@@ -390,57 +390,56 @@ export async function instrumentForPerformance(appInstance: ApplicationInstance)
390
390
391
391
const idleTimeout = config . transitionTimeout || 5000 ;
392
392
393
- const existingIntegrations = ( sentryConfig [ 'integrations' ] || [ ] ) as Integration [ ] ;
394
-
395
- sentryConfig [ 'integrations' ] = [
396
- ...existingIntegrations ,
397
- new BrowserTracing ( {
398
- routingInstrumentation : ( customStartTransaction , startTransactionOnPageLoad ) => {
399
- const routerMain = appInstance . lookup ( 'router:main' ) ;
400
- let routerService = appInstance . lookup ( 'service:router' ) as
401
- | RouterService & { externalRouter ?: RouterService ; _hasMountedSentryPerformanceRouting ?: boolean } ;
402
-
403
- if ( routerService . externalRouter ) {
404
- // Using ember-engines-router-service in an engine.
405
- routerService = routerService . externalRouter ;
406
- }
407
- if ( routerService . _hasMountedSentryPerformanceRouting ) {
408
- // Routing listens to route changes on the main router, and should not be initialized multiple times per page.
409
- return ;
410
- }
411
- if ( ! routerService . recognize ) {
412
- // Router is missing critical functionality to limit cardinality of the transaction names.
413
- return ;
414
- }
415
- routerService . _hasMountedSentryPerformanceRouting = true ;
416
- _instrumentEmberRouter ( routerService , routerMain , config , customStartTransaction , startTransactionOnPageLoad ) ;
417
- } ,
418
- idleTimeout,
419
- ...browserTracingOptions ,
420
- } ) ,
421
- ] ;
422
-
423
- class FakeBrowserTracingClass {
424
- static id = 'BrowserTracing' ;
425
- public name = FakeBrowserTracingClass . id ;
426
- setupOnce ( ) {
427
- // noop - We're just faking this class for a lookup
393
+ const browserTracing = new BrowserTracing ( {
394
+ routingInstrumentation : ( customStartTransaction , startTransactionOnPageLoad ) => {
395
+ const routerMain = appInstance . lookup ( 'router:main' ) ;
396
+ let routerService = appInstance . lookup ( 'service:router' ) as
397
+ | RouterService & { externalRouter ?: RouterService ; _hasMountedSentryPerformanceRouting ?: boolean } ;
398
+
399
+ if ( routerService . externalRouter ) {
400
+ // Using ember-engines-router-service in an engine.
401
+ routerService = routerService . externalRouter ;
402
+ }
403
+ if ( routerService . _hasMountedSentryPerformanceRouting ) {
404
+ // Routing listens to route changes on the main router, and should not be initialized multiple times per page.
405
+ return ;
406
+ }
407
+ if ( ! routerService . recognize ) {
408
+ // Router is missing critical functionality to limit cardinality of the transaction names.
409
+ return ;
410
+ }
411
+ routerService . _hasMountedSentryPerformanceRouting = true ;
412
+ _instrumentEmberRouter ( routerService , routerMain , config , customStartTransaction , startTransactionOnPageLoad ) ;
413
+ } ,
414
+ idleTimeout,
415
+ ...browserTracingOptions ,
416
+ } ) ;
417
+
418
+ if ( macroCondition ( isTesting ( ) ) ) {
419
+ class FakeBrowserTracingClass {
420
+ static id = 'BrowserTracing' ;
421
+ public name = FakeBrowserTracingClass . id ;
422
+ setupOnce ( ) {
423
+ // noop - We're just faking this class for a lookup
424
+ }
428
425
}
429
- }
430
426
431
- if (
432
- isTesting ( ) &&
433
- Sentry . getCurrentHub ( ) ?. getIntegration (
434
- // This is a temporary hack because the BrowserTracing integration cannot have a static `id` field for tree
435
- // shaking reasons. However, `getIntegration` needs that field.
436
- FakeBrowserTracingClass ,
437
- )
438
- ) {
439
- // Initializers are called more than once in tests, causing the integrations to not be setup correctly.
440
- return ;
427
+ if (
428
+ Sentry . getCurrentHub ( ) ?. getIntegration (
429
+ // This is a temporary hack because the BrowserTracing integration cannot have a static `id` field for tree
430
+ // shaking reasons. However, `getIntegration` needs that field.
431
+ FakeBrowserTracingClass ,
432
+ )
433
+ ) {
434
+ // Initializers are called more than once in tests, causing the integrations to not be setup correctly.
435
+ return ;
436
+ }
441
437
}
442
438
443
- Sentry . init ( sentryConfig ) ; // Call init again to rebind client with new integration list in addition to the defaults
439
+ const client = Sentry . getCurrentHub ( ) . getClient ( ) ;
440
+ if ( client && client . addIntegration ) {
441
+ client . addIntegration ( browserTracing ) ;
442
+ }
444
443
445
444
_instrumentEmberRunloop ( config ) ;
446
445
_instrumentComponents ( config ) ;
0 commit comments