Home » Android » java – How to clear distinct_id in mixpanel android when user logs out?

java – How to clear distinct_id in mixpanel android when user logs out?

Posted by: admin June 15, 2020 Leave a comment

Questions:

I need Mixpanel to forget distinct_id when user logs out.
In iOS app i call reset (https://mixpanel.com/site_media/doctyl/uploads/iPhone-spec/Classes/Mixpanel/index.html#//apple_ref/occ/instm/Mixpanel/reset)
and it works.

I cant find the right call in Android mixpanel documentation, i tried calling clearSuperProperties(), but distinct_id persists.

How to&Answers:
  1. Call .clearSuperProperties() to remove any Super Properties in local storage.
  2. Set new_distinct_id = UUID.randomUUID().toString());
  3. Call .identify(new_distinct_id) and .getPeople().identify(new_distinct_id)

This should wipe the device clean for a fresh user that can then register and be aliased to another distinct_id.

EDIT: The best way to do this with javascript is to delete the cookie. The name of the cookie is mp_{mixpanel_token_id}_mixpanel 🙂

Answer:

Actually there’s a reset() function in the MixpanelAPI class that, according to the doc, does the following : “Clears all distinct_ids, superProperties, and push registrations from persistent storage.”
Hope that helps