nytimes / react-tracking

🎯 Declarative tracking for React apps.
https://open.nytimes.com/introducing-react-tracking-declarative-tracking-for-react-apps-2c76706bb79a
Other
1.87k stars 123 forks source link

Fix compatibility issue with React Native environment #220

Closed kimskovhusandersen closed 1 year ago

kimskovhusandersen commented 1 year ago

This is to improve the compatibility with React Native and ensure the dispatch function is triggered correctly.

Currently, the code assumes the availability of the "window" object without checking its type, which is causing an issue with the dispatch function in React Native where "window" is not present. 🙅‍♂️

To fix this, I have added a simple check to ensure the "window" object is defined using typeof window === "undefined". This allows the code to gracefully handle React Native environments and ensures the dispatch function works smoothly in web browser environments. 🚀

Thank you so much for your time and consideration. 🙏

kimskovhusandersen commented 1 year ago

Great, thank you! 🙏 👍

Just out of curiosity, when can we expect the next release of the library with the recent changes to be published on NPM?

Much appreciated!

tizmagik commented 1 year ago

Released in v9.3.2

kimskovhusandersen commented 1 year ago

Amazing! Thank you very much 👍 🙏

anna-rusk commented 1 year ago

What version of React/React Native are you on? I am seeing this error when using react: 18.2.0 and react-native: 0.71.8 and am using the latest patch v9.3.2 of this package

Screenshot 2023-06-08 at 3 29 02 PM
tizmagik commented 1 year ago

@anna-rusk that looks like a different error entirely. Mind opening up a new issue with more context? Thanks.

anna-rusk commented 1 year ago

I had this issue open! It was closed recently but I am still facing this issue - I will post more context there

https://github.com/nytimes/react-tracking/issues/218