@@ -6,20 +6,21 @@ import type RouterService from '@ember/routing/router-service';
6
6
import { _backburner , run , scheduleOnce } from '@ember/runloop' ;
7
7
import type { EmberRunQueues } from '@ember/runloop/-private/types' ;
8
8
import { getOwnConfig , isTesting , macroCondition } from '@embroider/macros' ;
9
- import type { ExtendedBackburner } from '@sentry/ember/runloop' ;
10
- import type { Span } from '@sentry/types' ;
11
- import { GLOBAL_OBJ , browserPerformanceTimeOrigin , timestampInSeconds } from '@sentry/utils' ;
12
-
13
- import type { BrowserClient } from '@sentry/browser' ;
9
+ import type {
10
+ BrowserClient ,
11
+ startBrowserTracingNavigationSpan as startBrowserTracingNavigationSpanType ,
12
+ startBrowserTracingPageLoadSpan as startBrowserTracingPageLoadSpanType ,
13
+ } from '@sentry/browser' ;
14
14
import {
15
15
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ,
16
16
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ,
17
17
getActiveSpan ,
18
18
getClient ,
19
- startBrowserTracingNavigationSpan ,
20
- startBrowserTracingPageLoadSpan ,
21
19
startInactiveSpan ,
22
20
} from '@sentry/browser' ;
21
+ import type { ExtendedBackburner } from '@sentry/ember/runloop' ;
22
+ import type { Span } from '@sentry/types' ;
23
+ import { GLOBAL_OBJ , browserPerformanceTimeOrigin , timestampInSeconds } from '@sentry/utils' ;
23
24
import type { EmberRouterMain , EmberSentryConfig , GlobalConfig , OwnConfig } from '../types' ;
24
25
25
26
function getSentryConfig ( ) : EmberSentryConfig {
@@ -99,6 +100,8 @@ export function _instrumentEmberRouter(
99
100
routerService : RouterService ,
100
101
routerMain : EmberRouterMain ,
101
102
config : EmberSentryConfig ,
103
+ startBrowserTracingPageLoadSpan : typeof startBrowserTracingPageLoadSpanType ,
104
+ startBrowserTracingNavigationSpan : typeof startBrowserTracingNavigationSpanType ,
102
105
) : void {
103
106
const { disableRunloopPerformance } = config ;
104
107
const location = routerMain . location ;
@@ -424,7 +427,8 @@ export async function instrumentForPerformance(appInstance: ApplicationInstance)
424
427
// Maintaining backwards compatibility with config.browserTracingOptions, but passing it with Sentry options is preferred.
425
428
const browserTracingOptions = config . browserTracingOptions || config . sentry . browserTracingOptions || { } ;
426
429
427
- const { browserTracingIntegration } = await import ( '@sentry/browser' ) ;
430
+ const { browserTracingIntegration, startBrowserTracingNavigationSpan, startBrowserTracingPageLoadSpan } =
431
+ await import ( '@sentry/browser' ) ;
428
432
429
433
const idleTimeout = config . transitionTimeout || 5000 ;
430
434
@@ -444,7 +448,7 @@ export async function instrumentForPerformance(appInstance: ApplicationInstance)
444
448
}
445
449
446
450
// We _always_ call this, as it triggers the page load & navigation spans
447
- _instrumentNavigation ( appInstance , config ) ;
451
+ _instrumentNavigation ( appInstance , config , startBrowserTracingPageLoadSpan , startBrowserTracingNavigationSpan ) ;
448
452
449
453
// Skip instrumenting the stuff below again in tests, as these are not reset between tests
450
454
if ( isAlreadyInitialized ) {
@@ -456,7 +460,12 @@ export async function instrumentForPerformance(appInstance: ApplicationInstance)
456
460
_instrumentInitialLoad ( config ) ;
457
461
}
458
462
459
- function _instrumentNavigation ( appInstance : ApplicationInstance , config : EmberSentryConfig ) : void {
463
+ function _instrumentNavigation (
464
+ appInstance : ApplicationInstance ,
465
+ config : EmberSentryConfig ,
466
+ startBrowserTracingPageLoadSpan : typeof startBrowserTracingPageLoadSpanType ,
467
+ startBrowserTracingNavigationSpan : typeof startBrowserTracingNavigationSpanType ,
468
+ ) : void {
460
469
// eslint-disable-next-line ember/no-private-routing-service
461
470
const routerMain = appInstance . lookup ( 'router:main' ) as EmberRouterMain ;
462
471
let routerService = appInstance . lookup ( 'service:router' ) as RouterService & {
@@ -478,7 +487,13 @@ function _instrumentNavigation(appInstance: ApplicationInstance, config: EmberSe
478
487
}
479
488
480
489
routerService . _hasMountedSentryPerformanceRouting = true ;
481
- _instrumentEmberRouter ( routerService , routerMain , config ) ;
490
+ _instrumentEmberRouter (
491
+ routerService ,
492
+ routerMain ,
493
+ config ,
494
+ startBrowserTracingPageLoadSpan ,
495
+ startBrowserTracingNavigationSpan ,
496
+ ) ;
482
497
}
483
498
484
499
export default {
0 commit comments