mixpanel-react-native icon indicating copy to clipboard operation
mixpanel-react-native copied to clipboard

TypeError: Cannot set property 'distinctId' of undefined when call identify method

Open klalex opened this issue 10 months ago • 6 comments

After signup I call mixpanel.identify(email). It logs I see LOG [Mixpanel] Identify '...'. But then immediately get this error:

TypeError: Cannot set property 'distinctId' of undefined.

I've checked email has value. So it's not undefined. Even in mixpanel logs email is displayed for identify.

mixpanel.track() works as expected though.

klalex avatar Apr 11 '24 05:04 klalex

hi @klalex , do you mind sharing the full log and the code snippet that can reproduce the issue?

zihejia avatar Apr 11 '24 20:04 zihejia

@zihejia I used example from docs:

const mixpanelToken = '...'; const mixpanel = new Mixpanel(mixpanelToken, false); mixpanel.setLoggingEnabled(true); mixpanel.init(); mixpanel.identify(email);

Also when I downgraded to version 2.4.1 it works now. So something wrong with version 3.0

klalex avatar Apr 11 '24 20:04 klalex

hi @klalex , would you like to try 3.0.2?

zihejia avatar Apr 16 '24 20:04 zihejia

I got the same error. It should be "await mixpanel.init();" because the init function is an async function.

enu-kuro avatar May 05 '24 03:05 enu-kuro

@zihejia In your React-Native example, the init() call is inside a Class Constructor. How can we wait on a Class Constructor in javascript? Also, the MixpanelManager class is pretty wild on itself and Class Components are close to being deprecated. Not sure it is the best solution for the example.

gabgagnon avatar Sep 11 '24 15:09 gabgagnon

I'm still facing this issue

Code-Victor avatar Oct 22 '24 12:10 Code-Victor