Multiple users on same ios device not working as I would expect
Opened this issue · 2 comments
Hi,
I had an issue with multiple users on the same device (ios in this case). I posted my question here:
https://community.mixpanel.com/sending-data-to-mixpanel-11/multiple-users-on-same-device-not-working-as-i-would-expect-4872
Key question is as follows:
Why does a reset() not set a new random distinctId, but reverts it back to the old 'anonymous' distinctId.
Example:
- Anonymous user browses app with distinctId 98CB5B1C-7922-44C8-8FAC-ED03BD1BB564
- user logs in (identify called with userId 144). DistinctId is now 144.
- user browses app and all event correctly get distinctId 144.
- user logs out (reset method is called). Distinct Id gets set back to 98CB5B1C-7922-44C8-8FAC-ED03BD1BB564 instead of a random new distinctId. I think it should be a new random distinctId based on the documentation:
"Reset generates a new random distinct_id and clears super properties." (source: https://developer.mixpanel.com/docs/swift).
After diving into this repository I saw the following line of code in the reset() method:
self.distinctId = self.anonymousId;
on line 945 in https://github.com/samzilverberg/cordova-mixpanel-plugin/blob/master/src/ios/Mixpanel/Mixpanel.m
Is this expected behaviour or should it be set to a new random distinctId (new UUID)? Am I missing something?
Cheers,
Bart
Worth noting is that I tested it on Android which doesn't have this 'bug'. On android when a user logs out (call reset()) the new event gets a new unique distinctId. Note the difference in distinctId onHomePage before calling identify (f9996458-1430-487f-91f7-c95acbe645b6) and after logout onLoginPage after calling reset (2faa0443-7ecf-4f4d-b9a2-95c060c68b24).
Apparently, this is well known in their implementation, see: mixpanel/mixpanel-swift#139