Skip to content

Commit

Permalink
Merge pull request #954 from argenisf/master
Browse files Browse the repository at this point in the history
Remove alias check when calling identify
  • Loading branch information
zihejia authored Nov 14, 2021
2 parents d489e8d + 270dba4 commit 3ed699f
Showing 1 changed file with 21 additions and 22 deletions.
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

0 comments on commit 3ed699f

Please sign in to comment.