1
1
import type { DynamicSamplingContext , StackFrame , TraceparentData } from '@sentry/types' ;
2
+ import type { InternalGlobal } from '@sentry/utils' ;
2
3
import {
3
4
baggageHeaderToDynamicSamplingContext ,
4
5
basename ,
5
6
escapeStringForRegex ,
6
7
extractTraceparentData ,
8
+ GLOBAL_OBJ ,
9
+ join ,
7
10
} from '@sentry/utils' ;
8
11
import type { RequestEvent } from '@sveltejs/kit' ;
9
12
@@ -18,7 +21,7 @@ export type GlobalSentryValues = {
18
21
* injected by the SvelteKit SDK at build time.
19
22
* @see packages/sveltekit/src/vite/sourcemaps.ts
20
23
*/
21
- export type GlobalWithSentryValues = typeof globalThis & GlobalSentryValues ;
24
+ export type GlobalWithSentryValues = InternalGlobal & GlobalSentryValues ;
22
25
23
26
/**
24
27
* Takes a request event and extracts traceparent and DSC data
@@ -51,7 +54,7 @@ export function rewriteFramesIteratee(frame: StackFrame): StackFrame {
51
54
if ( ! frame . filename ) {
52
55
return frame ;
53
56
}
54
- const globalWithSentryValues : GlobalWithSentryValues = globalThis ;
57
+ const globalWithSentryValues : GlobalWithSentryValues = GLOBAL_OBJ ;
55
58
const svelteKitBuildOutDir = globalWithSentryValues . __sentry_sveltekit_output_dir ;
56
59
const prefix = 'app:///' ;
57
60
@@ -67,7 +70,10 @@ export function rewriteFramesIteratee(frame: StackFrame): StackFrame {
67
70
68
71
let strippedFilename ;
69
72
if ( svelteKitBuildOutDir ) {
70
- strippedFilename = filename . replace ( new RegExp ( `^.*${ escapeStringForRegex ( svelteKitBuildOutDir ) } /server/` ) , '' ) ;
73
+ strippedFilename = filename . replace (
74
+ new RegExp ( `^.*${ escapeStringForRegex ( join ( svelteKitBuildOutDir , 'server' ) ) } ` ) ,
75
+ '' ,
76
+ ) ;
71
77
} else {
72
78
strippedFilename = basename ( filename ) ;
73
79
}
0 commit comments