analytics
analytics copied to clipboard
analytics constructor can fail to init breaking entire app
Version: "analytics": "^0.8.1",
If you have a URL containing this: ?a=1&%%20Exe
The line:
export const analytics = Analytics({ app: 'Pulse', debug:true, plugins: myPlugins });
Will throw an error (stack trace below). Which since I didn't have it trapped and I run this early in my application, causes the whole app not to load.
Stack Trace:
Uncaught TypeError: a is null
s analytics-utils.module.js:55
s analytics-utils.module.js:64
Ve analytics-core.module.js:1142
analyticsLib analytics.browser.es.js:43
tsx App.tsx:102
factory react refresh:6
Webpack 7
analytics-utils.module.js:55
s analytics-utils.module.js:55
s analytics-utils.module.js:64
Ve analytics-core.module.js:1142
analyticsLib analytics.browser.es.js:43
tsx App.tsx:102
factory react refresh:6
Webpack 7
As a workaround and to prevent analytics from ever being able to break my app I'm doing:
let analytics:any = { track:()=>{}, page:()=>{}};
try {
analytics = Analytics({ app: 'Pulse', debug:true, plugins: myPlugins });
} catch {
console.error("analytics failed to load");
}
export { analytics };