Open emibcn opened 5 years ago
Getting the same issue with my ReactJS WEB app after React Scripts upgrade to the latest version. @emibcn did you figured out the way to overcome this?
@webdevbyjoss Yes: don't load GA if process.env.NODE_ENV !== 'production'
:
https://github.com/emibcn/Rac1.js/blob/master/app/src/GAListener.jsx#L56
@emibcn I don't see that check: https://github.com/emibcn/Rac1.js/blob/master/app/src/GAListener.jsx#L15
Also, if that's the case, why is that not in the README?
Also, if that's the case, would you need to add that conditional at EVERY ReactGA
call? That's a lot of bloat. Why would that not be part of the initialize
and pageview
methods in the lib?
@alxvallejo
I don't see that check:
I changed this project a little bit, since I don't want to track users with DoNotTrack activated.
Also, if that's the case, why is that not in the README?
I am changing some things, but could not dedicate all the time I'd like. I will add it to README and add some UI elements to better control tracking from the UI.
Also, if that's the case, would you need to add that conditional at EVERY ReactGA call? That's a lot of bloat. Why would that not be part of the initialize and pageview methods in the lib?
I have moved the condition to the Component constructor at https://github.com/emibcn/Rac1.js/blob/master/app/src/GAListener.jsx#L72 :
const dnt = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
this.dnt = process.env.NODE_ENV !== 'production' || dnt === "1" || dnt === "yes";
@alxvallejo I have changed a bit the logic:
state
attribute trackOptIn
to global App that controls user tracking, using user's DNT and process.env.NODE_ENV
for defining the default value.prop
.ReactGA.event
depending on tracking value.https://github.com/react-ga/react-ga#test-mode - this helped me! Thanks for maintaining such an useful library guys! :)
https://github.com/react-ga/react-ga#test-mode - this helped me! Thanks for maintaining such an useful library guys! :)
Thanks, this solved my issue.
I'm getting this error while constructing and testing my app at TravisCI (removed tons of unrelated lines):
The related code is the GA loader, when inserting the tag to node (in file
react-ga/src/utils/loadGA.js
, at linem.parentNode.insertBefore
):Is there anything I can do to prevent this to fail? Or maybe it's better to only try to insert the node when the DOM is a real one?