Skip to content

Commit

Permalink
feat(ember): Add ember-engine-router support (#5905)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
k-fish committed Oct 6, 2022
1 parent 458374a commit 47e8b7a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/ember/addon/instance-initializers/sentry-performance.ts
Expand Up @@ -372,7 +372,20 @@ export async function instrumentForPerformance(appInstance: ApplicationInstance)
new tracing.Integrations.BrowserTracing({
routingInstrumentation: (customStartTransaction, startTransactionOnPageLoad) => {
const routerMain = appInstance.lookup('router:main');
const routerService = appInstance.lookup('service:router');
let routerService = appInstance.lookup('service:router');
if (routerService.externalRouter) {
// Using ember-engines-router-service in an engine.
routerService = routerService.externalRouter;
}
if (routerService._hasMountedSentryPerformanceRouting) {
// Routing listens to route changes on the main router, and should not be initialized multiple times per page.
return;
}
if (!routerService.recognize) {
// Router is missing critical functionality to limit cardinality of the transaction names.
return;
}
routerService._hasMountedSentryPerformanceRouting = true;
_instrumentEmberRouter(routerService, routerMain, config, customStartTransaction, startTransactionOnPageLoad);
},
idleTimeout,
Expand Down

0 comments on commit 47e8b7a

Please sign in to comment.