As the title suggest, I am struggling to get multiple users on the same device working. The situation is as follows:
- Users browse anonymous and gets a ‘random’ distinctId (98CB5B1C-7922-44C8-8FAC-ED03BD1BB564).
- Users logs in. In code I call identify to set the distinctId (e.g. 114)
- User browses app on which each subsequent call distinctId of 114 correctly gets sent along
- User logs out, in code I call reset method to reset the distinctId and remove existing super properties. I see reset is being called due to logging in Xcode (I also call a flush just to be sure).
- Now the anonymous user does not get a new ‘random’ distinctId. Instead it gets the distinctId which was set in step 1.
The problem is that after calling identify, the ‘random’ distinctId of 98CB5B1C-7922-44C8-8FAC-ED03BD1BB564 is linked to 114. So this is linked to a logged in user. Also, in the documentation it states that it resets the distinctId which it sort of does, but not to a random new value, actually it sets it to an old value. The reason why I expect a new random UUID or something of that sort is this source under ‘Multiple Users on Single Devices: Identify on Login, Reset on Logout’ states:
“Mixpanel will treat subsequent events on the same device as performed by a new user. “
but this is not true in my case, because the ‘new user’ is the user previously logged in. This is also confirmed by going to the user’s profile where I can see the multiple linked distinctId’s to this user:
What am I missing?
Best answer by robin
There is an extra step in ios
let uuid = UUID().uuidString