Skip to content

Commit 6d03f84

Browse files
committed
use GLOBAL from utils
1 parent 0a86242 commit 6d03f84

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packages/sveltekit/src/server/utils.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import type { DynamicSamplingContext, StackFrame, TraceparentData } from '@sentry/types';
2+
import type { InternalGlobal } from '@sentry/utils';
23
import {
34
baggageHeaderToDynamicSamplingContext,
45
basename,
56
escapeStringForRegex,
67
extractTraceparentData,
8+
GLOBAL_OBJ,
9+
join,
710
} from '@sentry/utils';
811
import type { RequestEvent } from '@sveltejs/kit';
912

@@ -18,7 +21,7 @@ export type GlobalSentryValues = {
1821
* injected by the SvelteKit SDK at build time.
1922
* @see packages/sveltekit/src/vite/sourcemaps.ts
2023
*/
21-
export type GlobalWithSentryValues = typeof globalThis & GlobalSentryValues;
24+
export type GlobalWithSentryValues = InternalGlobal & GlobalSentryValues;
2225

2326
/**
2427
* Takes a request event and extracts traceparent and DSC data
@@ -51,7 +54,7 @@ export function rewriteFramesIteratee(frame: StackFrame): StackFrame {
5154
if (!frame.filename) {
5255
return frame;
5356
}
54-
const globalWithSentryValues: GlobalWithSentryValues = globalThis;
57+
const globalWithSentryValues: GlobalWithSentryValues = GLOBAL_OBJ;
5558
const svelteKitBuildOutDir = globalWithSentryValues.__sentry_sveltekit_output_dir;
5659
const prefix = 'app:///';
5760

@@ -67,7 +70,10 @@ export function rewriteFramesIteratee(frame: StackFrame): StackFrame {
6770

6871
let strippedFilename;
6972
if (svelteKitBuildOutDir) {
70-
strippedFilename = filename.replace(new RegExp(`^.*${escapeStringForRegex(svelteKitBuildOutDir)}/server/`), '');
73+
strippedFilename = filename.replace(
74+
new RegExp(`^.*${escapeStringForRegex(join(svelteKitBuildOutDir, 'server'))}`),
75+
'',
76+
);
7177
} else {
7278
strippedFilename = basename(filename);
7379
}

0 commit comments

Comments
 (0)