PostHog / posthog-js-lite

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

If `async-storage` or `expo-file-system` is not installed, the SDK will fallback to `persistence: memory` and log a warning #146

Closed marandaneto closed 11 months ago

marandaneto commented 11 months ago

Problem

If you install the PH SDK in a clean sample app and run yarn test, the test will fail because the PH SDK needs the storage libs but they aren't available for other targets than Android and iOS. The only option is to mock the libs or set the persistence to memory, both are not great as a first experience when using our SDK so it's better to use a fallback instead of throwing an error and letting the user figure it out.

Fixes https://github.com/PostHog/posthog-js-lite/issues/143

Changes

SDK fallback to persistence: memory if storage libs aren't installed. Added a test but it failed because of https://github.com/facebook/react-native/issues/35701 so I removed it, I tested the code at runtime though.

Release info Sub-libraries affected

Bump level

Libraries affected

Changelog notes

marandaneto commented 11 months ago

I really don't like this solution but I can't think of a better one so lets do it 😅

Same 😅