@sentry/ember 7.92.0 → 7.94.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.
package/addon/index.ts CHANGED
@@ -2,13 +2,14 @@ import { assert, warn } from '@ember/debug';
2
2
  import type Route from '@ember/routing/route';
3
3
  import { next } from '@ember/runloop';
4
4
  import { getOwnConfig, isDevelopingApp, macroCondition } from '@embroider/macros';
5
+ import { startSpan } from '@sentry/browser';
5
6
  import type { BrowserOptions } from '@sentry/browser';
6
7
  import * as Sentry from '@sentry/browser';
7
8
  import { SDK_VERSION } from '@sentry/browser';
8
- import type { Transaction } from '@sentry/types';
9
- import { GLOBAL_OBJ, timestampInSeconds } from '@sentry/utils';
9
+ import { GLOBAL_OBJ } from '@sentry/utils';
10
10
  import Ember from 'ember';
11
11
 
12
+ import type { Transaction } from '@sentry/types';
12
13
  import type { EmberSentryConfig, GlobalConfig, OwnConfig } from './types';
13
14
 
14
15
  function _getSentryInitConfig(): EmberSentryConfig['sentry'] {
@@ -66,8 +67,14 @@ export function InitSentryForEmber(_runtimeConfig?: BrowserOptions): void {
66
67
  }
67
68
  }
68
69
 
70
+ /**
71
+ * Grabs active transaction off scope.
72
+ *
73
+ * @deprecated You should not rely on the transaction, but just use `startSpan()` APIs instead.
74
+ */
69
75
  export const getActiveTransaction = (): Transaction | undefined => {
70
- return Sentry.getCurrentHub().getScope().getTransaction();
76
+ // eslint-disable-next-line deprecation/deprecation
77
+ return Sentry.getCurrentScope().getTransaction();
71
78
  };
72
79
 
73
80
  type RouteConstructor = new (...args: ConstructorParameters<typeof Route>) => Route;
@@ -80,22 +87,16 @@ export const instrumentRoutePerformance = <T extends RouteConstructor>(BaseRoute
80
87
  fn: X,
81
88
  args: Parameters<X>,
82
89
  ): Promise<ReturnType<X>> => {
83
- const startTimestamp = timestampInSeconds();
84
- const result = await fn(...args);
85
-
86
- const currentTransaction = getActiveTransaction();
87
- if (!currentTransaction) {
88
- return result;
89
- }
90
- currentTransaction
91
- .startChild({
90
+ return startSpan(
91
+ {
92
92
  op,
93
- description,
93
+ name: description,
94
94
  origin: 'auto.ui.ember',
95
- startTimestamp,
96
- })
97
- .end();
98
- return result;
95
+ },
96
+ () => {
97
+ return fn(...args);
98
+ },
99
+ );
99
100
  };
100
101
 
101
102
  const routeName = BaseRoute.name;
@@ -12,7 +12,7 @@ import type { Span, Transaction } from '@sentry/types';
12
12
  import { GLOBAL_OBJ, browserPerformanceTimeOrigin, timestampInSeconds } from '@sentry/utils';
13
13
 
14
14
  import type { BrowserClient } from '..';
15
- import { getActiveTransaction } from '..';
15
+ import { getActiveSpan, startInactiveSpan } from '..';
16
16
  import type { EmberRouterMain, EmberSentryConfig, GlobalConfig, OwnConfig, StartTransactionFunction } from '../types';
17
17
 
18
18
  type SentryTestRouterService = RouterService & {
@@ -149,9 +149,9 @@ export function _instrumentEmberRouter(
149
149
  'routing.instrumentation': '@sentry/ember',
150
150
  },
151
151
  });
152
- transitionSpan = activeTransaction?.startChild({
152
+ transitionSpan = startInactiveSpan({
153
153
  op: 'ui.ember.transition',
154
- description: `route:${fromRoute} -> route:${toRoute}`,
154
+ name: `route:${fromRoute} -> route:${toRoute}`,
155
155
  origin: 'auto.ui.ember',
156
156
  });
157
157
  });
@@ -195,8 +195,8 @@ function _instrumentEmberRunloop(config: EmberSentryConfig): void {
195
195
  if (previousInstance) {
196
196
  return;
197
197
  }
198
- const activeTransaction = getActiveTransaction();
199
- if (!activeTransaction) {
198
+ const activeSpan = getActiveSpan();
199
+ if (!activeSpan) {
200
200
  return;
201
201
  }
202
202
  if (currentQueueSpan) {
@@ -211,22 +211,20 @@ function _instrumentEmberRunloop(config: EmberSentryConfig): void {
211
211
  const minQueueDuration = minimumRunloopQueueDuration ?? 5;
212
212
 
213
213
  if ((now - currentQueueStart) * 1000 >= minQueueDuration) {
214
- activeTransaction
215
- ?.startChild({
216
- op: `ui.ember.runloop.${queue}`,
217
- origin: 'auto.ui.ember',
218
- startTimestamp: currentQueueStart,
219
- endTimestamp: now,
220
- })
221
- .end();
214
+ startInactiveSpan({
215
+ name: 'runloop',
216
+ op: `ui.ember.runloop.${queue}`,
217
+ origin: 'auto.ui.ember',
218
+ startTimestamp: currentQueueStart,
219
+ })?.end(now);
222
220
  }
223
221
  currentQueueStart = undefined;
224
222
  }
225
223
 
226
224
  // Setup for next queue
227
225
 
228
- const stillActiveTransaction = getActiveTransaction();
229
- if (!stillActiveTransaction) {
226
+ const stillActiveSpan = getActiveSpan();
227
+ if (!stillActiveSpan) {
230
228
  return;
231
229
  }
232
230
  currentQueueStart = timestampInSeconds();
@@ -286,15 +284,12 @@ function processComponentRenderAfter(
286
284
  const componentRenderDuration = now - begin.now;
287
285
 
288
286
  if (componentRenderDuration * 1000 >= minComponentDuration) {
289
- const activeTransaction = getActiveTransaction();
290
-
291
- activeTransaction?.startChild({
287
+ startInactiveSpan({
288
+ name: payload.containerKey || payload.object,
292
289
  op,
293
- description: payload.containerKey || payload.object,
294
290
  origin: 'auto.ui.ember',
295
291
  startTimestamp: begin.now,
296
- endTimestamp: now,
297
- });
292
+ })?.end(now);
298
293
  }
299
294
  }
300
295
 
@@ -372,13 +367,12 @@ function _instrumentInitialLoad(config: EmberSentryConfig): void {
372
367
  const startTimestamp = (measure.startTime + browserPerformanceTimeOrigin) / 1000;
373
368
  const endTimestamp = startTimestamp + measure.duration / 1000;
374
369
 
375
- const transaction = getActiveTransaction();
376
- const span = transaction?.startChild({
370
+ startInactiveSpan({
377
371
  op: 'ui.ember.init',
372
+ name: 'init',
378
373
  origin: 'auto.ui.ember',
379
374
  startTimestamp,
380
- });
381
- span?.end(endTimestamp);
375
+ })?.end(endTimestamp);
382
376
  performance.clearMarks(startName);
383
377
  performance.clearMarks(endName);
384
378
 
@@ -443,19 +437,19 @@ export async function instrumentForPerformance(appInstance: ApplicationInstance)
443
437
  });
444
438
 
445
439
  if (macroCondition(isTesting())) {
446
- const client = Sentry.getCurrentHub().getClient();
440
+ const client = Sentry.getClient();
447
441
 
448
442
  if (
449
443
  client &&
450
- (client as BrowserClient).getIntegrationById &&
451
- (client as BrowserClient).getIntegrationById('BrowserTracing')
444
+ (client as BrowserClient).getIntegrationByName &&
445
+ (client as BrowserClient).getIntegrationByName('BrowserTracing')
452
446
  ) {
453
447
  // Initializers are called more than once in tests, causing the integrations to not be setup correctly.
454
448
  return;
455
449
  }
456
450
  }
457
451
 
458
- const client = Sentry.getCurrentHub().getClient();
452
+ const client = Sentry.getClient();
459
453
  if (client && client.addIntegration) {
460
454
  client.addIntegration(browserTracing);
461
455
  }
package/index.d.ts CHANGED
@@ -2,6 +2,11 @@ import type Route from '@ember/routing/route';
2
2
  import type { BrowserOptions } from '@sentry/browser';
3
3
  import type { Transaction } from '@sentry/types';
4
4
  export declare function InitSentryForEmber(_runtimeConfig?: BrowserOptions): void;
5
+ /**
6
+ * Grabs active transaction off scope.
7
+ *
8
+ * @deprecated You should not rely on the transaction, but just use `startSpan()` APIs instead.
9
+ */
5
10
  export declare const getActiveTransaction: () => Transaction | undefined;
6
11
  type RouteConstructor = new (...args: ConstructorParameters<typeof Route>) => Route;
7
12
  export declare const instrumentRoutePerformance: <T extends RouteConstructor>(BaseRoute: T) => T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/ember",
3
- "version": "7.92.0",
3
+ "version": "7.94.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,9 +32,10 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@embroider/macros": "^1.9.0",
35
- "@sentry/browser": "7.92.0",
36
- "@sentry/types": "7.92.0",
37
- "@sentry/utils": "7.92.0",
35
+ "@sentry/browser": "7.94.1",
36
+ "@sentry/core": "7.94.1",
37
+ "@sentry/types": "7.94.1",
38
+ "@sentry/utils": "7.94.1",
38
39
  "ember-auto-import": "^1.12.1 || ^2.4.3",
39
40
  "ember-cli-babel": "^7.26.11",
40
41
  "ember-cli-htmlbars": "^6.1.1",