PostHog / posthog-js-lite

Reimplementation of posthog-js to be as light and modular as possible.
https://posthog.com/docs/libraries
MIT License
69 stars 36 forks source link

React Native app tested with jest fails with: PostHog: No storage available. Please install expo-filesystem or react-native-async-storage OR implement a custom storage provider. #231

Closed itsramiel closed 6 months ago

itsramiel commented 6 months ago

Bug description

posthog-react-native fails when tested with jest. This was an issue before, but seems to have regressed

How to reproduce

  1. git clone https://github.com/itsramiel/posthog-repro
  2. cd posthog-repor
  3. yarn
  4. yarn test

Related sub-libraries

marandaneto commented 6 months ago

@itsramiel If you are using the RN SDK v3, you can just set eg persistence to memory or set your custom customStorage when in testing mode, for example, you can check the __DEV__ or something else and set those properties during the RN SDK init. https://posthog.com/docs/libraries/react-native#configuration-options

Does that help?

marandaneto commented 6 months ago

@itsramiel did you try this out?

itsramiel commented 6 months ago

@itsramiel did you try this out?

Oops forgot to reply. Yes that was my workaround anyway since it was already mentioned in the previous issue, but I thought it was a regression since it was handled internally after the creation of that issue.

If that's the solution going forward, then alright

marandaneto commented 6 months ago

Gotcha, yes that is the workaround until those libraries provide the implementation of the missing platforms.