You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// We are merging the metadata objects in case modules are bundled twice with the plugin
337
329
// Use try-catch to avoid issues when bundlers rename global variables like 'window' to 'k'
338
-
return`!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];if(null!=a)for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])}return e}({},e._sentryModuleMetadata[(new e.Error).stack],${JSON.stringify(
339
-
metadata
340
-
)})}catch(e){}}();`;
330
+
returnnewCodeInjection(
331
+
`e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];if(null!=a)for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])}return e}({},e._sentryModuleMetadata[(new e.Error).stack],${JSON.stringify(
332
+
metadata
333
+
)});`
334
+
);
341
335
}
342
336
343
337
exportfunctiongetBuildInformation(): {
@@ -459,3 +453,36 @@ export function containsOnlyImports(code: string): boolean {
459
453
460
454
returncodeWithoutImports.length===0;
461
455
}
456
+
457
+
exportclassCodeInjection{
458
+
// The code below is mostly ternary operators because it saves bundle size.
459
+
// The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
exports[`generateGlobalInjectorCode generates code with release and build information 1`] =`"!function(){try{var e=\\"undefined\\"!=typeof window?window:\\"undefined\\"!=typeofglobal?global:\\"undefined\\"!=typeofglobalThis?globalThis:\\"undefined\\"!=typeofself?self:{};e.SENTRY_RELEASE={id:\\"1.2.3\\"};e.SENTRY_BUILD_INFO={\\"deps\\":[\\"myDep\\",\\"rollup\\"],\\"depsVersions\\":{\\"rollup\\":3},\\"nodeVersion\\":18};}catch(e){}}();"`;
6
6
7
-
exports[`generateModuleMetadataInjectorCode generates code with empty metadata object 1`] =`"!function(){try{var e=\\"undefined\\"!=typeof window?window:\\"undefined\\"!=typeofglobal?global:\\"undefined\\"!=typeofglobalThis?globalThis:\\"undefined\\"!=typeofself?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(newe.Error).stack]=function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];if(null!=a)for(var t ina)a.hasOwnProperty(t)&&(e[t]=a[t])}returne}({},e._sentryModuleMetadata[(new e.Error).stack],{})}catch(e){}}();"`;
7
+
exports[`generateModuleMetadataInjectorCode generates code with empty metadata object 1`] =`"!function(){try{var e=\\"undefined\\"!=typeof window?window:\\"undefined\\"!=typeofglobal?global:\\"undefined\\"!=typeofglobalThis?globalThis:\\"undefined\\"!=typeofself?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(newe.Error).stack]=function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];if(null!=a)for(var t ina)a.hasOwnProperty(t)&&(e[t]=a[t])}returne}({},e._sentryModuleMetadata[(new e.Error).stack],{});}catch(e){}}();"`;
8
8
9
-
exports[`generateModuleMetadataInjectorCode generates code with metadata object 1`] = `"!function(){try{var e=\\"undefined\\"!=typeofwindow?window:\\"undefined\\"!=typeofglobal?global:\\"undefined\\"!=typeofglobalThis?globalThis:\\"undefined\\"!=typeofself?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(newe.Error).stack]=function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];if(null!=a)for(var t ina)a.hasOwnProperty(t)&&(e[t]=a[t])}returne}({},e._sentryModuleMetadata[(newe.Error).stack],{\\"file1.js\\":{\\"foo\\":\\"bar\\"},\\"file2.js\\":{\\"bar\\":\\"baz\\"}})}catch(e){}}();"`;
9
+
exports[`generateModuleMetadataInjectorCode generates code with metadata object 1`] = `"!function(){try{var e=\\"undefined\\"!=typeofwindow?window:\\"undefined\\"!=typeofglobal?global:\\"undefined\\"!=typeofglobalThis?globalThis:\\"undefined\\"!=typeofself?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(newe.Error).stack]=function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];if(null!=a)for(var t ina)a.hasOwnProperty(t)&&(e[t]=a[t])}returne}({},e._sentryModuleMetadata[(newe.Error).stack],{\\"file1.js\\":{\\"foo\\":\\"bar\\"},\\"file2.js\\":{\\"bar\\":\\"baz\\"}});}catch(e){}}();"`;
0 commit comments