@@ -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 ;
@@ -411,7 +414,8 @@ export async function instrumentForPerformance(appInstance: ApplicationInstance)
411
414
// Maintaining backwards compatibility with config.browserTracingOptions, but passing it with Sentry options is preferred.
412
415
const browserTracingOptions = config . browserTracingOptions || config . sentry . browserTracingOptions || { } ;
413
416
414
- const { browserTracingIntegration } = await import ( '@sentry/browser' ) ;
417
+ const { browserTracingIntegration, startBrowserTracingNavigationSpan, startBrowserTracingPageLoadSpan } =
418
+ await import ( '@sentry/browser' ) ;
415
419
416
420
const idleTimeout = config . transitionTimeout || 5000 ;
417
421
@@ -431,7 +435,7 @@ export async function instrumentForPerformance(appInstance: ApplicationInstance)
431
435
}
432
436
433
437
// We _always_ call this, as it triggers the page load & navigation spans
434
- _instrumentNavigation ( appInstance , config ) ;
438
+ _instrumentNavigation ( appInstance , config , startBrowserTracingPageLoadSpan , startBrowserTracingNavigationSpan ) ;
435
439
436
440
// Skip instrumenting the stuff below again in tests, as these are not reset between tests
437
441
if ( isAlreadyInitialized ) {
@@ -443,7 +447,12 @@ export async function instrumentForPerformance(appInstance: ApplicationInstance)
443
447
_instrumentInitialLoad ( config ) ;
444
448
}
445
449
446
- function _instrumentNavigation ( appInstance : ApplicationInstance , config : EmberSentryConfig ) : void {
450
+ function _instrumentNavigation (
451
+ appInstance : ApplicationInstance ,
452
+ config : EmberSentryConfig ,
453
+ startBrowserTracingPageLoadSpan : typeof startBrowserTracingPageLoadSpanType ,
454
+ startBrowserTracingNavigationSpan : typeof startBrowserTracingNavigationSpanType ,
455
+ ) : void {
447
456
// eslint-disable-next-line ember/no-private-routing-service
448
457
const routerMain = appInstance . lookup ( 'router:main' ) as EmberRouterMain ;
449
458
let routerService = appInstance . lookup ( 'service:router' ) as RouterService & {
@@ -465,7 +474,13 @@ function _instrumentNavigation(appInstance: ApplicationInstance, config: EmberSe
465
474
}
466
475
467
476
routerService . _hasMountedSentryPerformanceRouting = true ;
468
- _instrumentEmberRouter ( routerService , routerMain , config ) ;
477
+ _instrumentEmberRouter (
478
+ routerService ,
479
+ routerMain ,
480
+ config ,
481
+ startBrowserTracingPageLoadSpan ,
482
+ startBrowserTracingNavigationSpan ,
483
+ ) ;
469
484
}
470
485
471
486
export default {
0 commit comments