Closed ellotheth closed 2 years ago
In case anybody else hits this, I've got a (very temporary) workaround that wraps Plausible operations and eats any errors:
const safe = (callback, args) => {
try {
return callback(...args);
} catch (e) {
// fail silently
}
}
const safePlausible = plausible => ({
trackEvent: (...args) => safe(plausible.trackEvent, args),
trackPageview: (...args) => safe(plausible.trackPageview, args),
enableAutoPageviews: (...args) => safe(plausible.enableAutoPageviews, args),
enableAutoOutboundTracking: (...args) => safe(plausible.enableAutoOutboundTracking, args),
});
const plausible = safePlausible(Plausible(options));
Using plausible-tracker@0.3.5, I am encountering the same error Cannot read properties of null (reading 'getItem')
when calling plausible.trackPageview()
, especially with calls from Android Webviews where setDomStorageEnabled
has not been called (it is false by default).
Sorry about that. I didn't know that disabling localStorage was a thing 😄. Should be fixed by #31 👍 .
Versions
Describe the bug
I'm using Plausible with ReactJS, and I enable automatic pageview tracking:
If
localStorage
is null or disabled (e.g. Block all cookies in Chromium 98),plausible.enableAutoPageviews()
throws an error:Expected behavior
Tracking should continue as if the
plausible_ignore
key were unset.Steps to reproduce
localStorage
in your browser of choiceplausible.enableAutoPageviews()
Your Environment