Skip to content

Commit 305df9f

Browse files
authored
feat(nextjs): Record turbopack as tag (#15928)
1 parent 9a1970b commit 305df9f

File tree

5 files changed

+34
-2
lines changed

5 files changed

+34
-2
lines changed

dev-packages/e2e-tests/test-applications/nextjs-turbo/next-env.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
/// <reference types="next/navigation-types/compat/navigation" />
44

55
// NOTE: This file should not be edited
6-
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
6+
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

dev-packages/e2e-tests/test-applications/nextjs-turbo/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"@types/node": "^18.19.1",
1818
"@types/react": "18.0.26",
1919
"@types/react-dom": "18.0.9",
20-
"next": "15.3.0-canary.8",
20+
"next": "15.3.0-canary.26",
2121
"react": "rc",
2222
"react-dom": "rc",
2323
"typescript": "~5.0.0"

packages/nextjs/src/client/index.ts

+11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Client, EventProcessor, Integration } from '@sentry/core';
2+
import { getGlobalScope } from '@sentry/core';
23
import { GLOBAL_OBJ, addEventProcessor, applySdkMetadata } from '@sentry/core';
34
import type { BrowserOptions } from '@sentry/react';
45
import { getDefaultIntegrations as getReactDefaultIntegrations, init as reactInit } from '@sentry/react';
@@ -61,6 +62,16 @@ export function init(options: BrowserOptions): Client | undefined {
6162
addEventProcessor(devErrorSymbolicationEventProcessor);
6263
}
6364

65+
try {
66+
// @ts-expect-error `process.turbopack` is a magic string that will be replaced by Next.js
67+
if (process.turbopack) {
68+
getGlobalScope().setTag('turbopack', true);
69+
}
70+
} catch (e) {
71+
// Noop
72+
// The statement above can throw because process is not defined on the client
73+
}
74+
6475
return client;
6576
}
6677

packages/nextjs/src/edge/index.ts

+11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
55
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
66
applySdkMetadata,
7+
getGlobalScope,
78
getRootSpan,
89
registerSpanErrorInstrumentation,
910
spanToJSON,
@@ -90,6 +91,16 @@ export function init(options: VercelEdgeOptions = {}): void {
9091
vercelWaitUntil(flushSafelyWithTimeout());
9192
}
9293
});
94+
95+
try {
96+
// @ts-expect-error `process.turbopack` is a magic string that will be replaced by Next.js
97+
if (process.turbopack) {
98+
getGlobalScope().setTag('turbopack', true);
99+
}
100+
} catch {
101+
// Noop
102+
// The statement above can throw because process is not defined on the client
103+
}
93104
}
94105

95106
/**

packages/nextjs/src/server/index.ts

+10
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,16 @@ export function init(options: NodeOptions): NodeClient | undefined {
357357
getGlobalScope().addEventProcessor(devErrorSymbolicationEventProcessor);
358358
}
359359

360+
try {
361+
// @ts-expect-error `process.turbopack` is a magic string that will be replaced by Next.js
362+
if (process.turbopack) {
363+
getGlobalScope().setTag('turbopack', true);
364+
}
365+
} catch {
366+
// Noop
367+
// The statement above can throw because process is not defined on the client
368+
}
369+
360370
DEBUG_BUILD && logger.log('SDK successfully initialized');
361371

362372
return client;

0 commit comments

Comments
 (0)