Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3 is broken for React Native with custom storage #256

Open
thoth-seshat opened this issue Jun 18, 2024 · 0 comments
Open

v3 is broken for React Native with custom storage #256

thoth-seshat opened this issue Jun 18, 2024 · 0 comments

Comments

@thoth-seshat
Copy link

Adding another issue to highlight v3 being very broken as mentioned

here: #255
and here: #247

Running version 3.0.8 with MMVK

Here is my setup:

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);
  },
};

const trackAutomaticEvents = true;
const useNative = true;
const mixpanel_api_key = process.env.EXPO_MIXPANEL_API_KEY ?? "";
const mixpanel = new Mixpanel(
  mixpanel_api_key,
  trackAutomaticEvents,
  useNative,
  MMKVStorageAdapter,
);

function useMixpanel() {
  useEffect(() => {
    if (mixpanel_api_key) {
      mixpanel.init();
    } else {
      Sentry.captureMessage("Mixpanel API key not found when starting the app");
    }
  }, [mixpanel_api_key]);
}

Also note that this will throw a TS error on the useNative field. Setting it to false doesn't throw an error but will still break the app.

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

No branches or pull requests

1 participant