Skip to content

refactor(ember): Use @embroider/macros instead of runInDebug for @sentry/ember #2873

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

Merged
merged 3 commits into from
Oct 6, 2020
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions packages/ember/addon/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as Sentry from '@sentry/browser';
import { addGlobalEventProcessor, SDK_VERSION, BrowserOptions } from '@sentry/browser';
import environmentConfig from 'ember-get-config';

import { macroCondition, isDevelopingApp } from '@embroider/macros';
import { next } from '@ember/runloop';
import { assert, warn, runInDebug } from '@ember/debug';
import { assert, warn } from '@ember/debug';
import Ember from 'ember';
import { timestampWithMs } from '@sentry/utils';

Expand All @@ -22,7 +22,7 @@ export function InitSentryForEmber(_runtimeConfig: BrowserOptions | undefined) {

Sentry.init(initConfig);

runInDebug(() => {
if (macroCondition(isDevelopingApp())) {
if (config.ignoreEmberOnErrorWarning) {
return;
}
Expand All @@ -35,7 +35,7 @@ export function InitSentryForEmber(_runtimeConfig: BrowserOptions | undefined) {
},
);
});
});
}
}

export const getActiveTransaction = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import { Span, Transaction, Integration } from '@sentry/types';
import { EmberRunQueues } from '@ember/runloop/-private/types';
import { getActiveTransaction } from '..';
import { timestampWithMs } from '@sentry/utils';
import { macroCondition, isTesting } from '@embroider/macros';

export function initialize(appInstance: ApplicationInstance): void {
const config = environmentConfig['@sentry/ember'];
if (config['disablePerformance']) {
return;
}
const performancePromise = instrumentForPerformance(appInstance);
if (Ember.testing) {
if (macroCondition(isTesting())) {
(<any>window)._sentryPerformanceLoad = performancePromise;
}
}
Expand Down Expand Up @@ -42,7 +43,7 @@ export function _instrumentEmberRouter(

const url = location && location.getURL && location.getURL();

if (Ember.testing) {
if (macroCondition(isTesting())) {
routerService._sentryInstrumented = true;
routerService._startTransaction = startTransaction;
}
Expand Down Expand Up @@ -329,7 +330,7 @@ export async function instrumentForPerformance(appInstance: ApplicationInstance)
}),
];

if (Ember.testing && Sentry.getCurrentHub()?.getIntegration(tracing.Integrations.BrowserTracing)) {
if (isTesting() && Sentry.getCurrentHub()?.getIntegration(tracing.Integrations.BrowserTracing)) {
// Initializers are called more than once in tests, causing the integrations to not be setup correctly.
return;
}
Expand Down
1 change: 1 addition & 0 deletions packages/ember/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"pack": "npm pack"
},
"dependencies": {
"@embroider/macros": ">=0.25.0",
"@sentry/browser": "5.25.0",
"@sentry/tracing": "5.25.0",
"@sentry/types": "5.25.0",
Expand Down
Loading