@sentry/ember 7.45.0 → 7.47.0

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.
@@ -3,13 +3,14 @@ import { run, _backburner, scheduleOnce } from '@ember/runloop';
3
3
  import { subscribe } from '@ember/instrumentation';
4
4
  import * as Sentry from '@sentry/browser';
5
5
  import { ExtendedBackburner } from '@sentry/ember/runloop';
6
- import { Span, Transaction, Integration } from '@sentry/types';
6
+ import { Span, Transaction } from '@sentry/types';
7
7
  import { EmberRunQueues } from '@ember/runloop/-private/types';
8
8
  import { getActiveTransaction } from '..';
9
9
  import { browserPerformanceTimeOrigin, GLOBAL_OBJ, timestampWithMs } from '@sentry/utils';
10
10
  import { macroCondition, isTesting, getOwnConfig } from '@embroider/macros';
11
11
  import { EmberSentryConfig, GlobalConfig, OwnConfig } from '../types';
12
12
  import RouterService from '@ember/routing/router-service';
13
+ import type { BaseClient } from '@sentry/core';
13
14
 
14
15
  function getSentryConfig() {
15
16
  const _global = GLOBAL_OBJ as typeof GLOBAL_OBJ & GlobalConfig;
@@ -390,58 +391,49 @@ export async function instrumentForPerformance(appInstance: ApplicationInstance)
390
391
 
391
392
  const idleTimeout = config.transitionTimeout || 5000;
392
393
 
393
- const existingIntegrations = (sentryConfig['integrations'] || []) as Integration[];
394
-
395
- sentryConfig['integrations'] = [
396
- ...existingIntegrations,
397
- new BrowserTracing({
398
- routingInstrumentation: (customStartTransaction, startTransactionOnPageLoad) => {
399
- const routerMain = appInstance.lookup('router:main');
400
- let routerService = appInstance.lookup('service:router') as
401
- | RouterService & { externalRouter?: RouterService; _hasMountedSentryPerformanceRouting?: boolean };
402
-
403
- if (routerService.externalRouter) {
404
- // Using ember-engines-router-service in an engine.
405
- routerService = routerService.externalRouter;
406
- }
407
- if (routerService._hasMountedSentryPerformanceRouting) {
408
- // Routing listens to route changes on the main router, and should not be initialized multiple times per page.
409
- return;
410
- }
411
- if (!routerService.recognize) {
412
- // Router is missing critical functionality to limit cardinality of the transaction names.
413
- return;
414
- }
415
- routerService._hasMountedSentryPerformanceRouting = true;
416
- _instrumentEmberRouter(routerService, routerMain, config, customStartTransaction, startTransactionOnPageLoad);
417
- },
418
- idleTimeout,
419
- ...browserTracingOptions,
420
- }),
421
- ];
422
-
423
- class FakeBrowserTracingClass {
424
- static id = 'BrowserTracing';
425
- public name = FakeBrowserTracingClass.id;
426
- setupOnce() {
427
- // noop - We're just faking this class for a lookup
394
+ const browserTracing = new BrowserTracing({
395
+ routingInstrumentation: (customStartTransaction, startTransactionOnPageLoad) => {
396
+ const routerMain = appInstance.lookup('router:main');
397
+ let routerService = appInstance.lookup('service:router') as
398
+ | RouterService & { externalRouter?: RouterService; _hasMountedSentryPerformanceRouting?: boolean };
399
+
400
+ if (routerService.externalRouter) {
401
+ // Using ember-engines-router-service in an engine.
402
+ routerService = routerService.externalRouter;
403
+ }
404
+ if (routerService._hasMountedSentryPerformanceRouting) {
405
+ // Routing listens to route changes on the main router, and should not be initialized multiple times per page.
406
+ return;
407
+ }
408
+ if (!routerService.recognize) {
409
+ // Router is missing critical functionality to limit cardinality of the transaction names.
410
+ return;
411
+ }
412
+ routerService._hasMountedSentryPerformanceRouting = true;
413
+ _instrumentEmberRouter(routerService, routerMain, config, customStartTransaction, startTransactionOnPageLoad);
414
+ },
415
+ idleTimeout,
416
+ ...browserTracingOptions,
417
+ });
418
+
419
+ if (macroCondition(isTesting())) {
420
+ const client = Sentry.getCurrentHub().getClient();
421
+
422
+ if (
423
+ client &&
424
+ (client as BaseClient<any>).getIntegrationById &&
425
+ (client as BaseClient<any>).getIntegrationById('BrowserTracing')
426
+ ) {
427
+ // Initializers are called more than once in tests, causing the integrations to not be setup correctly.
428
+ return;
428
429
  }
429
430
  }
430
431
 
431
- if (
432
- isTesting() &&
433
- Sentry.getCurrentHub()?.getIntegration(
434
- // This is a temporary hack because the BrowserTracing integration cannot have a static `id` field for tree
435
- // shaking reasons. However, `getIntegration` needs that field.
436
- FakeBrowserTracingClass,
437
- )
438
- ) {
439
- // Initializers are called more than once in tests, causing the integrations to not be setup correctly.
440
- return;
432
+ const client = Sentry.getCurrentHub().getClient();
433
+ if (client && client.addIntegration) {
434
+ client.addIntegration(browserTracing);
441
435
  }
442
436
 
443
- Sentry.init(sentryConfig); // Call init again to rebind client with new integration list in addition to the defaults
444
-
445
437
  _instrumentEmberRunloop(config);
446
438
  _instrumentComponents(config);
447
439
  _instrumentInitialLoad(config);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/ember",
3
- "version": "7.45.0",
3
+ "version": "7.47.0",
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",
@@ -29,9 +29,9 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@embroider/macros": "^1.9.0",
32
- "@sentry/browser": "7.45.0",
33
- "@sentry/types": "7.45.0",
34
- "@sentry/utils": "7.45.0",
32
+ "@sentry/browser": "7.47.0",
33
+ "@sentry/types": "7.47.0",
34
+ "@sentry/utils": "7.47.0",
35
35
  "ember-auto-import": "^1.12.1 || ^2.4.3",
36
36
  "ember-cli-babel": "^7.26.11",
37
37
  "ember-cli-htmlbars": "^6.1.1",