UNPKG

@sentry/nextjs

Version:
18 lines (14 loc) • 1.19 kB
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } }); const loaderUtils = require('@sentry/bundler-plugins/loader-utils'); function moduleMetadataInjectionLoader(userCode) { const { applicationKey } = "getOptions" in this ? this.getOptions() : this.query; this.cacheable(false); const metadata = JSON.stringify({ [`_sentryBundlerPluginAppKey:${applicationKey}`]: true }); const injectedCode = `;!function(){try{var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=Object.assign({},e._sentryModuleMetadata[(new e.Error).stack],${metadata});}catch(e){}}();`; const injectionIndex = loaderUtils.getCodeInjectionPosition(userCode); const codeToInject = injectionIndex === userCode.length ? ` ${injectedCode}` : injectedCode; return `${userCode.slice(0, injectionIndex)}${codeToInject}${userCode.slice(injectionIndex)}`; } exports.default = moduleMetadataInjectionLoader; //# sourceMappingURL=moduleMetadataInjectionLoader.js.map