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

[Upgrade to v3] : [@RNC/AsyncStorage]: NativeModule: AsyncStorage is null.

Open christophemenager opened this issue 1 year ago • 7 comments

Context

  • I am using this lib in a react-native environment (not web)
  • I don't use AsyncStorage but mmkv storage

Before (v2)

  • Everything worked fine, no error

After (v3)

 ERROR  [@RNC/AsyncStorage]: NativeModule: AsyncStorage is null. Please run 'npm install @react-native-async-storage/async-storage' or follow the Mixpanel guide to set up your own Storage class.
 ERROR  [Mixpanel] Falling back to in-memory storage
  • I don't want to install @RNC/AsyncStorage in my dependencies for this library only
  • Documentation is quite confusing about custom storage or not, async storage or not, web support and could be re-phrased I think

For now, I keep using 2.4.1 as v3 is not usable.

christophemenager avatar May 30 '24 08:05 christophemenager

I have the exact same setup as @christophemenager in my project and 💯 to his point about the docs, they don't make any sense at all.

Also, in case anyone needs it, here is the MMVK wrapper that SHOULD work when giving your own storage location but doesn't (since using your own storage in React Native breaks this lib). I can't stop stop development to wait for this to get fixed so I'm going to have to fall back. Thanks for heads up to fallback to v2.

Kinda sucks that v3 is broken.

const storage = new MMKV({ id: "mixpanel" });

const MMKVStorageAdapter: MixpanelAsyncStorage = {
  getItem: async (key) => {
    return storage.getString(key) || null;
  },
  setItem: async (key, value) => {
    storage.set(key, value);
  },
  removeItem: async (key) => {
    storage.delete(key);
  },
};

thoth-seshat avatar Jun 18 '24 01:06 thoth-seshat

Yes @thoth-seshat v3 is broken since several months now, but Mixpanel does not seem to care unfortunately...

christophemenager avatar Jun 19 '24 14:06 christophemenager

I apologize for the inconvenience and frustration caused by the ongoing issues with v3. We are aware of the problem and are working on it, thank you for your patience and understanding.

zihejia avatar Jun 20 '24 16:06 zihejia

@zihejia thanks for your answer. Do you have an ETA to fix the v3 release? It has been broken since 6 weeks now :/

christophemenager avatar Jul 01 '24 07:07 christophemenager

@zihejia do you have plan to fix this issue? It has been several months since v3 is broken for many users.

christophemenager avatar Sep 09 '24 09:09 christophemenager

So the expo support in v3 has been broken for months. Does anyone have an alternative lib to integrate with Mixpanel that works with Expo?

its-rav avatar Sep 10 '24 05:09 its-rav

@its-rav not that I am aware of. I picked mixpanel for analytics because of their react-native integration that sounded great, but I am thinking of switching to Amplitude now

christophemenager avatar Sep 12 '24 06:09 christophemenager

Any updates on this? We are facing the same issue.

Kartik4152 avatar Nov 18 '24 14:11 Kartik4152

@Kartik4152 nothing new since v3 was released almost 6 months ago. I am still stuck on v2 because of this. @zihejia said they were working on it 5 months ago and they made releases since then, so I hope a fix will come soon.

christophemenager avatar Nov 19 '24 10:11 christophemenager

For info I have moved to a competitor : https://posthog.com/docs/libraries/react-native which has an excellent react-native support, that's what I was looking for when I first chose mixpane,l but I was wrong 🤦

Good luck!

christophemenager avatar Nov 22 '24 09:11 christophemenager

This is throwing an error, but what is the impact of the issue? Something related to persisting user data? It seems to me events are correctly sent even although this error appears

PierreCapo avatar Jan 21 '25 10:01 PierreCapo

@zihejia we followed documentation and got this error in terminal. does it affect functionality? can this error be fixed?

//import Mixpanel class from the SDK
import { Mixpanel, MixpanelAsyncStorage } from 'mixpanel-react-native'
import { MMKV } from 'react-native-mmkv'

const mixpanelStorage = new MMKV({ id: 'mixpanel' })

const superProperties = {
	data_source: 'react-native-app',
}

const mixpanelAsyncStorage: MixpanelAsyncStorage = {
	getItem: async (key) => mixpanelStorage.getString(key) ?? null,
	setItem: async (key, value) => mixpanelStorage.set(key, value),
	removeItem: async (key) => mixpanelStorage.delete(key),
}

export const mixpanel = new Mixpanel(<TOKEN>, false, false, mixpanelAsyncStorage)

patrikduksin avatar Apr 08 '25 23:04 patrikduksin

Fixed by https://github.com/mixpanel/mixpanel-react-native/pull/282 in v3.0.9

jaredmixpanel avatar Apr 11 '25 23:04 jaredmixpanel