From 988ef58f324db91c129a64582c27658e8c204f0f Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Fri, 1 Mar 2024 10:30:15 +0000 Subject: [PATCH] ref(ember): Avoid namespace import to hopefully resolve minification issue Not sure if this will change stuff, but maybe this is tree shaken away incorrectly there, for whatever reason... let's try to see if this helps with things! --- .../sentry-performance.ts | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/ember/addon/instance-initializers/sentry-performance.ts b/packages/ember/addon/instance-initializers/sentry-performance.ts index 7cd61dd222cd..552fa1df7e78 100644 --- a/packages/ember/addon/instance-initializers/sentry-performance.ts +++ b/packages/ember/addon/instance-initializers/sentry-performance.ts @@ -6,14 +6,20 @@ import type RouterService from '@ember/routing/router-service'; import { _backburner, run, scheduleOnce } from '@ember/runloop'; import type { EmberRunQueues } from '@ember/runloop/-private/types'; import { getOwnConfig, isTesting, macroCondition } from '@embroider/macros'; -import * as Sentry from '@sentry/browser'; import type { ExtendedBackburner } from '@sentry/ember/runloop'; import type { Span } from '@sentry/types'; import { GLOBAL_OBJ, browserPerformanceTimeOrigin, timestampInSeconds } from '@sentry/utils'; -import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '@sentry/core'; -import type { BrowserClient } from '..'; -import { getActiveSpan, startInactiveSpan } from '..'; +import type { BrowserClient } from '@sentry/browser'; +import { + SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, + SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, + getActiveSpan, + getClient, + startBrowserTracingNavigationSpan, + startBrowserTracingPageLoadSpan, + startInactiveSpan, +} from '@sentry/browser'; import type { EmberRouterMain, EmberSentryConfig, GlobalConfig, OwnConfig } from '../types'; function getSentryConfig(): EmberSentryConfig { @@ -103,7 +109,7 @@ export function _instrumentEmberRouter( const browserTracingOptions = config.browserTracingOptions || config.sentry.browserTracingOptions || {}; const url = getLocationURL(location); - const client = Sentry.getClient(); + const client = getClient(); if (!client) { return; @@ -111,7 +117,7 @@ export function _instrumentEmberRouter( if (url && browserTracingOptions.instrumentPageLoad !== false) { const routeInfo = routerService.recognize(url); - activeRootSpan = Sentry.startBrowserTracingPageLoadSpan(client, { + activeRootSpan = startBrowserTracingPageLoadSpan(client, { name: `route:${routeInfo.name}`, origin: 'auto.pageload.ember', attributes: { @@ -138,7 +144,7 @@ export function _instrumentEmberRouter( const { fromRoute, toRoute } = getTransitionInformation(transition, routerService); activeRootSpan?.end(); - activeRootSpan = Sentry.startBrowserTracingNavigationSpan(client, { + activeRootSpan = startBrowserTracingNavigationSpan(client, { name: `route:${toRoute}`, origin: 'auto.navigation.ember', attributes: { @@ -416,7 +422,7 @@ export async function instrumentForPerformance(appInstance: ApplicationInstance) instrumentPageLoad: false, }); - const client = Sentry.getClient(); + const client = getClient(); const isAlreadyInitialized = macroCondition(isTesting()) ? !!client?.getIntegrationByName('BrowserTracing') : false;