Skip to content

Commit

Permalink
ref(ember): Avoid namespace import to hopefully resolve minification …
Browse files Browse the repository at this point in the history
…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...
  • Loading branch information
mydea authored and AbhiPrasad committed Mar 7, 2024
1 parent 9b4c855 commit 3c841ce
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions packages/ember/addon/instance-initializers/sentry-performance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -103,7 +109,7 @@ export function _instrumentEmberRouter(
const browserTracingOptions = config.browserTracingOptions || config.sentry.browserTracingOptions || {};
const url = getLocationURL(location);

const client = Sentry.getClient<BrowserClient>();
const client = getClient<BrowserClient>();

if (!client) {
return;
Expand All @@ -115,7 +121,7 @@ export function _instrumentEmberRouter(
browserTracingOptions.instrumentPageLoad !== false
) {
const routeInfo = routerService.recognize(url);
activeRootSpan = Sentry.startBrowserTracingPageLoadSpan(client, {
activeRootSpan = startBrowserTracingPageLoadSpan(client, {
name: `route:${routeInfo.name}`,
origin: 'auto.pageload.ember',
attributes: {
Expand Down Expand Up @@ -148,7 +154,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: {
Expand Down Expand Up @@ -429,7 +435,7 @@ export async function instrumentForPerformance(appInstance: ApplicationInstance)
instrumentPageLoad: false,
});

const client = Sentry.getClient<BrowserClient>();
const client = getClient<BrowserClient>();

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

Expand Down

0 comments on commit 3c841ce

Please sign in to comment.