Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Mixpanel.sharedInstanceWithToken is not a function #244

Open
ghasemikasra39 opened this issue Jun 19, 2020 · 3 comments
Open

Mixpanel.sharedInstanceWithToken is not a function #244

ghasemikasra39 opened this issue Jun 19, 2020 · 3 comments

Comments

@ghasemikasra39
Copy link

const Mixpanel = require('react-native-mixpanel');
Mixpanel.sharedInstanceWithToken(MIXPANEL_TOKEN_DEVELOPMENT, false, false);

Screenshot 2020-06-19 at 14 11 23

System:
    OS: macOS 10.15.3
    CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
    Memory: 22.38 MB / 8.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.13.1 - ~/.nvm/versions/node/v12.13.1/bin/node
    Yarn: 1.22.4 - ~/Documents/youpendo-app-bareworkflow/node_modules/.bin/yarn
    npm: 6.12.1 - ~/.nvm/versions/node/v12.13.1/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 28, 29
      Build Tools: 28.0.3, 29.0.2
      System Images: android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 3.6 AI-192.7142.36.36.6392135
    Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_232 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: ^4.8.0 => 4.10.0
    react: 16.11.0 => 16.11.0
    react-native: 0.62.2 => 0.62.2
  npmGlobalPackages:
    *react-native*: Not Found
   "react-native-mixpanel": "^1.2.0",
@bpfeiffer187
Copy link

so this is how i have it working. Granted i created a wrapper function.

import Mixpanel from 'react-native-mixpanel';

const logToMixpanel = (eventName: string, eventData = {}) => {
if (isMixpanelEnabled()) {
Mixpanel.sharedInstanceWithToken(mixpanelToken()).then(() => {
Mixpanel.trackWithProperties(eventName, {...DataLayer, ...eventData});
});
}
};

@ghasemikasra39
Copy link
Author

Dear @bpfeiffer187
Tested, getting the same error

@tibbus
Copy link

tibbus commented Aug 6, 2020

I cannot believe that I have wasted hours with this.
The solution is:
import mixpanel from 'react-native-mixpanel'; instead of using require

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants