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

React Native Web and `expo-file-system` support #140

Closed marandaneto closed 10 months ago

marandaneto commented 11 months ago

Description

https://github.com/necolas/react-native-web#readme

RN Web is getting more popular but our SDK does not support it yet, at least not without workarounds.

The goal of this issue is to list all the issues encountered and at least make the changes to run the SDK on RN Web without any compile/runtime issues, even if some features have to be disabled.

Issues faced as of now:

saulamsal commented 10 months ago

Is there an estimated timeline for this?

marandaneto commented 10 months ago

@saulamsal not planned yet, but please upvote the issue to gather interest.

Fixing the compile/runtime issues by disabling a few features should be doable though, would you like to give it a try with my guidance? happy to guide/review.

marandaneto commented 10 months ago

A quick workaround, for now, is to just call the API directly until we provide first-class support for React Native Web.

saulamsal commented 10 months ago

@marandaneto, I think I will just create a simple wrapper for RN Web with an API for now. Hopefully, you guys have a plan to work on it.

marandaneto commented 10 months ago

When using async-storage instead of expo-file-system, almost everything works out of the box, the problem is only with expo-file-system since it does not support the Web target.

Screenshot 2024-01-22 at 11 32 48

Another option is to use the persistence: "memory" when initing the SDK, so it's not using the file system at all. This is done since this version, but you will see a warning.

Another improvement: https://github.com/PostHog/posthog-js-lite/pull/157