Skip to content

Commit a6e25f0

Browse files
committed
replace hacky check
1 parent cbc00a2 commit a6e25f0

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

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

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { browserPerformanceTimeOrigin, GLOBAL_OBJ, timestampWithMs } from '@sent
1010
import { macroCondition, isTesting, getOwnConfig } from '@embroider/macros';
1111
import { EmberSentryConfig, GlobalConfig, OwnConfig } from '../types';
1212
import RouterService from '@ember/routing/router-service';
13+
import { BaseClient } from '@sentry/core';
1314

1415
function getSentryConfig() {
1516
const _global = GLOBAL_OBJ as typeof GLOBAL_OBJ & GlobalConfig;
@@ -416,20 +417,12 @@ export async function instrumentForPerformance(appInstance: ApplicationInstance)
416417
});
417418

418419
if (macroCondition(isTesting())) {
419-
class FakeBrowserTracingClass {
420-
static id = 'BrowserTracing';
421-
public name = FakeBrowserTracingClass.id;
422-
setupOnce() {
423-
// noop - We're just faking this class for a lookup
424-
}
425-
}
420+
const client = Sentry.getCurrentHub().getClient();
426421

427422
if (
428-
Sentry.getCurrentHub()?.getIntegration(
429-
// This is a temporary hack because the BrowserTracing integration cannot have a static `id` field for tree
430-
// shaking reasons. However, `getIntegration` needs that field.
431-
FakeBrowserTracingClass,
432-
)
423+
client &&
424+
(client as BaseClient<any>).getIntegrationById &&
425+
(client as BaseClient<any>).getIntegrationById('BrowserTracing')
433426
) {
434427
// Initializers are called more than once in tests, causing the integrations to not be setup correctly.
435428
return;

0 commit comments

Comments
 (0)