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

Cannot read property sharedInstanceWithToken of undefined

Open ColtraneNadler opened this issue 5 years ago • 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

ColtraneNadler avatar Feb 21 '19 16:02 ColtraneNadler

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

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

cielojrdev avatar Mar 06 '19 04:03 cielojrdev

its not working

chevulkar avatar Apr 23 '19 17:04 chevulkar

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

migcv avatar May 31 '19 16:05 migcv

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?

Return-1 avatar Jul 15 '19 14:07 Return-1

@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

bpfeiffer187 avatar Aug 05 '19 16:08 bpfeiffer187

@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 avatar Sep 13 '19 21:09 cielojrdev

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

bpfeiffer187 avatar Sep 16 '19 12:09 bpfeiffer187

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

ralph-dev avatar Dec 26 '19 00:12 ralph-dev

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

ghasemikasra39 avatar Sep 02 '20 20:09 ghasemikasra39