[Upgrade to v3] : [@RNC/AsyncStorage]: NativeModule: AsyncStorage is null.
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.
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);
},
};
Yes @thoth-seshat v3 is broken since several months now, but Mixpanel does not seem to care unfortunately...
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 thanks for your answer. Do you have an ETA to fix the v3 release? It has been broken since 6 weeks now :/
@zihejia do you have plan to fix this issue? It has been several months since v3 is broken for many users.
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 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
Any updates on this? We are facing the same issue.
@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.
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!
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
@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)
Fixed by https://github.com/mixpanel/mixpanel-react-native/pull/282 in v3.0.9