Skip to content

Commit 23264ba

Browse files
committed
Import Sentry from the @sentry/ember package (rather than @sentry/browser) in the the ember instance-initializer, otherwise any existing client that gets created by the app author gets overriden by this one - and loses any app specific BrowserOptions config
1 parent f398340 commit 23264ba

File tree

6 files changed

+77
-1
lines changed

6 files changed

+77
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import ApplicationInstance from '@ember/application/instance';
22
import Ember from 'ember';
33
import { run } from '@ember/runloop';
4-
import * as Sentry from '@sentry/browser';
4+
import * as Sentry from '@sentry/ember';
55
import { Span, Transaction, Integration } from '@sentry/types';
66
import { EmberRunQueues } from '@ember/runloop/-private/types';
77
import { getActiveTransaction } from '..';

packages/ember/ember.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import Ember from 'ember';
2+
declare module 'ember' {
3+
namespace Ember {
4+
export function subscribe(pattern: string, object: {}): any;
5+
}
6+
}

packages/ember/index.d.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { BrowserOptions } from '@sentry/browser';
2+
declare module '@ember/debug' {
3+
function assert(desc: string, test: unknown): void;
4+
}
5+
export declare function InitSentryForEmber(_runtimeConfig: BrowserOptions | undefined): void;
6+
export declare const getActiveTransaction: () => import("@sentry/types").Transaction | undefined;
7+
export declare const instrumentRoutePerformance: (BaseRoute: any) => {
8+
new (): {
9+
[x: string]: any;
10+
beforeModel(...args: any[]): Promise<any>;
11+
model(...args: any[]): Promise<any>;
12+
afterModel(...args: any[]): Promise<any>;
13+
setupController(...args: any[]): Promise<any>;
14+
};
15+
[x: string]: any;
16+
};
17+
export * from '@sentry/browser';
18+
export declare const init: typeof InitSentryForEmber;
19+
//# sourceMappingURL=index.d.ts.map
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import ApplicationInstance from '@ember/application/instance';
2+
import { EmberSentryConfig } from '../types';
3+
export declare function initialize(appInstance: ApplicationInstance): void;
4+
export declare function _instrumentEmberRouter(routerService: any, routerMain: any, config: EmberSentryConfig, startTransaction: Function, startTransactionOnPageLoad?: boolean): {
5+
startTransaction: Function;
6+
};
7+
export declare function instrumentForPerformance(appInstance: ApplicationInstance): Promise<void>;
8+
declare const _default: {
9+
initialize: typeof initialize;
10+
};
11+
export default _default;
12+
//# sourceMappingURL=sentry-performance.d.ts.map

packages/ember/runloop.d.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Backburner } from '@ember/runloop/-private/backburner';
2+
3+
/**
4+
* Backburner needs to be extended as it's missing the 'off' method.
5+
*/
6+
interface ExtendedBackburner extends Backburner {
7+
off(...args: any[]): void;
8+
}
9+
10+
/**
11+
* Runloop needs to be extended to expose backburner as suggested here:
12+
* https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/ember__runloop/ember__runloop-tests.ts#L9
13+
*/
14+
declare module '@ember/runloop' {
15+
interface RunNamespace {
16+
backburner: ExtendedBackburner;
17+
}
18+
}

packages/ember/types.d.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { BrowserOptions } from '@sentry/browser';
2+
export declare type EmberSentryConfig = {
3+
sentry: BrowserOptions & {
4+
browserTracingOptions: Object;
5+
};
6+
transitionTimeout: number;
7+
ignoreEmberOnErrorWarning: boolean;
8+
disableInstrumentComponents: boolean;
9+
disablePerformance: boolean;
10+
disablePostTransitionRender: boolean;
11+
disableRunloopPerformance: boolean;
12+
disableInitialLoadInstrumentation: boolean;
13+
enableComponentDefinitions: boolean;
14+
minimumRunloopQueueDuration: number;
15+
minimumComponentRenderDuration: number;
16+
browserTracingOptions: Object;
17+
};
18+
export declare type OwnConfig = {
19+
sentryConfig: EmberSentryConfig;
20+
};
21+
//# sourceMappingURL=types.d.ts.map

0 commit comments

Comments
 (0)