Denying cookies crashes the script
jehna opened this issue · comments
If your browser has cookies disabled, using localStorage
throws an error that crashes ga-lite.
ga-lite should be able to work even without localstorage.
According to MDN:
Safari Mobile's Private Browsing mode also prevents writing to
localStorage
entirely.
~ https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage#Browser_compatibility
So we should be able to skip localStorage
and degrade backwards without crashing.
I am having this issue with an anonymous browser (Windows 7 / Chrome 72.0.3626). It's rare but just occurred on our production site.
This probably can be quick fixed if we add a try-catch to get-user-id.js
and fall back to something that does not require a persistence (like a normal variable).
Though denying cookies is a strong indicator that the user does not want to be tracked; I'm thinking if we should disable the ga-lite tracking then altogether?
I have no issue with doing that... It seems like a rare case anyway.