File tree Expand file tree Collapse file tree 4 files changed +21
-7
lines changed
Expand file tree Collapse file tree 4 files changed +21
-7
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ const globalWithInjectedValues = GLOBAL_OBJ as typeof GLOBAL_OBJ & {
4343 _sentryBasePath ?: string ;
4444 _sentryRelease ?: string ;
4545 _experimentalThirdPartyOriginStackFrames ?: string ;
46+ _sentrySpotlight ?: string ;
4647} ;
4748
4849// Treeshakable guard to remove all code related to tracing
@@ -143,9 +144,10 @@ function getDefaultIntegrations(options: BrowserOptions): Integration[] {
143144 ) ;
144145
145146 // Auto-enable Spotlight from NEXT_PUBLIC_SENTRY_SPOTLIGHT env var
146- // The value is injected at build time via DefinePlugin in webpack.ts
147- // We use DefinePlugin because Next.js doesn't replace process.env.* in node_modules code
148- const spotlightEnvValue = process . env . _sentrySpotlight ;
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+ const spotlightEnvValue = process . env . _sentrySpotlight || globalWithInjectedValues . _sentrySpotlight ;
149151 if ( spotlightEnvValue !== undefined && options . spotlight === undefined ) {
150152 const boolValue = envToBool ( spotlightEnvValue , { strict : true } ) ;
151153 const spotlightConfig = boolValue !== null ? boolValue : spotlightEnvValue ;
Original file line number Diff line number Diff line change @@ -18,11 +18,13 @@ export function constructTurbopackConfig({
1818 userSentryOptions,
1919 routeManifest,
2020 nextJsVersion,
21+ spotlightConfig,
2122} : {
2223 userNextConfig : NextConfigObject ;
2324 userSentryOptions ?: SentryBuildOptions ;
2425 routeManifest ?: RouteManifest ;
2526 nextJsVersion ?: string ;
27+ spotlightConfig ?: string ;
2628} ) : TurbopackOptions {
2729 // If sourcemaps are disabled, we don't need to enable native debug ids as this will add build time.
2830 const shouldEnableNativeDebugIds =
@@ -45,6 +47,7 @@ export function constructTurbopackConfig({
4547 routeManifest,
4648 nextJsVersion,
4749 tunnelPath,
50+ spotlightConfig,
4851 } ) ;
4952
5053 for ( const { matcher, rule } of valueInjectionRules ) {
Original file line number Diff line number Diff line change @@ -9,10 +9,12 @@ export function generateValueInjectionRules({
99 routeManifest,
1010 nextJsVersion,
1111 tunnelPath,
12+ spotlightConfig,
1213} : {
1314 routeManifest ?: RouteManifest ;
1415 nextJsVersion ?: string ;
1516 tunnelPath ?: string ;
17+ spotlightConfig ?: string ;
1618} ) : TurbopackMatcherWithRule [ ] {
1719 const rules : TurbopackMatcherWithRule [ ] = [ ] ;
1820 const isomorphicValues : Record < string , JSONValue > = { } ;
@@ -33,6 +35,11 @@ export function generateValueInjectionRules({
3335 isomorphicValues . _sentryRewritesTunnelPath = tunnelPath ;
3436 }
3537
38+ // Inject Spotlight config for client (Spotlight is a client-side feature)
39+ if ( spotlightConfig ) {
40+ clientValues . _sentrySpotlight = spotlightConfig ;
41+ }
42+
3643 if ( Object . keys ( isomorphicValues ) . length > 0 ) {
3744 clientValues = { ...clientValues , ...isomorphicValues } ;
3845 serverValues = { ...serverValues , ...isomorphicValues } ;
Original file line number Diff line number Diff line change @@ -351,6 +351,10 @@ function getFinalConfigObject(
351351 ) ;
352352 }
353353
354+ // Calculate spotlight config once for both webpack and turbopack
355+ const spotlightConfig =
356+ incomingUserNextConfigObject . env ?. NEXT_PUBLIC_SENTRY_SPOTLIGHT ?? process . env . NEXT_PUBLIC_SENTRY_SPOTLIGHT ;
357+
354358 let turboPackConfig : TurbopackOptions | undefined ;
355359
356360 if ( isTurbopack ) {
@@ -359,6 +363,7 @@ function getFinalConfigObject(
359363 userSentryOptions,
360364 routeManifest,
361365 nextJsVersion,
366+ spotlightConfig,
362367 } ) ;
363368 }
364369
@@ -462,10 +467,7 @@ function getFinalConfigObject(
462467 routeManifest,
463468 nextJsVersion,
464469 useRunAfterProductionCompileHook : shouldUseRunAfterProductionCompileHook ,
465- // Spotlight config from NEXT_PUBLIC_SENTRY_SPOTLIGHT env var
466- spotlightConfig :
467- incomingUserNextConfigObject . env ?. NEXT_PUBLIC_SENTRY_SPOTLIGHT ??
468- process . env . NEXT_PUBLIC_SENTRY_SPOTLIGHT ,
470+ spotlightConfig,
469471 } ) ,
470472 }
471473 : { } ) ,
You can’t perform that action at this time.
0 commit comments