@@ -17,7 +17,7 @@ import {
1717 setOpenTelemetryContextAsyncContextStrategy ,
1818 setupEventContextTrace ,
1919} from '@sentry/opentelemetry' ;
20- import type { Client , Integration , Options } from '@sentry/types' ;
20+ import type { Integration , Options } from '@sentry/types' ;
2121import {
2222 consoleSandbox ,
2323 dropUndefinedKeys ,
@@ -36,7 +36,7 @@ import { modulesIntegration } from '../integrations/modules';
3636import { nativeNodeFetchIntegration } from '../integrations/node-fetch' ;
3737import { onUncaughtExceptionIntegration } from '../integrations/onuncaughtexception' ;
3838import { onUnhandledRejectionIntegration } from '../integrations/onunhandledrejection' ;
39- import { spotlightIntegration } from '../integrations/spotlight' ;
39+ import { INTEGRATION_NAME as SPOTLIGHT_INTEGRATION_NAME , spotlightIntegration } from '../integrations/spotlight' ;
4040import { getAutoPerformanceIntegrations } from '../integrations/tracing' ;
4141import { makeNodeTransport } from '../transports' ;
4242import type { NodeClientOptions , NodeOptions } from '../types' ;
@@ -140,13 +140,19 @@ function _init(
140140 const scope = getCurrentScope ( ) ;
141141 scope . update ( options . initialScope ) ;
142142
143+ if ( options . spotlight && ! options . integrations . some ( ( { name } ) => name === SPOTLIGHT_INTEGRATION_NAME ) ) {
144+ options . integrations . push (
145+ spotlightIntegration ( {
146+ sidecarUrl : typeof options . spotlight === 'string' ? options . spotlight : undefined ,
147+ } ) ,
148+ ) ;
149+ }
150+
143151 const client = new NodeClient ( options ) ;
144152 // The client is on the current scope, from where it generally is inherited
145153 getCurrentScope ( ) . setClient ( client ) ;
146154
147- if ( isEnabled ( client ) ) {
148- client . init ( ) ;
149- }
155+ client . init ( ) ;
150156
151157 logger . log ( `Running in ${ isCjs ( ) ? 'CommonJS' : 'ESM' } mode.` ) ;
152158
@@ -158,20 +164,6 @@ function _init(
158164
159165 updateScopeFromEnvVariables ( ) ;
160166
161- if ( options . spotlight ) {
162- // force integrations to be setup even if no DSN was set
163- // If they have already been added before, they will be ignored anyhow
164- const integrations = client . getOptions ( ) . integrations ;
165- for ( const integration of integrations ) {
166- client . addIntegration ( integration ) ;
167- }
168- client . addIntegration (
169- spotlightIntegration ( {
170- sidecarUrl : typeof options . spotlight === 'string' ? options . spotlight : undefined ,
171- } ) ,
172- ) ;
173- }
174-
175167 // If users opt-out of this, they _have_ to set up OpenTelemetry themselves
176168 // There is no way to use this SDK without OpenTelemetry!
177169 if ( ! options . skipOpenTelemetrySetup ) {
@@ -336,7 +328,3 @@ function startSessionTracking(): void {
336328 }
337329 } ) ;
338330}
339-
340- function isEnabled ( client : Client ) : boolean {
341- return client . getOptions ( ) . enabled !== false && client . getTransport ( ) !== undefined ;
342- }
0 commit comments