@@ -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 ;
@@ -411,7 +414,8 @@ export async function instrumentForPerformance(appInstance: ApplicationInstance)
411414 // Maintaining backwards compatibility with config.browserTracingOptions, but passing it with Sentry options is preferred.
412415 const browserTracingOptions = config . browserTracingOptions || config . sentry . browserTracingOptions || { } ;
413416
414- const { browserTracingIntegration } = await import ( '@sentry/browser' ) ;
417+ const { browserTracingIntegration, startBrowserTracingNavigationSpan, startBrowserTracingPageLoadSpan } =
418+ await import ( '@sentry/browser' ) ;
415419
416420 const idleTimeout = config . transitionTimeout || 5000 ;
417421
@@ -431,7 +435,7 @@ export async function instrumentForPerformance(appInstance: ApplicationInstance)
431435 }
432436
433437 // We _always_ call this, as it triggers the page load & navigation spans
434- _instrumentNavigation ( appInstance , config ) ;
438+ _instrumentNavigation ( appInstance , config , startBrowserTracingPageLoadSpan , startBrowserTracingNavigationSpan ) ;
435439
436440 // Skip instrumenting the stuff below again in tests, as these are not reset between tests
437441 if ( isAlreadyInitialized ) {
@@ -443,7 +447,12 @@ export async function instrumentForPerformance(appInstance: ApplicationInstance)
443447 _instrumentInitialLoad ( config ) ;
444448}
445449
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 {
447456 // eslint-disable-next-line ember/no-private-routing-service
448457 const routerMain = appInstance . lookup ( 'router:main' ) as EmberRouterMain ;
449458 let routerService = appInstance . lookup ( 'service:router' ) as RouterService & {
@@ -465,7 +474,13 @@ function _instrumentNavigation(appInstance: ApplicationInstance, config: EmberSe
465474 }
466475
467476 routerService . _hasMountedSentryPerformanceRouting = true ;
468- _instrumentEmberRouter ( routerService , routerMain , config ) ;
477+ _instrumentEmberRouter (
478+ routerService ,
479+ routerMain ,
480+ config ,
481+ startBrowserTracingPageLoadSpan ,
482+ startBrowserTracingNavigationSpan ,
483+ ) ;
469484}
470485
471486export default {
0 commit comments