Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(ember): Avoid namespace import to hopefully resolve minification issue #10885

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,15 +109,15 @@ 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;
}

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: {
Expand All @@ -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: {
Expand Down Expand Up @@ -416,7 +422,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
Loading