Skip to content

Injected global variable _global can clash with user code #645

@timfish

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.

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