Skip to content

Commit d4d9ed2

Browse files
committed
avoid importing Ember bundle
Where possible, import the module directly.
1 parent b2666f9 commit d4d9ed2

File tree

6 files changed

+20
-17
lines changed

6 files changed

+20
-17
lines changed

packages/ember/addon/ember.d.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import ApplicationInstance from '@ember/application/instance';
2-
import Ember from 'ember';
32
import { run, _backburner, scheduleOnce } from '@ember/runloop';
3+
import { subscribe } from '@ember/instrumentation';
44
import * as Sentry from '@sentry/browser';
55
import { ExtendedBackburner } from '@sentry/ember/runloop';
66
import { Span, Transaction, Integration } from '@sentry/types';
@@ -279,7 +279,6 @@ function _instrumentComponents(config: EmberSentryConfig) {
279279
const beforeEntries = {} as RenderEntries;
280280
const beforeComponentDefinitionEntries = {} as RenderEntries;
281281

282-
const subscribe = Ember.subscribe;
283282
function _subscribeToRenderEvents() {
284283
subscribe('render.component', {
285284
before(_name: string, _timestamp: number, payload: Payload) {
@@ -310,6 +309,7 @@ function _instrumentInitialLoad(config: EmberSentryConfig) {
310309
const endName = '@sentry/ember:initial-load-end';
311310

312311
const { performance } = window;
312+
// @ts-ignore
313313
const HAS_PERFORMANCE = performance && performance.clearMarks && performance.clearMeasures;
314314

315315
if (!HAS_PERFORMANCE) {
@@ -324,6 +324,7 @@ function _instrumentInitialLoad(config: EmberSentryConfig) {
324324

325325
// Split performance check in two so clearMarks still happens even if timeOrigin isn't available.
326326
const HAS_PERFORMANCE_TIMING =
327+
// @ts-ignore
327328
performance.measure && performance.getEntriesByName && browserPerformanceTimeOrigin !== undefined;
328329
if (!HAS_PERFORMANCE_TIMING) {
329330
return;

packages/ember/tests/acceptance/sentry-errors-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { test, module } from 'qunit';
22
import { setupApplicationTest } from 'ember-qunit';
33
import { find, click, visit } from '@ember/test-helpers';
4-
import { run } from '@ember/runloop';
4+
import { next } from '@ember/runloop';
55
import { setupSentryTest } from '../helpers/setup-sentry';
66

77
const defaultAssertOptions = {
@@ -78,7 +78,7 @@ module('Acceptance | Sentry Errors', function (hooks) {
7878

7979
const done = assert.async();
8080

81-
run.next(() => {
81+
next(() => {
8282
assertSentryErrorCount(assert, 1);
8383
assertSentryCall(assert, 0, { errorBodyContains: [...this.errorMessages] });
8484
done();

packages/ember/tests/helpers/setup-sentry.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import Ember from 'ember';
21
import sinon from 'sinon';
32
import { _instrumentEmberRouter } from '@sentry/ember/instance-initializers/sentry-performance';
3+
import { resetOnerror, setupOnerror } from '@ember/test-helpers';
44

55
// Keep a reference to the original startTransaction as the application gets re-initialized and setup for
66
// the integration doesn't occur again after the first time.
@@ -41,11 +41,10 @@ export function setupSentryTest(hooks) {
4141
return true;
4242
};
4343

44-
Ember.onerror = function (...args) {
45-
const [error] = args;
44+
setupOnerror(function (error) {
4645
errorMessages.push(error.message);
4746
throw error;
48-
};
47+
});
4948

5049
this._windowOnError = window.onerror;
5150

@@ -64,5 +63,6 @@ export function setupSentryTest(hooks) {
6463
this.fetchStub.restore();
6564
this.qunitOnUnhandledRejection.restore();
6665
window.onerror = this._windowOnError;
66+
resetOnerror();
6767
});
6868
}

packages/ember/tests/test-helper.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import Application from '../app';
1010
import config from '../config/environment';
1111
import { setApplication } from '@ember/test-helpers';
1212
import { start } from 'ember-qunit';
13-
import Ember from 'ember';
13+
import { isTesting } from '@embroider/macros';
1414

15-
Sentry.addGlobalEventProcessor((event) => {
16-
if (Ember.testing) {
15+
Sentry.addGlobalEventProcessor(event => {
16+
if (isTesting()) {
1717
if (!window._sentryTestEvents) {
1818
window._sentryTestEvents = [];
1919
}

packages/ember/types/global.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,11 @@ declare module '@sentry/ember/templates/*' {
44
const tmpl: TemplateFactory;
55
export default tmpl;
66
}
7+
8+
/**
9+
* This is private as of now.
10+
* See https://github.com/emberjs/ember.js/blob/master/packages/@ember/instrumentation/index.ts
11+
*/
12+
declare module '@ember/instrumentation' {
13+
export function subscribe(pattern: string, object: {}): any;
14+
}

0 commit comments

Comments
 (0)