samzilverberg/cordova-mixpanel-plugin

expose usePeople parameter to stop automatic creation of People profiles

Closed this issue · 5 comments

Hi Sam, I would like to raise your attention to a Mixpanel bug in iOS which has already been fixed by the Mixpanel team in their SDK v3.2.0 but hasn't been implemented in your plugin yet. As you know, on iOS Mixpanel uses the iPhone's IFA as the default distinct_id when aliasing new users. However, this has the unintended consequence that if a user logs out from the application and then a new user signs up, the new user's distinct_id will be the same as the first user's because the devices IFA doesn't change. To solve this issue, Mixpanel recommends to generate a random UUID and call identify with it after mixpanel.reset. The problem with this solution is that by default Mixpanel creates anonymous People profiles when identify is called on iOS; thus between logging out and logging back in the events dispatched to mixpanel are seen as coming from an anonymous user whose People profile is created which skews the actual number of users.

I talked to Jared McFarland from the Mixpanel support team regarding this issue and he wrote:

"The Mixpanel SDK automatically tracks the Total App Sessions and Total App Session Length People properties and when those were first added, it did cause People profiles to be automatically created whenever you called identify: so in v3.2.0 we added the option to set usePeople:NO to prevent identify from creating People profiles - https://github.com/mixpanel/mixpanel-iphone/releases/tag/v3.2.0 https://github.com/mixpanel/mixpanel-iphone/blob/master/Mixpanel/Mixpanel.h#L416-L428 Unfortunately, it doesn't look like that Cordova plugin exposes the usePeople parameter so calling identify will flush those automatic App Session People properties."

I was wondering if you could expose the usePeople parameter?

sure, i'm happy to expose any useful parameter to underlying sdk provides.
only thing that baffles me: is the problem really only ios related? i dont see any java (mixpanel-android) code related to this

Sam, I'm far from a Mixpanel expert, but according to my best knowledge this, is just an iOS issue, because on iOS Mixpanel uses the device's IFA as the dictinct ID, so Mixpanel recommends calling identify with a randomly generated UUID on reset, which in turn creates anonymous profiles unless you set usePeople:NO. Which is not currently exposed.

try out version 4.3.1
i added support for usePeople flag there

i will also release 4.4.0 within the hour with updated android/ios libs.
i didn't get a change to test them throughly, so maybe u can give 4.4.0 a quick try in your app and let me know if it works ok for you?

Hi Sam, it looks good. However, I found a bug in identify, basically the casting to Bool from [arguments objectAtIndex:1] was incorrect. I changed it to BOOL usePeople = [[arguments objectAtIndex:1] boolValue]; and it works now. I submitted a pull request with the fix. Thanks!

pulled in your commit. more info in pr comment:
#90 (comment)