@@ -6,20 +6,21 @@ import type RouterService from '@ember/routing/router-service';
66import { _backburner , run , scheduleOnce } from '@ember/runloop' ;
77import type { EmberRunQueues } from '@ember/runloop/-private/types' ;
88import { 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' ;
1414import {
1515 SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ,
1616 SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ,
1717 getActiveSpan ,
1818 getClient ,
19- startBrowserTracingNavigationSpan ,
20- startBrowserTracingPageLoadSpan ,
2119 startInactiveSpan ,
2220} 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' ;
2324import type { EmberRouterMain , EmberSentryConfig , GlobalConfig , OwnConfig } from '../types' ;
2425
2526function getSentryConfig ( ) : EmberSentryConfig {
@@ -99,6 +100,8 @@ export function _instrumentEmberRouter(
99100 routerService : RouterService ,
100101 routerMain : EmberRouterMain ,
101102 config : EmberSentryConfig ,
103+ startBrowserTracingPageLoadSpan : typeof startBrowserTracingPageLoadSpanType ,
104+ startBrowserTracingNavigationSpan : typeof startBrowserTracingNavigationSpanType ,
102105) : void {
103106 const { disableRunloopPerformance } = config ;
104107 const location = routerMain . location ;
@@ -424,7 +427,8 @@ export async function instrumentForPerformance(appInstance: ApplicationInstance)
424427 // Maintaining backwards compatibility with config.browserTracingOptions, but passing it with Sentry options is preferred.
425428 const browserTracingOptions = config . browserTracingOptions || config . sentry . browserTracingOptions || { } ;
426429
427- const { browserTracingIntegration } = await import ( '@sentry/browser' ) ;
430+ const { browserTracingIntegration, startBrowserTracingNavigationSpan, startBrowserTracingPageLoadSpan } =
431+ await import ( '@sentry/browser' ) ;
428432
429433 const idleTimeout = config . transitionTimeout || 5000 ;
430434
@@ -444,7 +448,7 @@ export async function instrumentForPerformance(appInstance: ApplicationInstance)
444448 }
445449
446450 // We _always_ call this, as it triggers the page load & navigation spans
447- _instrumentNavigation ( appInstance , config ) ;
451+ _instrumentNavigation ( appInstance , config , startBrowserTracingPageLoadSpan , startBrowserTracingNavigationSpan ) ;
448452
449453 // Skip instrumenting the stuff below again in tests, as these are not reset between tests
450454 if ( isAlreadyInitialized ) {
@@ -456,7 +460,12 @@ export async function instrumentForPerformance(appInstance: ApplicationInstance)
456460 _instrumentInitialLoad ( config ) ;
457461}
458462
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 {
460469 // eslint-disable-next-line ember/no-private-routing-service
461470 const routerMain = appInstance . lookup ( 'router:main' ) as EmberRouterMain ;
462471 let routerService = appInstance . lookup ( 'service:router' ) as RouterService & {
@@ -478,7 +487,13 @@ function _instrumentNavigation(appInstance: ApplicationInstance, config: EmberSe
478487 }
479488
480489 routerService . _hasMountedSentryPerformanceRouting = true ;
481- _instrumentEmberRouter ( routerService , routerMain , config ) ;
490+ _instrumentEmberRouter (
491+ routerService ,
492+ routerMain ,
493+ config ,
494+ startBrowserTracingPageLoadSpan ,
495+ startBrowserTracingNavigationSpan ,
496+ ) ;
482497}
483498
484499export default {
0 commit comments