@sentry/ember 7.99.0 → 7.100.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8,18 +8,13 @@ import type { EmberRunQueues } from '@ember/runloop/-private/types';
|
|
|
8
8
|
import { getOwnConfig, isTesting, macroCondition } from '@embroider/macros';
|
|
9
9
|
import * as Sentry from '@sentry/browser';
|
|
10
10
|
import type { ExtendedBackburner } from '@sentry/ember/runloop';
|
|
11
|
-
import type { Span
|
|
11
|
+
import type { Span } from '@sentry/types';
|
|
12
12
|
import { GLOBAL_OBJ, browserPerformanceTimeOrigin, timestampInSeconds } from '@sentry/utils';
|
|
13
13
|
|
|
14
14
|
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
|
|
15
15
|
import type { BrowserClient } from '..';
|
|
16
16
|
import { getActiveSpan, startInactiveSpan } from '..';
|
|
17
|
-
import type { EmberRouterMain, EmberSentryConfig, GlobalConfig, OwnConfig
|
|
18
|
-
|
|
19
|
-
type SentryTestRouterService = RouterService & {
|
|
20
|
-
_startTransaction?: StartTransactionFunction;
|
|
21
|
-
_sentryInstrumented?: boolean;
|
|
22
|
-
};
|
|
17
|
+
import type { EmberRouterMain, EmberSentryConfig, GlobalConfig, OwnConfig } from '../types';
|
|
23
18
|
|
|
24
19
|
function getSentryConfig(): EmberSentryConfig {
|
|
25
20
|
const _global = GLOBAL_OBJ as typeof GLOBAL_OBJ & GlobalConfig;
|
|
@@ -98,26 +93,29 @@ export function _instrumentEmberRouter(
|
|
|
98
93
|
routerService: RouterService,
|
|
99
94
|
routerMain: EmberRouterMain,
|
|
100
95
|
config: EmberSentryConfig,
|
|
101
|
-
|
|
102
|
-
startTransactionOnPageLoad?: boolean,
|
|
103
|
-
): {
|
|
104
|
-
startTransaction: StartTransactionFunction;
|
|
105
|
-
} {
|
|
96
|
+
): void {
|
|
106
97
|
const { disableRunloopPerformance } = config;
|
|
107
98
|
const location = routerMain.location;
|
|
108
|
-
let
|
|
99
|
+
let activeRootSpan: Span | undefined;
|
|
109
100
|
let transitionSpan: Span | undefined;
|
|
110
101
|
|
|
102
|
+
// Maintaining backwards compatibility with config.browserTracingOptions, but passing it with Sentry options is preferred.
|
|
103
|
+
const browserTracingOptions = config.browserTracingOptions || config.sentry.browserTracingOptions || {};
|
|
111
104
|
const url = getLocationURL(location);
|
|
112
105
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
106
|
+
const client = Sentry.getClient<BrowserClient>();
|
|
107
|
+
|
|
108
|
+
if (!client) {
|
|
109
|
+
return;
|
|
116
110
|
}
|
|
117
111
|
|
|
118
|
-
if (
|
|
112
|
+
if (
|
|
113
|
+
url &&
|
|
114
|
+
browserTracingOptions.startTransactionOnPageLoad !== false &&
|
|
115
|
+
browserTracingOptions.instrumentPageLoad !== false
|
|
116
|
+
) {
|
|
119
117
|
const routeInfo = routerService.recognize(url);
|
|
120
|
-
|
|
118
|
+
Sentry.startBrowserTracingPageLoadSpan(client, {
|
|
121
119
|
name: `route:${routeInfo.name}`,
|
|
122
120
|
op: 'pageload',
|
|
123
121
|
origin: 'auto.pageload.ember',
|
|
@@ -127,20 +125,29 @@ export function _instrumentEmberRouter(
|
|
|
127
125
|
'routing.instrumentation': '@sentry/ember',
|
|
128
126
|
},
|
|
129
127
|
});
|
|
128
|
+
activeRootSpan = getActiveSpan();
|
|
130
129
|
}
|
|
131
130
|
|
|
132
131
|
const finishActiveTransaction = (_: unknown, nextInstance: unknown): void => {
|
|
133
132
|
if (nextInstance) {
|
|
134
133
|
return;
|
|
135
134
|
}
|
|
136
|
-
|
|
135
|
+
activeRootSpan?.end();
|
|
137
136
|
getBackburner().off('end', finishActiveTransaction);
|
|
138
137
|
};
|
|
139
138
|
|
|
139
|
+
if (
|
|
140
|
+
browserTracingOptions.startTransactionOnLocationChange === false &&
|
|
141
|
+
browserTracingOptions.instrumentNavigation === false
|
|
142
|
+
) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
|
|
140
146
|
routerService.on('routeWillChange', (transition: Transition) => {
|
|
141
147
|
const { fromRoute, toRoute } = getTransitionInformation(transition, routerService);
|
|
142
|
-
|
|
143
|
-
|
|
148
|
+
activeRootSpan?.end();
|
|
149
|
+
|
|
150
|
+
Sentry.startBrowserTracingNavigationSpan(client, {
|
|
144
151
|
name: `route:${toRoute}`,
|
|
145
152
|
op: 'navigation',
|
|
146
153
|
origin: 'auto.navigation.ember',
|
|
@@ -150,6 +157,9 @@ export function _instrumentEmberRouter(
|
|
|
150
157
|
'routing.instrumentation': '@sentry/ember',
|
|
151
158
|
},
|
|
152
159
|
});
|
|
160
|
+
|
|
161
|
+
activeRootSpan = getActiveSpan();
|
|
162
|
+
|
|
153
163
|
transitionSpan = startInactiveSpan({
|
|
154
164
|
attributes: {
|
|
155
165
|
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.ember',
|
|
@@ -160,22 +170,18 @@ export function _instrumentEmberRouter(
|
|
|
160
170
|
});
|
|
161
171
|
|
|
162
172
|
routerService.on('routeDidChange', () => {
|
|
163
|
-
if (!transitionSpan || !
|
|
173
|
+
if (!transitionSpan || !activeRootSpan) {
|
|
164
174
|
return;
|
|
165
175
|
}
|
|
166
176
|
transitionSpan.end();
|
|
167
177
|
|
|
168
178
|
if (disableRunloopPerformance) {
|
|
169
|
-
|
|
179
|
+
activeRootSpan.end();
|
|
170
180
|
return;
|
|
171
181
|
}
|
|
172
182
|
|
|
173
183
|
getBackburner().on('end', finishActiveTransaction);
|
|
174
184
|
});
|
|
175
|
-
|
|
176
|
-
return {
|
|
177
|
-
startTransaction,
|
|
178
|
-
};
|
|
179
185
|
}
|
|
180
186
|
|
|
181
187
|
function _instrumentEmberRunloop(config: EmberSentryConfig): void {
|
|
@@ -411,61 +417,63 @@ export async function instrumentForPerformance(appInstance: ApplicationInstance)
|
|
|
411
417
|
// Maintaining backwards compatibility with config.browserTracingOptions, but passing it with Sentry options is preferred.
|
|
412
418
|
const browserTracingOptions = config.browserTracingOptions || config.sentry.browserTracingOptions || {};
|
|
413
419
|
|
|
414
|
-
const {
|
|
420
|
+
const { browserTracingIntegration } = await import('@sentry/browser');
|
|
415
421
|
|
|
416
422
|
const idleTimeout = config.transitionTimeout || 5000;
|
|
417
423
|
|
|
418
|
-
const browserTracing =
|
|
419
|
-
routingInstrumentation: (customStartTransaction, startTransactionOnPageLoad) => {
|
|
420
|
-
// eslint-disable-next-line ember/no-private-routing-service
|
|
421
|
-
const routerMain = appInstance.lookup('router:main') as EmberRouterMain;
|
|
422
|
-
let routerService = appInstance.lookup('service:router') as RouterService & {
|
|
423
|
-
externalRouter?: RouterService;
|
|
424
|
-
_hasMountedSentryPerformanceRouting?: boolean;
|
|
425
|
-
};
|
|
426
|
-
|
|
427
|
-
if (routerService.externalRouter) {
|
|
428
|
-
// Using ember-engines-router-service in an engine.
|
|
429
|
-
routerService = routerService.externalRouter;
|
|
430
|
-
}
|
|
431
|
-
if (routerService._hasMountedSentryPerformanceRouting) {
|
|
432
|
-
// Routing listens to route changes on the main router, and should not be initialized multiple times per page.
|
|
433
|
-
return;
|
|
434
|
-
}
|
|
435
|
-
if (!routerService.recognize) {
|
|
436
|
-
// Router is missing critical functionality to limit cardinality of the transaction names.
|
|
437
|
-
return;
|
|
438
|
-
}
|
|
439
|
-
routerService._hasMountedSentryPerformanceRouting = true;
|
|
440
|
-
_instrumentEmberRouter(routerService, routerMain, config, customStartTransaction, startTransactionOnPageLoad);
|
|
441
|
-
},
|
|
424
|
+
const browserTracing = browserTracingIntegration({
|
|
442
425
|
idleTimeout,
|
|
443
426
|
...browserTracingOptions,
|
|
427
|
+
instrumentNavigation: false,
|
|
428
|
+
instrumentPageLoad: false,
|
|
444
429
|
});
|
|
445
430
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
if (
|
|
450
|
-
client &&
|
|
451
|
-
(client as BrowserClient).getIntegrationByName &&
|
|
452
|
-
(client as BrowserClient).getIntegrationByName('BrowserTracing')
|
|
453
|
-
) {
|
|
454
|
-
// Initializers are called more than once in tests, causing the integrations to not be setup correctly.
|
|
455
|
-
return;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
431
|
+
const client = Sentry.getClient<BrowserClient>();
|
|
432
|
+
|
|
433
|
+
const isAlreadyInitialized = macroCondition(isTesting()) ? !!client?.getIntegrationByName('BrowserTracing') : false;
|
|
458
434
|
|
|
459
|
-
const client = Sentry.getClient();
|
|
460
435
|
if (client && client.addIntegration) {
|
|
461
436
|
client.addIntegration(browserTracing);
|
|
462
437
|
}
|
|
463
438
|
|
|
439
|
+
// We _always_ call this, as it triggers the page load & navigation spans
|
|
440
|
+
_instrumentNavigation(appInstance, config);
|
|
441
|
+
|
|
442
|
+
// Skip instrumenting the stuff below again in tests, as these are not reset between tests
|
|
443
|
+
if (isAlreadyInitialized) {
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
|
|
464
447
|
_instrumentEmberRunloop(config);
|
|
465
448
|
_instrumentComponents(config);
|
|
466
449
|
_instrumentInitialLoad(config);
|
|
467
450
|
}
|
|
468
451
|
|
|
452
|
+
function _instrumentNavigation(appInstance: ApplicationInstance, config: EmberSentryConfig): void {
|
|
453
|
+
// eslint-disable-next-line ember/no-private-routing-service
|
|
454
|
+
const routerMain = appInstance.lookup('router:main') as EmberRouterMain;
|
|
455
|
+
let routerService = appInstance.lookup('service:router') as RouterService & {
|
|
456
|
+
externalRouter?: RouterService;
|
|
457
|
+
_hasMountedSentryPerformanceRouting?: boolean;
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
if (routerService.externalRouter) {
|
|
461
|
+
// Using ember-engines-router-service in an engine.
|
|
462
|
+
routerService = routerService.externalRouter;
|
|
463
|
+
}
|
|
464
|
+
if (routerService._hasMountedSentryPerformanceRouting) {
|
|
465
|
+
// Routing listens to route changes on the main router, and should not be initialized multiple times per page.
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
if (!routerService.recognize) {
|
|
469
|
+
// Router is missing critical functionality to limit cardinality of the transaction names.
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
routerService._hasMountedSentryPerformanceRouting = true;
|
|
474
|
+
_instrumentEmberRouter(routerService, routerMain, config);
|
|
475
|
+
}
|
|
476
|
+
|
|
469
477
|
export default {
|
|
470
478
|
initialize,
|
|
471
479
|
};
|
package/addon/types.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { BrowserOptions, BrowserTracing } from '@sentry/browser';
|
|
1
|
+
import type { BrowserOptions, BrowserTracing, browserTracingIntegration } from '@sentry/browser';
|
|
2
2
|
import type { Transaction, TransactionContext } from '@sentry/types';
|
|
3
3
|
|
|
4
|
-
type BrowserTracingOptions =
|
|
4
|
+
type BrowserTracingOptions = Parameters<typeof browserTracingIntegration>[0] &
|
|
5
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
6
|
+
ConstructorParameters<typeof BrowserTracing>[0];
|
|
5
7
|
|
|
6
8
|
export type EmberSentryConfig = {
|
|
7
9
|
sentry: BrowserOptions & { browserTracingOptions?: BrowserTracingOptions };
|
|
@@ -31,7 +33,7 @@ export interface EmberRouterMain {
|
|
|
31
33
|
rootURL: string;
|
|
32
34
|
};
|
|
33
35
|
}
|
|
34
|
-
|
|
36
|
+
/** @deprecated This will be removed in v8. */
|
|
35
37
|
export type StartTransactionFunction = (context: TransactionContext) => Transaction | undefined;
|
|
36
38
|
|
|
37
39
|
export type GlobalConfig = {
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import type ApplicationInstance from '@ember/application/instance';
|
|
2
2
|
import type RouterService from '@ember/routing/router-service';
|
|
3
|
-
import type { EmberRouterMain, EmberSentryConfig
|
|
3
|
+
import type { EmberRouterMain, EmberSentryConfig } from '../types';
|
|
4
4
|
export declare function initialize(appInstance: ApplicationInstance): void;
|
|
5
|
-
export declare function _instrumentEmberRouter(routerService: RouterService, routerMain: EmberRouterMain, config: EmberSentryConfig
|
|
6
|
-
startTransaction: StartTransactionFunction;
|
|
7
|
-
};
|
|
5
|
+
export declare function _instrumentEmberRouter(routerService: RouterService, routerMain: EmberRouterMain, config: EmberSentryConfig): void;
|
|
8
6
|
export declare function instrumentForPerformance(appInstance: ApplicationInstance): Promise<void>;
|
|
9
7
|
declare const _default: {
|
|
10
8
|
initialize: typeof initialize;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/ember",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.100.1",
|
|
4
4
|
"description": "Official Sentry SDK for Ember.js",
|
|
5
5
|
"repository": "git://github.com/getsentry/sentry-javascript.git",
|
|
6
6
|
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/ember",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@embroider/macros": "^1.9.0",
|
|
35
|
-
"@sentry/browser": "7.
|
|
36
|
-
"@sentry/core": "7.
|
|
37
|
-
"@sentry/types": "7.
|
|
38
|
-
"@sentry/utils": "7.
|
|
35
|
+
"@sentry/browser": "7.100.1",
|
|
36
|
+
"@sentry/core": "7.100.1",
|
|
37
|
+
"@sentry/types": "7.100.1",
|
|
38
|
+
"@sentry/utils": "7.100.1",
|
|
39
39
|
"ember-auto-import": "^1.12.1 || ^2.4.3",
|
|
40
40
|
"ember-cli-babel": "^7.26.11",
|
|
41
41
|
"ember-cli-htmlbars": "^6.1.1",
|
package/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { BrowserOptions, BrowserTracing } from '@sentry/browser';
|
|
1
|
+
import type { BrowserOptions, BrowserTracing, browserTracingIntegration } from '@sentry/browser';
|
|
2
2
|
import type { Transaction, TransactionContext } from '@sentry/types';
|
|
3
|
-
type BrowserTracingOptions = ConstructorParameters<typeof BrowserTracing>[0];
|
|
3
|
+
type BrowserTracingOptions = Parameters<typeof browserTracingIntegration>[0] & ConstructorParameters<typeof BrowserTracing>[0];
|
|
4
4
|
export type EmberSentryConfig = {
|
|
5
5
|
sentry: BrowserOptions & {
|
|
6
6
|
browserTracingOptions?: BrowserTracingOptions;
|
|
@@ -28,6 +28,7 @@ export interface EmberRouterMain {
|
|
|
28
28
|
rootURL: string;
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
+
/** @deprecated This will be removed in v8. */
|
|
31
32
|
export type StartTransactionFunction = (context: TransactionContext) => Transaction | undefined;
|
|
32
33
|
export type GlobalConfig = {
|
|
33
34
|
__sentryEmberConfig: EmberSentryConfig['sentry'];
|