Skip to content

Commit bc9ce81

Browse files
committed
WIP move stuff around...
1 parent 1fb7bc6 commit bc9ce81

4 files changed

Lines changed: 13 additions & 14 deletions

File tree

packages/ember/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@
3535
index.d.ts
3636
runloop.d.ts
3737
types.d.ts
38+
utils/*.d.ts

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ export function initialize(appInstance: ApplicationInstance): void {
2929
if (config['disablePerformance']) {
3030
return;
3131
}
32-
instrumentForPerformance(appInstance);
32+
33+
// Run this in the next tick to ensure the ember router etc. is properly initialized
34+
setTimeout(() => {
35+
instrumentForPerformance(appInstance);
36+
});
3337
}
3438

3539
export default {

packages/ember/addon/utils/browserTracingIntegration.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { BrowserClient } from '@sentry/browser';
12
import {
23
browserTracingIntegration as originalBrowserTracingIntegration,
34
startBrowserTracingNavigationSpan,
@@ -50,10 +51,11 @@ export function browserTracingIntegration(options: EmberBrowserTracingIntegratio
5051

5152
return {
5253
...integration,
53-
afterAllSetup(client) {
54+
afterAllSetup(client: BrowserClient) {
5455
integration.afterAllSetup(client);
5556

5657
instrumentEmberAppInstanceForPerformance(
58+
client,
5759
appInstance,
5860
appInstancePerformanceConfig,
5961
startBrowserTracingPageLoadSpan,

packages/ember/addon/utils/instrumentEmberAppInstanceForPerformance.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,13 @@ import type {
66
startBrowserTracingNavigationSpan as startBrowserTracingNavigationSpanType,
77
startBrowserTracingPageLoadSpan as startBrowserTracingPageLoadSpanType,
88
} from '@sentry/browser';
9-
import {
10-
getClient,
11-
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
12-
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
13-
startInactiveSpan,
14-
} from '@sentry/browser';
9+
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, startInactiveSpan } from '@sentry/browser';
1510
import type { Span } from '@sentry/core';
1611
import type { EmberRouterMain } from '../types';
1712
import { getBackburner } from './performance';
1813

1914
export function instrumentEmberAppInstanceForPerformance(
15+
client: BrowserClient,
2016
appInstance: ApplicationInstance,
2117
config: { disableRunloopPerformance?: boolean; instrumentPageLoad?: boolean; instrumentNavigation?: boolean },
2218
startBrowserTracingPageLoadSpan: typeof startBrowserTracingPageLoadSpanType,
@@ -44,6 +40,7 @@ export function instrumentEmberAppInstanceForPerformance(
4440

4541
routerService._hasMountedSentryPerformanceRouting = true;
4642
_instrumentEmberRouter(
43+
client,
4744
routerService,
4845
routerMain,
4946
config,
@@ -79,6 +76,7 @@ export function _getLocationURL(location: EmberRouterMain['location']): string {
7976
}
8077

8178
function _instrumentEmberRouter(
79+
client: BrowserClient,
8280
routerService: RouterService,
8381
routerMain: EmberRouterMain,
8482
config: { disableRunloopPerformance?: boolean; instrumentPageLoad?: boolean; instrumentNavigation?: boolean },
@@ -92,12 +90,6 @@ function _instrumentEmberRouter(
9290

9391
const url = _getLocationURL(location);
9492

95-
const client = getClient<BrowserClient>();
96-
97-
if (!client) {
98-
return;
99-
}
100-
10193
if (url && instrumentPageLoad !== false) {
10294
const routeInfo = routerService.recognize(url);
10395
activeRootSpan = startBrowserTracingPageLoadSpan(client, {

0 commit comments

Comments
 (0)