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
Updates group to accept new group settings #43
Conversation
By analyzing the blame information on this pull request, we identified and undefined to be a potential reviewer. |
if ([payload.traits objectForKey:groupTypeTrait] && [payload.traits objectForKey:groupTypeValue]) { | ||
groupName = [payload.traits objectForKey:groupTypeTrait]; | ||
groupValue = [payload.traits objectForKey:groupTypeValue]; | ||
|
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.
extra line?
} | ||
|
||
[self.amplitude setGroup:groupValue groupName:groupName]; | ||
SEGLog(@"[Amplitude setGroup:%@' groupName:%@]", groupValue, groupName); |
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.
extra '
?
NSString *groupName; | ||
NSString *groupValue = payload.groupId; | ||
|
||
NSString *groupTypeTrait = self.settings[@"groupTypeTrait"]; |
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.
What happens if groupTypeTrait
is not set?
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.
It will default to the old behavior. Or are you saying to check if the value for this setting exists?
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.
Not quite. I was wondering what would happen at payload.traits objectForKey:groupTypeTrait
if groupTypeTrait
is null here.
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.
It will just default to the original behavior
|
||
NSString *groupName; | ||
NSString *groupValue; | ||
if ([payload.traits objectForKey:groupTypeTrait] && [payload.traits objectForKey:groupTypeValue]) { |
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.
could be payload.traits[groupTypeTrait]
?
[self.amplitude setGroup:@"[Segment] Group" groupName:groupId]; | ||
SEGLog(@"[Amplitude setGroup:@'[Segment] Group' groupName:%@]", groupId); | ||
NSString *groupTypeTrait; | ||
if (self.settings[@"groupTypeTrait"]) { |
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 don't understand why this is an if check.
What's the difference between these two pieces of code:
NSString *groupTypeTrait = self.settings[@"groupTypeTrait"];
NSString *groupTypeTrait;
if (self.settings[@"groupTypeTrait"]) {
groupTypeTrait = self.settings[@"groupTypeTrait"];
}
They seem functionally equivalent to me.
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 misunderstood your original question then about "What happens if groupTypeTrait is not set?"
will revert
8f6f5b2
to
2c029be
Compare
andAmpRevenue:amprevenue]; | ||
SEGGroupPayload *payload = [[SEGGroupPayload alloc] initWithGroupId:@"32423084" traits:@{ | ||
@"company" : @"Segment", | ||
@"industry" : @"Technology" |
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.
This test looks ok, but I think it's a bit confusing since groupType:groupTrait should follow the pattern general:specific. Here, looks like specific:general (i.e. Segment:Technology).
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.
makes sense, changed 👇
if (groupId) { | ||
[self.amplitude setGroup:@"[Segment] Group" groupName:groupId]; | ||
SEGLog(@"[Amplitude setGroup:@'[Segment] Group' groupName:%@]", groupId); | ||
NSString *groupTypeTrait = self.settings[@"groupTypeTrait"]; |
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.
This block:
NSString *groupTypeTrait = self.settings[@"groupTypeTrait"];
NSString *groupTypeValue = self.settings[@"groupTypeValue"];
NSString *groupName;
NSString *groupValue;
if (payload.traits[groupTypeTrait] && payload.traits[groupTypeValue]) {
groupName = payload.traits[groupTypeTrait];
groupValue = payload.traits[groupTypeValue];
} else {
groupName = payload.traits[@"name"] ?: @"[Segment] Group";
groupValue = payload.groupId;
}
Is likely more readable and less error prone as:
NSString *groupTypeTrait = self.settings[@"groupTypeTrait"];
NSString *groupTypeValue = self.settings[@"groupTypeValue"];
NSString *groupName = payload.traits[groupTypeTrait];
NSString *groupValue = payload.traits[groupTypeValue];
if (!groupName || !groupValue) {
groupName = payload.traits[@"name"] ?: @"[Segment] Group";
groupValue = payload.groupId;
}
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.
Amplitude allows customers to send multiple types of groups on the same event, for example
group_type
: org namegroup_value
: engineeringgroup_type
: org idgroup_value
: 1234The new Segment settings
groupTypeTrait
(group type) andgroupTypeValue
(group value) allow the user to set which keys the Segment integration will look for to determine what to set for group name and group values in Amplitude.We will default to legacy behavior, which was incorrect prior to this PR (incorrectly setting group type as
[Segment] Group
andgroup.id
to group name)