Skip to content
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

Supports setOnce #51

Merged
merged 1 commit into from
Oct 28, 2017
Merged

Supports setOnce #51

merged 1 commit into from
Oct 28, 2017

Conversation

ladanazita
Copy link
Contributor

@ladanazita ladanazita commented Oct 27, 2017

setOnce sets the value of a user property only once. Subsequent setOnce operations on that user property will be ignored.

Checks traits against values in settings.traitsToSetOnce

@SegmentBot
Copy link

By analyzing the blame information on this pull request, we identified and undefined to be a potential reviewer.

@@ -21,6 +21,10 @@ - (id)initWithSettings:(NSDictionary *)settings andAmplitude:(Amplitude *)amplit
self.traitsToIncrement = [NSSet setWithArray:self.settings[@"traitsToIncrement"]];
}

if (self.settings[@"traitsToSetOnce"] != (id)[NSNull null]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the cast here? Also does this handle nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we determined that settings.traitsToSetOnce could be @[] or null, not nil

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But does this check handle all those cases? It seems to me it would only handle the null case.

@@ -73,7 +77,7 @@ - (void)identify:(SEGIdentifyPayload *)payload
[self.amplitude setUserId:payload.userId];
SEGLog(@"[Amplitude setUserId:%@]", payload.userId);

if ([self.traitsToIncrement count] > 0) {
if ([self.traitsToIncrement count] > 0 || [self.traitsToSetOnce count] > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should consider removing the else block (not in this PR but as a follow up) as this block will do the same thing if these settings are both empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm but I don't want to return within this block so that it checks groups. I can move groups up in another PR and then return out of this block and remove the else

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, I think this is wrong. This going to call incrementOrSetTraits and setUserProperties. We don't want that. What I was I saying is I think we don't need to have this check, and don't need setUserProperties at all, the incrementOrSetTraits on it's own will handle correctly (no early return here).

Either way let's go back to what you had before and make the change in a follow up PR.

@ladanazita ladanazita changed the title Supports setting to set traits once Supports setOnce Oct 28, 2017
@ladanazita ladanazita merged commit fcf587f into master Oct 28, 2017
@ladanazita ladanazita deleted the adds/setOnce branch October 28, 2017 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants