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

Remove alias check when calling identify #954

Merged
merged 1 commit into from
Nov 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 21 additions & 22 deletions Mixpanel/Mixpanel.m
Original file line number Diff line number Diff line change
Expand Up @@ -455,34 +455,33 @@ - (void)identify:(NSString *)distinctId usePeople:(BOOL)usePeople
self.anonymousId = self.distinctId;
self.hadPersistedDistinctId = YES;
}
// identify only changes the distinct id if it doesn't match either the existing or the alias;
// identify only changes the distinct id if it doesn't match the ID
// if it's new, blow away the alias as well.
if (![distinctId isEqualToString:self.alias]) {
if (![distinctId isEqualToString:self.distinctId]) {
NSString *oldDistinctId = [self.distinctId copy];
self.alias = nil;
self.distinctId = distinctId;
self.userId = distinctId;
[self track:@"$identify" properties:@{@"$anon_distinct_id": oldDistinctId}];
}
if (usePeople) {
self.people.distinctId = distinctId;
if (self.people.unidentifiedQueue.count > 0) {
for (NSMutableDictionary *r in self.people.unidentifiedQueue) {
r[@"$distinct_id"] = self.distinctId;
@synchronized (self) {
[self.peopleQueue addObject:r];
}
}
if (![distinctId isEqualToString:self.distinctId]) {
NSString *oldDistinctId = [self.distinctId copy];
self.alias = nil;
self.distinctId = distinctId;
self.userId = distinctId;
[self track:@"$identify" properties:@{@"$anon_distinct_id": oldDistinctId}];
}
if (usePeople) {
self.people.distinctId = distinctId;
if (self.people.unidentifiedQueue.count > 0) {
for (NSMutableDictionary *r in self.people.unidentifiedQueue) {
r[@"$distinct_id"] = self.distinctId;
@synchronized (self) {
[self.people.unidentifiedQueue removeAllObjects];
[self.peopleQueue addObject:r];
}
[self archivePeople];
}
} else {
self.people.distinctId = nil;
@synchronized (self) {
[self.people.unidentifiedQueue removeAllObjects];
}
[self archivePeople];
}
} else {
self.people.distinctId = nil;
}

[self archiveProperties];
});
#if MIXPANEL_FLUSH_IMMEDIATELY
Expand Down