Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

analytics constructor can fail to init breaking entire app #391

Open
ryanhamilton opened this issue Jul 14, 2023 · 0 comments
Open

analytics constructor can fail to init breaking entire app #391

ryanhamilton opened this issue Jul 14, 2023 · 0 comments

Comments

@ryanhamilton
Copy link

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 };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant