@@ -2,6 +2,7 @@ import { RewriteFrames } from '@sentry/integrations';
2
2
import { configureScope , getCurrentHub , init as nodeInit , Integrations } from '@sentry/node' ;
3
3
import { hasTracingEnabled } from '@sentry/tracing' ;
4
4
import { escapeStringForRegex , logger } from '@sentry/utils' ;
5
+ import * as path from 'path' ;
5
6
6
7
import { instrumentServer } from './utils/instrumentServer' ;
7
8
import { MetadataBuilder } from './utils/metadataBuilder' ;
@@ -49,14 +50,19 @@ function sdkAlreadyInitialized(): boolean {
49
50
50
51
function addServerIntegrations ( options : NextjsOptions ) : void {
51
52
// This value is injected at build time, based on the output directory specified in the build config
52
- const distDirRegex = ( global as typeof global & { __rewriteFramesRegex__ : string } ) . __rewriteFramesRegex__ ;
53
- const SOURCEMAP_FILENAME_REGEX = new RegExp ( escapeStringForRegex ( distDirRegex ) ) ;
53
+ const distDir = ( global as typeof global & { __rewriteFramesDistDir__ : string } ) . __rewriteFramesDistDir__ ;
54
+ const SOURCEMAP_FILENAME_REGEX = new RegExp ( escapeStringForRegex ( path . resolve ( process . cwd ( ) , distDir ) ) ) ;
55
+ // const distDirRegex = (global as typeof global & { __rewriteFramesRegex__: string }).__rewriteFramesRegex__;
56
+ // const SOURCEMAP_FILENAME_REGEX = new RegExp(escapeStringForRegex(distDirRegex));
54
57
55
- console . log ( 'distDirRegex:' , distDirRegex ) ;
58
+ // console.log('distDirRegex:', distDirRegex);
56
59
console . log ( 'cwd in addServerIntegrations' , process . cwd ( ) ) ;
57
60
58
61
const defaultRewriteFramesIntegration = new RewriteFrames ( {
59
62
iteratee : frame => {
63
+ if ( frame . filename ?. includes ( 'throw' ) ) {
64
+ debugger ;
65
+ }
60
66
frame . filename = frame . filename ?. replace ( SOURCEMAP_FILENAME_REGEX , 'app:///_next' ) ;
61
67
return frame ;
62
68
} ,
0 commit comments