123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- import { _optionalChain } from '@sentry/utils';
- import { defineIntegration } from '@sentry/core';
- import { rewriteFramesIntegration as rewriteFramesIntegration$1, RewriteFrames } from '@sentry/integrations';
- import { escapeStringForRegex, GLOBAL_OBJ } from '@sentry/utils';
- const globalWithInjectedValues = 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(`.*${escapeStringForRegex(distDirAbsPath)}`);
- return rewriteFramesIntegration$1({
- 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: RewriteFrames.id,
- // eslint-disable-next-line @typescript-eslint/no-empty-function
- setupOnce: () => {},
- processEvent: event => event,
- };
- }) ;
- const rewriteFramesIntegration = defineIntegration(customRewriteFramesIntegration);
- export { customRewriteFramesIntegration, rewriteFramesIntegration };
- //# sourceMappingURL=rewriteFramesIntegration.js.map
|