-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Moves logRevenueV2 logic into trackLogRevenue method #39
Conversation
By analyzing the blame information on this pull request, we identified and undefined to be a potential reviewer. |
- (void)trackLogRevenueV2:(NSDictionary *)properties andRevenueOrTotal:(NSNumber *)revenueOrTotal | ||
{ | ||
id price = [properties objectForKey:@"price"] ?: revenueOrTotal; | ||
id quantity = [properties objectForKey:@"quantity"] ?: [NSNumber numberWithInt:1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Android, we set quantity to 1 if "price" is null but either revenue or total has a value. That's because Amplitude will calculate their internal revenue with price * quantity. Maybe we should guard against this in iOS as well: https://github.com/segment-integrations/analytics-android-integration-amplitude/blob/master/src/main/java/com/segment/analytics/android/integrations/amplitude/AmplitudeIntegration.java#L203-L211
@@ -42,7 +42,6 @@ + (NSNumber *)extractRevenueOrTotal:(NSDictionary *)dictionary withRevenueKey:(N | |||
|
|||
if ([key caseInsensitiveCompare:totalKey] == NSOrderedSame) { | |||
revenueOrTotal = dictionary[key]; | |||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm... why did this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want revenue to be used in cases where both total and revenue are present
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll want to add this reason as a comment in the codebase so the next developer (e.g. future you) does not look at it and think there's a missed break
and thus a bug then put it back in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will say that if a break was added, tests would fail
This is hard to review because of the huge diff. It would be better to break this up into commits or PR that are easier to review.
|
d8e50cd
to
8872932
Compare
Tests succeed with:
Build succeeds with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should clarify unexpected code usage via comments.
@@ -42,7 +42,6 @@ + (NSNumber *)extractRevenueOrTotal:(NSDictionary *)dictionary withRevenueKey:(N | |||
|
|||
if ([key caseInsensitiveCompare:totalKey] == NSOrderedSame) { | |||
revenueOrTotal = dictionary[key]; | |||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll want to add this reason as a comment in the codebase so the next developer (e.g. future you) does not look at it and think there's a missed break
and thus a bug then put it back in.
[self.amprevenue setReceipt:receipt]; | ||
SEGLog(@"[[AMPRevenue revenue] setReceipt:%@];", receipt); | ||
} | ||
id revenueType = [properties objectForKey:@"revenueType"] ?: [properties objectForKey:@"revenue_type"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally it's preferred to use shorthand syntax via []
. is there any reason you are not?
Build Succeeds with
xcodebuild -scheme Segment-Amplitude_Example -workspace Example/Segment-Amplitude.xcworkspace
Tests succeed locally
xcodebuild test -scheme Segment-Amplitude_Example -workspace Example/Segment-Amplitude.xcworkspace -destination 'platform=iOS Simulator,name=iPhone 6'
But fails with
When simulator is changed to
name=iPhone 5
Travis and Podfile.lock issues are fixed on a separate branch:
#38