Skip to content

Commit 47e8b7a

Browse files
authored
feat(ember): Add ember-engine-router support (#5905)
When using engines and the 'ember-engines-router-service' addon, this will allow performance monitoring to work, which was previously causing an error since the ember-engines-router-service router doesn't have a 'recognize' function. This hooks into the main router for the application instead, and only setups up route change listening once for navigation transactions.
1 parent 458374a commit 47e8b7a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

packages/ember/addon/instance-initializers/sentry-performance.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,20 @@ export async function instrumentForPerformance(appInstance: ApplicationInstance)
372372
new tracing.Integrations.BrowserTracing({
373373
routingInstrumentation: (customStartTransaction, startTransactionOnPageLoad) => {
374374
const routerMain = appInstance.lookup('router:main');
375-
const routerService = appInstance.lookup('service:router');
375+
let routerService = appInstance.lookup('service:router');
376+
if (routerService.externalRouter) {
377+
// Using ember-engines-router-service in an engine.
378+
routerService = routerService.externalRouter;
379+
}
380+
if (routerService._hasMountedSentryPerformanceRouting) {
381+
// Routing listens to route changes on the main router, and should not be initialized multiple times per page.
382+
return;
383+
}
384+
if (!routerService.recognize) {
385+
// Router is missing critical functionality to limit cardinality of the transaction names.
386+
return;
387+
}
388+
routerService._hasMountedSentryPerformanceRouting = true;
376389
_instrumentEmberRouter(routerService, routerMain, config, customStartTransaction, startTransactionOnPageLoad);
377390
},
378391
idleTimeout,

0 commit comments

Comments
 (0)