Skip to content

Commit 4b7deee

Browse files
authored
ref(ember): Avoid namespace import to hopefully resolve minification issue (#10885)
Let's see if this actually fixes this issue: #10566 🤔 Maybe the internal bundler is thrown off by the fact that we lazy load browser tracing further below, and only includes certain things in `Sentry` on top, not sure...
1 parent 1c3f7a4 commit 4b7deee

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,20 @@ import type RouterService from '@ember/routing/router-service';
66
import { _backburner, run, scheduleOnce } from '@ember/runloop';
77
import type { EmberRunQueues } from '@ember/runloop/-private/types';
88
import { getOwnConfig, isTesting, macroCondition } from '@embroider/macros';
9-
import * as Sentry from '@sentry/browser';
109
import type { ExtendedBackburner } from '@sentry/ember/runloop';
1110
import type { Span } from '@sentry/types';
1211
import { GLOBAL_OBJ, browserPerformanceTimeOrigin, timestampInSeconds } from '@sentry/utils';
1312

14-
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '@sentry/core';
15-
import type { BrowserClient } from '..';
16-
import { getActiveSpan, startInactiveSpan } from '..';
13+
import type { BrowserClient } from '@sentry/browser';
14+
import {
15+
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
16+
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
17+
getActiveSpan,
18+
getClient,
19+
startBrowserTracingNavigationSpan,
20+
startBrowserTracingPageLoadSpan,
21+
startInactiveSpan,
22+
} from '@sentry/browser';
1723
import type { EmberRouterMain, EmberSentryConfig, GlobalConfig, OwnConfig } from '../types';
1824

1925
function getSentryConfig(): EmberSentryConfig {
@@ -103,15 +109,15 @@ export function _instrumentEmberRouter(
103109
const browserTracingOptions = config.browserTracingOptions || config.sentry.browserTracingOptions || {};
104110
const url = getLocationURL(location);
105111

106-
const client = Sentry.getClient<BrowserClient>();
112+
const client = getClient<BrowserClient>();
107113

108114
if (!client) {
109115
return;
110116
}
111117

112118
if (url && browserTracingOptions.instrumentPageLoad !== false) {
113119
const routeInfo = routerService.recognize(url);
114-
activeRootSpan = Sentry.startBrowserTracingPageLoadSpan(client, {
120+
activeRootSpan = startBrowserTracingPageLoadSpan(client, {
115121
name: `route:${routeInfo.name}`,
116122
origin: 'auto.pageload.ember',
117123
attributes: {
@@ -138,7 +144,7 @@ export function _instrumentEmberRouter(
138144
const { fromRoute, toRoute } = getTransitionInformation(transition, routerService);
139145
activeRootSpan?.end();
140146

141-
activeRootSpan = Sentry.startBrowserTracingNavigationSpan(client, {
147+
activeRootSpan = startBrowserTracingNavigationSpan(client, {
142148
name: `route:${toRoute}`,
143149
origin: 'auto.navigation.ember',
144150
attributes: {
@@ -416,7 +422,7 @@ export async function instrumentForPerformance(appInstance: ApplicationInstance)
416422
instrumentPageLoad: false,
417423
});
418424

419-
const client = Sentry.getClient<BrowserClient>();
425+
const client = getClient<BrowserClient>();
420426

421427
const isAlreadyInitialized = macroCondition(isTesting()) ? !!client?.getIntegrationByName('BrowserTracing') : false;
422428

0 commit comments

Comments
 (0)