UNPKG

@sentry/nextjs

Version:
16 lines (12 loc) 1.11 kB
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } }); const valueInjectionLoader = require('./valueInjectionLoader.js'); 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 window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"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 = valueInjectionLoader.findInjectionIndexAfterDirectives(userCode); return `${userCode.slice(0, injectionIndex)}${injectedCode}${userCode.slice(injectionIndex)}`; } exports.default = moduleMetadataInjectionLoader; //# sourceMappingURL=moduleMetadataInjectionLoader.js.map