davide-scalzo/react-native-mixpanel

Cannot read property sharedInstanceWithToken of undefined

Opened this issue · 9 comments

MixpanelInstance.initialize is not working under the hood. Not sure what to do here. I install with npm i react-native-mixpanel and react-native link react-native-mixpanel.

import Mixpanel from 'react-native-mixpanel';

Mixpanel.sharedInstanceWithToken('');

code

import { MixpanelInstance } from 'react-native-mixpanel';
const mixpanel = new MixpanelInstance('key');

mixpanel.initialize().then(() => {
mixpanel.track('track screen name');
});

its not working

I am also facing this on iOS. Following @cielojrdev 's solution yields the same issue. I have not added [Mixpanel sharedInstanceWithToken:@"YOUR_API_TOKEN"]

as described in the additional steps but that is because there is no token present in the ObjC context. Any ideas?

@cielojrdev @Return-1
i am also having the issue, i have tried a few different things. i ended up adding sharedinstace with token in the app delegate but it isnt defined. i have tried a few different importants and nothing helped. Anyone get iOS going that can help

@chevulkar @Return-1 @bpfeiffer187 use version ^1.1.3
When I first commented that was version 1.1.1 and the latest 1.1.4 I'm having the same issue
But version ^1.1.3 works for me now

@cielojrdev @Return-1 there is an updated version 1.1.6, looks like this was forked.
i used the files from https://github.com/lorenc-tomasz/react-native-mixpanel
i used then approach @cielojrdev mentions above and that works fine.

This issue still exists in 1.1.14 btw. Reverted to 1.1.10 for now

when running my test using Jest and Enzyme, I get this error