var { _optionalChain } = require('@sentry/utils'); Object.defineProperty(exports, '__esModule', { value: true }); const core = require('@sentry/core'); const integrations = require('@sentry/integrations'); const utils = require('@sentry/utils'); const globalWithInjectedValues = utils.GLOBAL_OBJ ; const customRewriteFramesIntegration = ((options) => { // This value is injected at build time, based on the output directory specified in the build config. Though a default // is set there, we set it here as well, just in case something has gone wrong with the injection. const distDirName = globalWithInjectedValues.__rewriteFramesDistDir__; if (distDirName) { const distDirAbsPath = distDirName.replace(/(\/|\\)$/, ''); // We strip trailing slashes because "app:///_next" also doesn't have one // Normally we would use `path.resolve` to obtain the absolute path we will strip from the stack frame to align with // the uploaded artifacts, however we don't have access to that API in edge so we need to be a bit more lax. // eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor -- user input is escaped const SOURCEMAP_FILENAME_REGEX = new RegExp(`.*${utils.escapeStringForRegex(distDirAbsPath)}`); return integrations.rewriteFramesIntegration({ iteratee: frame => { frame.filename = _optionalChain([frame, 'access', _ => _.filename, 'optionalAccess', _2 => _2.replace, 'call', _3 => _3(SOURCEMAP_FILENAME_REGEX, 'app:///_next')]); return frame; }, ...options, }); } // Do nothing if we can't find a distDirName return { // eslint-disable-next-line deprecation/deprecation name: integrations.RewriteFrames.id, // eslint-disable-next-line @typescript-eslint/no-empty-function setupOnce: () => {}, processEvent: event => event, }; }) ; const rewriteFramesIntegration = core.defineIntegration(customRewriteFramesIntegration); exports.customRewriteFramesIntegration = customRewriteFramesIntegration; exports.rewriteFramesIntegration = rewriteFramesIntegration; //# sourceMappingURL=rewriteFramesIntegration.js.map