Skip to content

Injected global variable _global can clash with user code #645

Description

@timfish

We inject code that creates a new variable called _global:

let code = `
var _global =
typeof window !== 'undefined' ?
window :
typeof global !== 'undefined' ?
global :
typeof globalThis !== 'undefined' ?
globalThis :
typeof self !== 'undefined' ?
self :
{};
_global.SENTRY_RELEASE={id:${JSON.stringify(release)}};`;

There is a chance this can clash with user code if that variable name is used.

We should either chose a variable name that is more unique and less likely to clash with user code or wrap this code block in a closure so that the scope is private.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions