diff --git a/dev-packages/e2e-tests/test-applications/nextjs-turbo/next-env.d.ts b/dev-packages/e2e-tests/test-applications/nextjs-turbo/next-env.d.ts index 725dd6f24515..3cd7048ed947 100644 --- a/dev-packages/e2e-tests/test-applications/nextjs-turbo/next-env.d.ts +++ b/dev-packages/e2e-tests/test-applications/nextjs-turbo/next-env.d.ts @@ -3,4 +3,4 @@ /// // NOTE: This file should not be edited -// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information. +// see https://nextjs.org/docs/app/api-reference/config/typescript for more information. diff --git a/dev-packages/e2e-tests/test-applications/nextjs-turbo/package.json b/dev-packages/e2e-tests/test-applications/nextjs-turbo/package.json index 243c719da4c2..94e762a859a9 100644 --- a/dev-packages/e2e-tests/test-applications/nextjs-turbo/package.json +++ b/dev-packages/e2e-tests/test-applications/nextjs-turbo/package.json @@ -17,7 +17,7 @@ "@types/node": "^18.19.1", "@types/react": "18.0.26", "@types/react-dom": "18.0.9", - "next": "15.3.0-canary.8", + "next": "15.3.0-canary.26", "react": "rc", "react-dom": "rc", "typescript": "~5.0.0" diff --git a/packages/nextjs/src/client/index.ts b/packages/nextjs/src/client/index.ts index 9b1d58610e0d..031f5a412a37 100644 --- a/packages/nextjs/src/client/index.ts +++ b/packages/nextjs/src/client/index.ts @@ -1,4 +1,5 @@ import type { Client, EventProcessor, Integration } from '@sentry/core'; +import { getGlobalScope } from '@sentry/core'; import { GLOBAL_OBJ, addEventProcessor, applySdkMetadata } from '@sentry/core'; import type { BrowserOptions } from '@sentry/react'; import { getDefaultIntegrations as getReactDefaultIntegrations, init as reactInit } from '@sentry/react'; @@ -61,6 +62,16 @@ export function init(options: BrowserOptions): Client | undefined { addEventProcessor(devErrorSymbolicationEventProcessor); } + try { + // @ts-expect-error `process.turbopack` is a magic string that will be replaced by Next.js + if (process.turbopack) { + getGlobalScope().setTag('turbopack', true); + } + } catch (e) { + // Noop + // The statement above can throw because process is not defined on the client + } + return client; } diff --git a/packages/nextjs/src/edge/index.ts b/packages/nextjs/src/edge/index.ts index 77469cfdf9dc..8b21abd18917 100644 --- a/packages/nextjs/src/edge/index.ts +++ b/packages/nextjs/src/edge/index.ts @@ -4,6 +4,7 @@ import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, applySdkMetadata, + getGlobalScope, getRootSpan, registerSpanErrorInstrumentation, spanToJSON, @@ -90,6 +91,16 @@ export function init(options: VercelEdgeOptions = {}): void { vercelWaitUntil(flushSafelyWithTimeout()); } }); + + try { + // @ts-expect-error `process.turbopack` is a magic string that will be replaced by Next.js + if (process.turbopack) { + getGlobalScope().setTag('turbopack', true); + } + } catch { + // Noop + // The statement above can throw because process is not defined on the client + } } /** diff --git a/packages/nextjs/src/server/index.ts b/packages/nextjs/src/server/index.ts index bc5cbb50893d..5edd62d15bdd 100644 --- a/packages/nextjs/src/server/index.ts +++ b/packages/nextjs/src/server/index.ts @@ -357,6 +357,16 @@ export function init(options: NodeOptions): NodeClient | undefined { getGlobalScope().addEventProcessor(devErrorSymbolicationEventProcessor); } + try { + // @ts-expect-error `process.turbopack` is a magic string that will be replaced by Next.js + if (process.turbopack) { + getGlobalScope().setTag('turbopack', true); + } + } catch { + // Noop + // The statement above can throw because process is not defined on the client + } + DEBUG_BUILD && logger.log('SDK successfully initialized'); return client;