segment-integrations / analytics-ios-integration-amplitude

The Amplitude analytics-ios integration.
MIT License
11 stars 45 forks source link

Old traits are set on new user #93

Open cerupcat opened 3 years ago

cerupcat commented 3 years ago

Users that logout and create another account are associated to the original user.

I'm currently performing the following:

The second user is associated with the first in amplitude and the email trait is not set.

cerupcat commented 3 years ago

Doing some more research, it's unclear if this is an Amplitude bug or Segment bug.

When calling identify in the Segment SDK, the Amplitude SDK method is called - (void)identify:(AMPIdentify *)identify. However, the identify.userPropertyOperations are the traits that were first set in the first identify call, not the most recent traits in the identify call and therefore previous traits are set on new users when identify is called.

cerupcat commented 3 years ago

On -(void)reset, reinitializing the identify in SEGAmpltidueIntegration.m seems to solve this.

- (void)reset
{
    [self.amplitude setUserId:nil];
    SEGLog(@"[Amplitude setUserId:nil");

    [self.amplitude regenerateDeviceId];
    SEGLog(@"[Amplitude regnerateDeviceId];");

    self.identify = [AMPIdentify identify]; // NEW CODE
    SEGLog(@"[Amplitude reset identify];");
}
cerupcat commented 3 years ago

Pull request: #95