22// can be removed once following issue is fixed: https://github.com/import-js/eslint-plugin-import/issues/703
33/* eslint-disable import/export */
44import type { Client , EventProcessor , Integration } from '@sentry/core' ;
5- import {
6- addEventProcessor ,
7- applySdkMetadata ,
8- consoleSandbox ,
9- envToBool ,
10- getGlobalScope ,
11- GLOBAL_OBJ ,
12- resolveSpotlightOptions ,
13- } from '@sentry/core' ;
5+ import { addEventProcessor , applySdkMetadata , consoleSandbox , getGlobalScope , GLOBAL_OBJ } from '@sentry/core' ;
146import type { BrowserOptions } from '@sentry/react' ;
15- import {
16- getDefaultIntegrations as getReactDefaultIntegrations ,
17- init as reactInit ,
18- spotlightBrowserIntegration ,
19- } from '@sentry/react' ;
7+ import { getDefaultIntegrations as getReactDefaultIntegrations , init as reactInit } from '@sentry/react' ;
208import { devErrorSymbolicationEventProcessor } from '../common/devErrorSymbolicationEventProcessor' ;
219import { getVercelEnv } from '../common/getVercelEnv' ;
2210import { isRedirectNavigationError } from '../common/nextNavigationErrorUtils' ;
@@ -43,7 +31,6 @@ const globalWithInjectedValues = GLOBAL_OBJ as typeof GLOBAL_OBJ & {
4331 _sentryBasePath ?: string ;
4432 _sentryRelease ?: string ;
4533 _experimentalThirdPartyOriginStackFrames ?: string ;
46- _sentrySpotlight ?: string ;
4734} ;
4835
4936// Treeshakable guard to remove all code related to tracing
@@ -143,39 +130,11 @@ function getDefaultIntegrations(options: BrowserOptions): Integration[] {
143130 } ) ,
144131 ) ;
145132
146- // Auto-enable Spotlight from NEXT_PUBLIC_SENTRY_SPOTLIGHT env var
147- // The value is injected at build time:
148- // - Webpack: via DefinePlugin which replaces process.env._sentrySpotlight
149- // - Turbopack: via valueInjectionLoader which sets globalThis._sentrySpotlight
150- // - Manual: user can set window._sentrySpotlight in instrumentation-client.ts
151- const processEnvSpotlight = process . env . _sentrySpotlight ;
152- const globalSpotlight = globalWithInjectedValues . _sentrySpotlight ;
153-
154- // Check window directly for manual setting (most reliable in browser)
155- // This is set in instrumentation-client.ts before Sentry.init()
156- const windowObj = typeof window !== 'undefined' ? window : undefined ;
157- const windowSpotlight = windowObj ? ( windowObj as unknown as Record < string , unknown > ) . _sentrySpotlight : undefined ;
158-
159- // Convert window value to string if it's a boolean or other type
160- const windowSpotlightStr =
161- typeof windowSpotlight === 'string'
162- ? windowSpotlight
163- : typeof windowSpotlight === 'boolean'
164- ? String ( windowSpotlight )
165- : undefined ;
166-
167- const spotlightEnvValue : string | undefined = processEnvSpotlight || globalSpotlight || windowSpotlightStr ;
168-
169- if ( spotlightEnvValue !== undefined && options . spotlight === undefined ) {
170- const boolValue = envToBool ( spotlightEnvValue , { strict : true } ) ;
171- const spotlightConfig = boolValue !== null ? boolValue : spotlightEnvValue ;
172- const spotlightValue = resolveSpotlightOptions ( undefined , spotlightConfig ) ;
173-
174- if ( spotlightValue ) {
175- const spotlightArgs = typeof spotlightValue === 'string' ? { sidecarUrl : spotlightValue } : undefined ;
176- customDefaultIntegrations . push ( spotlightBrowserIntegration ( spotlightArgs ) ) ;
177- }
178- }
133+ // Note: Spotlight auto-enablement from NEXT_PUBLIC_SENTRY_SPOTLIGHT is handled by the
134+ // browser SDK's init() function. The Next.js build config injects the env var value via:
135+ // - Webpack: DefinePlugin replaces process.env.NEXT_PUBLIC_SENTRY_SPOTLIGHT
136+ // - Turbopack: valueInjectionLoader sets globalThis.NEXT_PUBLIC_SENTRY_SPOTLIGHT
137+ // The browser SDK's getEnvValue() checks both sources.
179138
180139 return customDefaultIntegrations ;
181140}
0 commit comments