davide-scalzo / react-native-mixpanel

A React Native wrapper for Mixpanel tracking
MIT License
455 stars 195 forks source link

Cannot read property sharedInstanceWithToken of undefined #170

Open ColtraneNadler opened 5 years ago

ColtraneNadler commented 5 years ago

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

cielojrdev commented 5 years ago

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

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

chevulkar commented 5 years ago

its not working

migcv commented 5 years ago

Did you do the required additional steps? https://github.com/davodesign84/react-native-mixpanel#additional-step-for-ios

Return-1 commented 5 years ago

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?

bpfeiffer187 commented 5 years ago

@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

cielojrdev commented 5 years ago

@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

bpfeiffer187 commented 5 years ago

@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.

ralph-dev commented 4 years ago

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

ghasemikasra39 commented 4 years ago

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