@sentry/angular 6.19.2 → 6.19.5

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.
@@ -0,0 +1,4 @@
1
+ export declare const ANGULAR_ROUTING_OP = "ui.angular.routing";
2
+ export declare const ANGULAR_INIT_OP = "ui.angular.init";
3
+ export declare const ANGULAR_OP = "ui.angular";
4
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAEvD,eAAO,MAAM,eAAe,oBAAoB,CAAC;AAEjD,eAAO,MAAM,UAAU,eAAe,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { ErrorHandler as AngularErrorHandler } from '@angular/core';
2
+ import * as Sentry from '@sentry/browser';
3
+ /**
4
+ * Options used to configure the behavior of the Angular ErrorHandler.
5
+ */
6
+ export interface ErrorHandlerOptions {
7
+ logErrors?: boolean;
8
+ showDialog?: boolean;
9
+ dialogOptions?: Sentry.ReportDialogOptions;
10
+ /**
11
+ * Custom implementation of error extraction from the raw value captured by the Angular.
12
+ * @param error Value captured by Angular's ErrorHandler provider
13
+ * @param defaultExtractor Default implementation that can be used as the fallback in case of custom implementation
14
+ */
15
+ extractor?(error: unknown, defaultExtractor: (error: unknown) => unknown): unknown;
16
+ }
17
+ /**
18
+ * Implementation of Angular's ErrorHandler provider that can be used as a drop-in replacement for the stock one.
19
+ */
20
+ declare class SentryErrorHandler implements AngularErrorHandler {
21
+ protected readonly _options: ErrorHandlerOptions;
22
+ constructor(options?: ErrorHandlerOptions);
23
+ /**
24
+ * Method called for every value captured through the ErrorHandler
25
+ */
26
+ handleError(error: unknown): void;
27
+ /**
28
+ * Used to pull a desired value that will be used to capture an event out of the raw value captured by ErrorHandler.
29
+ */
30
+ protected _extractError(error: unknown): unknown;
31
+ /**
32
+ * Default implementation of error extraction that handles default error wrapping, HTTP responses, ErrorEvent and few other known cases.
33
+ */
34
+ protected _defaultExtractor(errorCandidate: unknown): unknown;
35
+ }
36
+ /**
37
+ * Factory function that creates an instance of a preconfigured ErrorHandler provider.
38
+ */
39
+ declare function createErrorHandler(config?: ErrorHandlerOptions): SentryErrorHandler;
40
+ export { createErrorHandler, SentryErrorHandler };
41
+ //# sourceMappingURL=errorhandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorhandler.d.ts","sourceRoot":"","sources":["../../src/errorhandler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,IAAI,mBAAmB,EAAc,MAAM,eAAe,CAAC;AAChF,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAC;AAI1C;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC,mBAAmB,CAAC;IAC3C;;;;OAIG;IACH,SAAS,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,GAAG,OAAO,CAAC;CACpF;AAED;;GAEG;AACH,cACM,kBAAmB,YAAW,mBAAmB;IACrD,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAC;gBAE9B,OAAO,CAAC,EAAE,mBAAmB;IAOhD;;OAEG;IACI,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAkBxC;;OAEG;IACH,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAUhD;;OAEG;IACH,SAAS,CAAC,iBAAiB,CAAC,cAAc,EAAE,OAAO,GAAG,OAAO;CAsC9D;AAED;;GAEG;AACH,iBAAS,kBAAkB,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,kBAAkB,CAE5E;AAED,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** Flag that is true for debug builds, false otherwise. */
2
+ export declare const IS_DEBUG_BUILD: boolean;
3
+ //# sourceMappingURL=flags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flags.d.ts","sourceRoot":"","sources":["../../src/flags.ts"],"names":[],"mappings":"AAgBA,2DAA2D;AAC3D,eAAO,MAAM,cAAc,SAAoE,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from '@sentry/browser';
2
+ export { init } from './sdk';
3
+ export { createErrorHandler, ErrorHandlerOptions, SentryErrorHandler } from './errorhandler';
4
+ export { getActiveTransaction, instrumentAngularRouting, // new name
5
+ routingInstrumentation, // legacy name
6
+ TraceClassDecorator, TraceMethodDecorator, TraceDirective, TraceModule, TraceService, } from './tracing';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAC7F,OAAO,EACL,oBAAoB,EAEpB,wBAAwB,EAAE,WAAW;AACrC,sBAAsB,EAAE,cAAc;AACtC,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,YAAY,GACb,MAAM,WAAW,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { BrowserOptions } from '@sentry/browser';
2
+ /**
3
+ * Inits the Angular SDK
4
+ */
5
+ export declare function init(options: BrowserOptions): void;
6
+ //# sourceMappingURL=sdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAoC,MAAM,iBAAiB,CAAC;AAEnF;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAalD"}
@@ -0,0 +1,61 @@
1
+ import { AfterViewInit, OnDestroy, OnInit } from '@angular/core';
2
+ import { Event, Router } from '@angular/router';
3
+ import { Transaction, TransactionContext } from '@sentry/types';
4
+ import { Observable } from 'rxjs';
5
+ /**
6
+ * Creates routing instrumentation for Angular Router.
7
+ */
8
+ export declare function routingInstrumentation(customStartTransaction: (context: TransactionContext) => Transaction | undefined, startTransactionOnPageLoad?: boolean, startTransactionOnLocationChange?: boolean): void;
9
+ export declare const instrumentAngularRouting: typeof routingInstrumentation;
10
+ /**
11
+ * Grabs active transaction off scope
12
+ */
13
+ export declare function getActiveTransaction(): Transaction | undefined;
14
+ /**
15
+ * Angular's Service responsible for hooking into Angular Router and tracking current navigation process.
16
+ * Creates a new transaction for every route change and measures a duration of routing process.
17
+ */
18
+ export declare class TraceService implements OnDestroy {
19
+ private readonly _router;
20
+ navStart$: Observable<Event>;
21
+ navEnd$: Observable<Event>;
22
+ private _routingSpan;
23
+ private _subscription;
24
+ constructor(_router: Router);
25
+ /**
26
+ * This is used to prevent memory leaks when the root view is created and destroyed multiple times,
27
+ * since `subscribe` callbacks capture `this` and prevent many resources from being GC'd.
28
+ */
29
+ ngOnDestroy(): void;
30
+ }
31
+ /**
32
+ * A directive that can be used to capture initialization lifecycle of the whole component.
33
+ */
34
+ export declare class TraceDirective implements OnInit, AfterViewInit {
35
+ componentName: string;
36
+ private _tracingSpan?;
37
+ /**
38
+ * Implementation of OnInit lifecycle method
39
+ * @inheritdoc
40
+ */
41
+ ngOnInit(): void;
42
+ /**
43
+ * Implementation of AfterViewInit lifecycle method
44
+ * @inheritdoc
45
+ */
46
+ ngAfterViewInit(): void;
47
+ }
48
+ /**
49
+ * A module serves as a single compilation unit for the `TraceDirective` and can be re-used by any other module.
50
+ */
51
+ export declare class TraceModule {
52
+ }
53
+ /**
54
+ * Decorator function that can be used to capture initialization lifecycle of the whole component.
55
+ */
56
+ export declare function TraceClassDecorator(): ClassDecorator;
57
+ /**
58
+ * Decorator function that can be used to capture a single lifecycle methods of the component.
59
+ */
60
+ export declare function TraceMethodDecorator(): MethodDecorator;
61
+ //# sourceMappingURL=tracing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracing.d.ts","sourceRoot":"","sources":["../../src/tracing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA0C,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACzG,OAAO,EAAE,KAAK,EAAkC,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEhF,OAAO,EAAQ,WAAW,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEtE,OAAO,EAAE,UAAU,EAAgB,MAAM,MAAM,CAAC;AAahD;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,sBAAsB,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,WAAW,GAAG,SAAS,EAChF,0BAA0B,GAAE,OAAc,EAC1C,gCAAgC,GAAE,OAAc,GAC/C,IAAI,CAWN;AAED,eAAO,MAAM,wBAAwB,+BAAyB,CAAC;AAE/D;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,WAAW,GAAG,SAAS,CAW9D;AAED;;;GAGG;AACH,qBACa,YAAa,YAAW,SAAS;IAwDzB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAvDpC,SAAS,EAAE,UAAU,CAAC,KAAK,CAAC,CAqCjC;IAEK,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,CAW/B;IAEF,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,aAAa,CAAoC;gBAErB,OAAO,EAAE,MAAM;IAKnD;;;OAGG;IACI,WAAW,IAAI,IAAI;CAG3B;AAID;;GAEG;AACH,qBACa,cAAe,YAAW,MAAM,EAAE,aAAa;IACnC,aAAa,EAAE,MAAM,CAAqB;IAEjE,OAAO,CAAC,YAAY,CAAC,CAAO;IAE5B;;;OAGG;IACI,QAAQ,IAAI,IAAI;IAUvB;;;OAGG;IACI,eAAe,IAAI,IAAI;CAK/B;AAED;;GAEG;AACH,qBAIa,WAAW;CAAG;AAE3B;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,cAAc,CAiCpD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,eAAe,CAuBtD"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The function that does the same job as `NgZone.runOutsideAngular`.
3
+ */
4
+ export declare function runOutsideAngular<T>(callback: () => T): T;
5
+ //# sourceMappingURL=zone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zone.d.ts","sourceRoot":"","sources":["../../src/zone.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,CAWzD"}
@@ -0,0 +1,3 @@
1
+ /** Flag that is true for debug builds, false otherwise. */
2
+ export declare const IS_DEBUG_BUILD: boolean;
3
+ //# sourceMappingURL=flags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flags.d.ts","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":"AAgBA,2DAA2D;AAC3D,eAAO,MAAM,cAAc,SAAoE,CAAC"}
package/dist/flags.js ADDED
@@ -0,0 +1,17 @@
1
+ /*
2
+ * This file defines flags and constants that can be modified during compile time in order to facilitate tree shaking
3
+ * for users.
4
+ *
5
+ * Debug flags need to be declared in each package individually and must not be imported across package boundaries,
6
+ * because some build tools have trouble tree-shaking imported guards.
7
+ *
8
+ * As a convention, we define debug flags in a `flags.ts` file in the root of a package's `src` folder.
9
+ *
10
+ * Debug flag files will contain "magic strings" like `__SENTRY_DEBUG__` that may get replaced with actual values during
11
+ * our, or the user's build process. Take care when introducing new flags - they must not throw if they are not
12
+ * replaced.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ /** Flag that is true for debug builds, false otherwise. */
16
+ exports.IS_DEBUG_BUILD = typeof __SENTRY_DEBUG__ === 'undefined' ? true : __SENTRY_DEBUG__;
17
+ //# sourceMappingURL=flags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flags.js","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;;AAIH,2DAA2D;AAC9C,QAAA,cAAc,GAAG,OAAO,gBAAgB,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC","sourcesContent":["/*\n * This file defines flags and constants that can be modified during compile time in order to facilitate tree shaking\n * for users.\n *\n * Debug flags need to be declared in each package individually and must not be imported across package boundaries,\n * because some build tools have trouble tree-shaking imported guards.\n *\n * As a convention, we define debug flags in a `flags.ts` file in the root of a package's `src` folder.\n *\n * Debug flag files will contain \"magic strings\" like `__SENTRY_DEBUG__` that may get replaced with actual values during\n * our, or the user's build process. Take care when introducing new flags - they must not throw if they are not\n * replaced.\n */\n\ndeclare const __SENTRY_DEBUG__: boolean;\n\n/** Flag that is true for debug builds, false otherwise. */\nexport const IS_DEBUG_BUILD = typeof __SENTRY_DEBUG__ === 'undefined' ? true : __SENTRY_DEBUG__;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"tracing.d.ts","sourceRoot":"","sources":["../src/tracing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA0C,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACzG,OAAO,EAAE,KAAK,EAAkC,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEhF,OAAO,EAAQ,WAAW,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEtE,OAAO,EAAE,UAAU,EAAgB,MAAM,MAAM,CAAC;AAYhD;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,sBAAsB,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,WAAW,GAAG,SAAS,EAChF,0BAA0B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AAE,kBAAkB,KAAK,WAAW,GAAG,SAAS,EAChF,0BAA0B,GAAE,OAAc,EAC1C,gCAAgC,GAAE,OAAc,GAC/C,IAAI,CAWN;AAED,eAAO,MAAM,wBAAwB,+BAAyB,CAAC;AAE/D;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,WAAW,GAAG,SAAS,CAW9D;AAED;;;GAGG;AACH,qBACa,YAAa,YAAW,SAAS;IAwDzB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAvDpC,SAAS,EAAE,UAAU,CAAC,KAAK,CAAC,CAqCjC;IAEK,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,CAW/B;IAEF,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,aAAa,CAAoC;gBAErB,OAAO,EAAE,MAAM;IAKnD;;;OAGG;IACI,WAAW,IAAI,IAAI;CAG3B;AAID;;GAEG;AACH,qBACa,cAAe,YAAW,MAAM,EAAE,aAAa;IACnC,aAAa,EAAE,MAAM,CAAqB;IAEjE,OAAO,CAAC,YAAY,CAAC,CAAO;IAE5B;;;OAGG;IACI,QAAQ,IAAI,IAAI;IAUvB;;;OAGG;IACI,eAAe,IAAI,IAAI;CAK/B;AAED;;GAEG;AACH,qBAIa,WAAW;CAAG;AAE3B;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,cAAc,CAiCpD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,eAAe,CAuBtD"}
package/dist/tracing.js CHANGED
@@ -7,6 +7,7 @@ var utils_1 = require("@sentry/utils");
7
7
  var rxjs_1 = require("rxjs");
8
8
  var operators_1 = require("rxjs/operators");
9
9
  var constants_1 = require("./constants");
10
+ var flags_1 = require("./flags");
10
11
  var zone_1 = require("./zone");
11
12
  var instrumentationInitialized;
12
13
  var stashedStartTransaction;
@@ -54,7 +55,7 @@ var TraceService = /** @class */ (function () {
54
55
  this._router = _router;
55
56
  this.navStart$ = this._router.events.pipe(operators_1.filter(function (event) { return event instanceof router_1.NavigationStart; }), operators_1.tap(function (event) {
56
57
  if (!instrumentationInitialized) {
57
- utils_1.isDebugBuild() &&
58
+ flags_1.IS_DEBUG_BUILD &&
58
59
  utils_1.logger.error('Angular integration has tracing enabled, but Tracing integration is not configured');
59
60
  return;
60
61
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tracing.js","sourceRoot":"","sources":["../src/tracing.ts"],"names":[],"mappings":";;AAAA,sCAAyG;AACzG,0CAAgF;AAChF,2CAAgD;AAEhD,uCAAiH;AACjH,6BAAgD;AAChD,4CAA6C;AAE7C,yCAA8E;AAC9E,+BAA2C;AAE3C,IAAI,0BAAmC,CAAC;AACxC,IAAI,uBAAiF,CAAC;AACtF,IAAI,uCAAgD,CAAC;AAErD,IAAM,MAAM,GAAG,uBAAe,EAAU,CAAC;AAEzC;;GAEG;AACH,SAAgB,sBAAsB,CACpC,sBAAgF,EAChF,0BAA0C,EAC1C,gCAAgD;IADhD,2CAAA,EAAA,iCAA0C;IAC1C,iDAAA,EAAA,uCAAgD;IAEhD,0BAA0B,GAAG,IAAI,CAAC;IAClC,uBAAuB,GAAG,sBAAsB,CAAC;IACjD,uCAAuC,GAAG,gCAAgC,CAAC;IAE3E,IAAI,0BAA0B,IAAI,MAAM,IAAI,MAAM,CAAC,QAAQ,EAAE;QAC3D,sBAAsB,CAAC;YACrB,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ;YAC9B,EAAE,EAAE,UAAU;SACf,CAAC,CAAC;KACJ;AACH,CAAC;AAfD,wDAeC;AAEY,QAAA,wBAAwB,GAAG,sBAAsB,CAAC;AAE/D;;GAEG;AACH,SAAgB,oBAAoB;IAClC,IAAM,UAAU,GAAG,uBAAa,EAAE,CAAC;IAEnC,IAAI,UAAU,EAAE;QACd,IAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC;QACpC,IAAI,KAAK,EAAE;YACT,OAAO,KAAK,CAAC,cAAc,EAAE,CAAC;SAC/B;KACF;IAED,OAAO,SAAS,CA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Destroy, OnInit } from '@angular/core';\nimport { Event, NavigationEnd, NavigationStart, Router } from '@angular/router';\nimport { getCurrentHub } from '@sentry/browser';\nimport { Span, Transaction, TransactionContext } from '@sentry/types';\nimport { getGlobalObject, isDebugBuild, logger, stripUrlQueryAndFragment, timestampWithMs } from '@sentry/utils';\nimport { Observable, Subscription } from 'rxjs';\nimport { filter, tap } from 'rxjs/operators';\n\nimport { ANGULAR_INIT_OP, ANGULAR_OP, ANGULAR_ROUTING_OP } from './constants';\nimport { runOutsideAngular } from './zone';\n\nlet instrumentationInitialized: boolean;\nlet stashedStartTransaction: (context: TransactionContext) => Transaction | undefined;\nlet stashedStartTransactionOnLocationChange: boolean;\n\nconst global = getGlobalObject<Window>();\n\n/**\n * Creates routing instrumentation for Angular Router.\n */\nexport function routingInstrumentation(\n customStartTransaction: (context: TransactionContext) => Transaction | undefined,\n startTransactionOnPageLoad: boolean = true,\n startTransactionOnLocationChange: boolean = true,\n): void {\n instrumentationInitialized = true;\n stashedStartTransaction = customStartTransaction;\n stashedStartTransactionOnLocationChange = startTransactionOnLocationChange;\n\n if (startTransactionOnPageLoad && global && global.location) {\n customStartTransaction({\n name: global.location.pathname,\n op: 'pageload',\n });\n }\n}\n\nexport const instrumentAngularRouting = routingInstrumentation;\n\n/**\n * Grabs active transaction off scope\n */\nexport function getActiveTransaction(): Transaction | undefined {\n const currentHub = getCurrentHub();\n\n if (currentHub) {\n const scope = currentHub.getScope();\n if (scope) {\n return scope.getTransaction();\n }\n }\n\n return undefined;\n}\n\n/**\n * Angular's Service responsible for hooking into Angular Router and tracking current navigation process.\n * Creates a new transaction for every route change and measures a duration of routing process.\n */\n@Injectable({ providedIn: 'root' })\nexport class TraceService implements OnDestroy {\n public navStart$: Observable<Event> = this._router.events.pipe(\n filter(event => event instanceof NavigationStart),\n tap(event => {\n if (!instrumentationInitialized) {\n isDebugBuild() &&\n logger.error('Angular integration has tracing enabled, but Tracing integration is not configured');\n return;\n }\n\n const navigationEvent = event as NavigationStart;\n const strippedUrl = stripUrlQueryAndFragment(navigationEvent.url);\n let activeTransaction = getActiveTransaction();\n\n if (!activeTransaction && stashedStartTransactionOnLocationChange) {\n activeTransaction = stashedStartTransaction({\n name: strippedUrl,\n op: 'navigation',\n });\n }\n\n if (activeTransaction) {\n if (this._routingSpan) {\n this._routingSpan.finish();\n }\n this._routingSpan = activeTransaction.startChild({\n description: `${navigationEvent.url}`,\n op: ANGULAR_ROUTING_OP,\n tags: {\n 'routing.instrumentation': '@sentry/angular',\n url: strippedUrl,\n ...(navigationEvent.navigationTrigger && {\n navigationTrigger: navigationEvent.navigationTrigger,\n }),\n },\n });\n }\n }),\n );\n\n public navEnd$: Observable<Event> = this._router.events.pipe(\n filter(event => event instanceof NavigationEnd),\n tap(() => {\n if (this._routingSpan) {\n runOutsideAngular(() => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this._routingSpan!.finish();\n });\n this._routingSpan = null;\n }\n }),\n );\n\n private _routingSpan: Span | null = null;\n private _subscription: Subscription = new Subscription();\n\n public constructor(private readonly _router: Router) {\n this._subscription.add(this.navStart$.subscribe());\n this._subscription.add(this.navEnd$.subscribe());\n }\n\n /**\n * This is used to prevent memory leaks when the root view is created and destroyed multiple times,\n * since `subscribe` callbacks capture `this` and prevent many resources from being GC'd.\n */\n public ngOnDestroy(): void {\n this._subscription.unsubscribe();\n }\n}\n\nconst UNKNOWN_COMPONENT = 'unknown';\n\n/**\n * A directive that can be used to capture initialization lifecycle of the whole component.\n */\n@Directive({ selector: '[trace]' })\nexport class TraceDirective implements OnInit, AfterViewInit {\n @Input('trace') public componentName: string = UNKNOWN_COMPONENT;\n\n private _tracingSpan?: Span;\n\n /**\n * Implementation of OnInit lifecycle method\n * @inheritdoc\n */\n public ngOnInit(): void {\n const activeTransaction = getActiveTransaction();\n if (activeTransaction) {\n this._tracingSpan = activeTransaction.startChild({\n description: `<${this.componentName}>`,\n op: ANGULAR_INIT_OP,\n });\n }\n }\n\n /**\n * Implementation of AfterViewInit lifecycle method\n * @inheritdoc\n */\n public ngAfterViewInit(): void {\n if (this._tracingSpan) {\n this._tracingSpan.finish();\n }\n }\n}\n\n/**\n * A module serves as a single compilation unit for the `TraceDirective` and can be re-used by any other module.\n */\n@NgModule({\n declarations: [TraceDirective],\n exports: [TraceDirective],\n})\nexport class TraceModule {}\n\n/**\n * Decorator function that can be used to capture initialization lifecycle of the whole component.\n */\nexport function TraceClassDecorator(): ClassDecorator {\n let tracingSpan: Span;\n\n /* eslint-disable @typescript-eslint/no-unsafe-member-access */\n // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n return target => {\n const originalOnInit = target.prototype.ngOnInit;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n target.prototype.ngOnInit = function (...args: any[]): ReturnType<typeof originalOnInit> {\n const activeTransaction = getActiveTransaction();\n if (activeTransaction) {\n tracingSpan = activeTransaction.startChild({\n description: `<${target.name}>`,\n op: ANGULAR_INIT_OP,\n });\n }\n if (originalOnInit) {\n return originalOnInit.apply(this, args);\n }\n };\n\n const originalAfterViewInit = target.prototype.ngAfterViewInit;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n target.prototype.ngAfterViewInit = function (...args: any[]): ReturnType<typeof originalAfterViewInit> {\n if (tracingSpan) {\n tracingSpan.finish();\n }\n if (originalAfterViewInit) {\n return originalAfterViewInit.apply(this, args);\n }\n };\n };\n /* eslint-enable @typescript-eslint/no-unsafe-member-access */\n}\n\n/**\n * Decorator function that can be used to capture a single lifecycle methods of the component.\n */\nexport function TraceMethodDecorator(): MethodDecorator {\n // eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/ban-types\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const originalMethod = descriptor.value;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n descriptor.value = function (...args: any[]): ReturnType<typeof originalMethod> {\n const now = timestampWithMs();\n const activeTransaction = getActiveTransaction();\n if (activeTransaction) {\n activeTransaction.startChild({\n description: `<${target.constructor.name}>`,\n endTimestamp: now,\n op: `${ANGULAR_OP}.${String(propertyKey)}`,\n startTimestamp: now,\n });\n }\n if (originalMethod) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n return originalMethod.apply(this, args);\n }\n };\n return descriptor;\n };\n}\n"]}
1
+ {"version":3,"file":"tracing.js","sourceRoot":"","sources":["../src/tracing.ts"],"names":[],"mappings":";;AAAA,sCAAyG;AACzG,0CAAgF;AAChF,2CAAgD;AAEhD,uCAAmG;AACnG,6BAAgD;AAChD,4CAA6C;AAE7C,yCAA8E;AAC9E,iCAAyC;AACzC,+BAA2C;AAE3C,IAAI,0BAAmC,CAAC;AACxC,IAAI,uBAAiF,CAAC;AACtF,IAAI,uCAAgD,CAAC;AAErD,IAAM,MAAM,GAAG,uBAAe,EAAU,CAAC;AAEzC;;GAEG;AACH,SAAgB,sBAAsB,CACpC,sBAAgF,EAChF,0BAA0C,EAC1C,gCAAgD;IADhD,2CAAA,EAAA,iCAA0C;IAC1C,iDAAA,EAAA,uCAAgD;IAEhD,0BAA0B,GAAG,IAAI,CAAC;IAClC,uBAAuB,GAAG,sBAAsB,CAAC;IACjD,uCAAuC,GAAG,gCAAgC,CAAC;IAE3E,IAAI,0BAA0B,IAAI,MAAM,IAAI,MAAM,CAAC,QAAQ,EAAE;QAC3D,sBAAsB,CAAC;YACrB,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ;YAC9B,EAAE,EAAE,UAAU;SACf,CAAC,CAAC;KACJ;AACH,CAAC;AAfD,wDAeC;AAEY,QAAA,wBAAwB,GAAG,sBAAsB,CAAC;AAE/D;;GAEG;AACH,SAAgB,oBAAoB;IAClC,IAAM,UAAU,GAAG,uBAAa,EAAE,CAAC;IAEnC,IAAI,UAAU,EAAE;QACd,IAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC;QACpC,IAAI,KAAK,EAAE;YACT,OAAO,KAAK,CAAC,cAAc,EAAE,CAAC;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it, Directive, Injectable, Input, NgModule, OnDestroy, OnInit } from '@angular/core';\nimport { Event, NavigationEnd, NavigationStart, Router } from '@angular/router';\nimport { getCurrentHub } from '@sentry/browser';\nimport { Span, Transaction, TransactionContext } from '@sentry/types';\nimport { getGlobalObject, logger, stripUrlQueryAndFragment, timestampWithMs } from '@sentry/utils';\nimport { Observable, Subscription } from 'rxjs';\nimport { filter, tap } from 'rxjs/operators';\n\nimport { ANGULAR_INIT_OP, ANGULAR_OP, ANGULAR_ROUTING_OP } from './constants';\nimport { IS_DEBUG_BUILD } from './flags';\nimport { runOutsideAngular } from './zone';\n\nlet instrumentationInitialized: boolean;\nlet stashedStartTransaction: (context: TransactionContext) => Transaction | undefined;\nlet stashedStartTransactionOnLocationChange: boolean;\n\nconst global = getGlobalObject<Window>();\n\n/**\n * Creates routing instrumentation for Angular Router.\n */\nexport function routingInstrumentation(\n customStartTransaction: (context: TransactionContext) => Transaction | undefined,\n startTransactionOnPageLoad: boolean = true,\n startTransactionOnLocationChange: boolean = true,\n): void {\n instrumentationInitialized = true;\n stashedStartTransaction = customStartTransaction;\n stashedStartTransactionOnLocationChange = startTransactionOnLocationChange;\n\n if (startTransactionOnPageLoad && global && global.location) {\n customStartTransaction({\n name: global.location.pathname,\n op: 'pageload',\n });\n }\n}\n\nexport const instrumentAngularRouting = routingInstrumentation;\n\n/**\n * Grabs active transaction off scope\n */\nexport function getActiveTransaction(): Transaction | undefined {\n const currentHub = getCurrentHub();\n\n if (currentHub) {\n const scope = currentHub.getScope();\n if (scope) {\n return scope.getTransaction();\n }\n }\n\n return undefined;\n}\n\n/**\n * Angular's Service responsible for hooking into Angular Router and tracking current navigation process.\n * Creates a new transaction for every route change and measures a duration of routing process.\n */\n@Injectable({ providedIn: 'root' })\nexport class TraceService implements OnDestroy {\n public navStart$: Observable<Event> = this._router.events.pipe(\n filter(event => event instanceof NavigationStart),\n tap(event => {\n if (!instrumentationInitialized) {\n IS_DEBUG_BUILD &&\n logger.error('Angular integration has tracing enabled, but Tracing integration is not configured');\n return;\n }\n\n const navigationEvent = event as NavigationStart;\n const strippedUrl = stripUrlQueryAndFragment(navigationEvent.url);\n let activeTransaction = getActiveTransaction();\n\n if (!activeTransaction && stashedStartTransactionOnLocationChange) {\n activeTransaction = stashedStartTransaction({\n name: strippedUrl,\n op: 'navigation',\n });\n }\n\n if (activeTransaction) {\n if (this._routingSpan) {\n this._routingSpan.finish();\n }\n this._routingSpan = activeTransaction.startChild({\n description: `${navigationEvent.url}`,\n op: ANGULAR_ROUTING_OP,\n tags: {\n 'routing.instrumentation': '@sentry/angular',\n url: strippedUrl,\n ...(navigationEvent.navigationTrigger && {\n navigationTrigger: navigationEvent.navigationTrigger,\n }),\n },\n });\n }\n }),\n );\n\n public navEnd$: Observable<Event> = this._router.events.pipe(\n filter(event => event instanceof NavigationEnd),\n tap(() => {\n if (this._routingSpan) {\n runOutsideAngular(() => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this._routingSpan!.finish();\n });\n this._routingSpan = null;\n }\n }),\n );\n\n private _routingSpan: Span | null = null;\n private _subscription: Subscription = new Subscription();\n\n public constructor(private readonly _router: Router) {\n this._subscription.add(this.navStart$.subscribe());\n this._subscription.add(this.navEnd$.subscribe());\n }\n\n /**\n * This is used to prevent memory leaks when the root view is created and destroyed multiple times,\n * since `subscribe` callbacks capture `this` and prevent many resources from being GC'd.\n */\n public ngOnDestroy(): void {\n this._subscription.unsubscribe();\n }\n}\n\nconst UNKNOWN_COMPONENT = 'unknown';\n\n/**\n * A directive that can be used to capture initialization lifecycle of the whole component.\n */\n@Directive({ selector: '[trace]' })\nexport class TraceDirective implements OnInit, AfterViewInit {\n @Input('trace') public componentName: string = UNKNOWN_COMPONENT;\n\n private _tracingSpan?: Span;\n\n /**\n * Implementation of OnInit lifecycle method\n * @inheritdoc\n */\n public ngOnInit(): void {\n const activeTransaction = getActiveTransaction();\n if (activeTransaction) {\n this._tracingSpan = activeTransaction.startChild({\n description: `<${this.componentName}>`,\n op: ANGULAR_INIT_OP,\n });\n }\n }\n\n /**\n * Implementation of AfterViewInit lifecycle method\n * @inheritdoc\n */\n public ngAfterViewInit(): void {\n if (this._tracingSpan) {\n this._tracingSpan.finish();\n }\n }\n}\n\n/**\n * A module serves as a single compilation unit for the `TraceDirective` and can be re-used by any other module.\n */\n@NgModule({\n declarations: [TraceDirective],\n exports: [TraceDirective],\n})\nexport class TraceModule {}\n\n/**\n * Decorator function that can be used to capture initialization lifecycle of the whole component.\n */\nexport function TraceClassDecorator(): ClassDecorator {\n let tracingSpan: Span;\n\n /* eslint-disable @typescript-eslint/no-unsafe-member-access */\n // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n return target => {\n const originalOnInit = target.prototype.ngOnInit;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n target.prototype.ngOnInit = function (...args: any[]): ReturnType<typeof originalOnInit> {\n const activeTransaction = getActiveTransaction();\n if (activeTransaction) {\n tracingSpan = activeTransaction.startChild({\n description: `<${target.name}>`,\n op: ANGULAR_INIT_OP,\n });\n }\n if (originalOnInit) {\n return originalOnInit.apply(this, args);\n }\n };\n\n const originalAfterViewInit = target.prototype.ngAfterViewInit;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n target.prototype.ngAfterViewInit = function (...args: any[]): ReturnType<typeof originalAfterViewInit> {\n if (tracingSpan) {\n tracingSpan.finish();\n }\n if (originalAfterViewInit) {\n return originalAfterViewInit.apply(this, args);\n }\n };\n };\n /* eslint-enable @typescript-eslint/no-unsafe-member-access */\n}\n\n/**\n * Decorator function that can be used to capture a single lifecycle methods of the component.\n */\nexport function TraceMethodDecorator(): MethodDecorator {\n // eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/ban-types\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const originalMethod = descriptor.value;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n descriptor.value = function (...args: any[]): ReturnType<typeof originalMethod> {\n const now = timestampWithMs();\n const activeTransaction = getActiveTransaction();\n if (activeTransaction) {\n activeTransaction.startChild({\n description: `<${target.constructor.name}>`,\n endTimestamp: now,\n op: `${ANGULAR_OP}.${String(propertyKey)}`,\n startTimestamp: now,\n });\n }\n if (originalMethod) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n return originalMethod.apply(this, args);\n }\n };\n return descriptor;\n };\n}\n"]}
package/esm/flags.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ /** Flag that is true for debug builds, false otherwise. */
2
+ export declare const IS_DEBUG_BUILD: boolean;
3
+ //# sourceMappingURL=flags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flags.d.ts","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":"AAgBA,2DAA2D;AAC3D,eAAO,MAAM,cAAc,SAAoE,CAAC"}
package/esm/flags.js ADDED
@@ -0,0 +1,16 @@
1
+ /*
2
+ * This file defines flags and constants that can be modified during compile time in order to facilitate tree shaking
3
+ * for users.
4
+ *
5
+ * Debug flags need to be declared in each package individually and must not be imported across package boundaries,
6
+ * because some build tools have trouble tree-shaking imported guards.
7
+ *
8
+ * As a convention, we define debug flags in a `flags.ts` file in the root of a package's `src` folder.
9
+ *
10
+ * Debug flag files will contain "magic strings" like `__SENTRY_DEBUG__` that may get replaced with actual values during
11
+ * our, or the user's build process. Take care when introducing new flags - they must not throw if they are not
12
+ * replaced.
13
+ */
14
+ /** Flag that is true for debug builds, false otherwise. */
15
+ export var IS_DEBUG_BUILD = typeof __SENTRY_DEBUG__ === 'undefined' ? true : __SENTRY_DEBUG__;
16
+ //# sourceMappingURL=flags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flags.js","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,2DAA2D;AAC3D,MAAM,CAAC,IAAM,cAAc,GAAG,OAAO,gBAAgB,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC","sourcesContent":["/*\n * This file defines flags and constants that can be modified during compile time in order to facilitate tree shaking\n * for users.\n *\n * Debug flags need to be declared in each package individually and must not be imported across package boundaries,\n * because some build tools have trouble tree-shaking imported guards.\n *\n * As a convention, we define debug flags in a `flags.ts` file in the root of a package's `src` folder.\n *\n * Debug flag files will contain \"magic strings\" like `__SENTRY_DEBUG__` that may get replaced with actual values during\n * our, or the user's build process. Take care when introducing new flags - they must not throw if they are not\n * replaced.\n */\n\ndeclare const __SENTRY_DEBUG__: boolean;\n\n/** Flag that is true for debug builds, false otherwise. */\nexport const IS_DEBUG_BUILD = typeof __SENTRY_DEBUG__ === 'undefined' ? true : __SENTRY_DEBUG__;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"tracing.d.ts","sourceRoot":"","sources":["../src/tracing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA0C,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACzG,OAAO,EAAE,KAAK,EAAkC,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEhF,OAAO,EAAQ,WAAW,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEtE,OAAO,EAAE,UAAU,EAAgB,MAAM,MAAM,CAAC;AAYhD;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,sBAAsB,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,WAAW,GAAG,SAAS,EAChF,0BAA0B,GAAE,OAAc,EAC1C,gCAAgC,GAAE,OAAc,GAC/C,IAAI,CAWN;AAED,eAAO,MAAM,wBAAwB,+BAAyB,CAAC;AAE/D;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,WAAW,GAAG,SAAS,CAW9D;AAED;;;GAGG;AACH,qBACa,YAAa,YAAW,SAAS;IAwDzB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAvDpC,SAAS,EAAE,UAAU,CAAC,KAAK,CAAC,CAqCjC;IAEK,OAAO,EAAE,UAAU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,CAAC,KAAK,CAAC,CAqCjC;IAEK,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,CAW/B;IAEF,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,aAAa,CAAoC;gBAErB,OAAO,EAAE,MAAM;IAKnD;;;OAGG;IACI,WAAW,IAAI,IAAI;CAG3B;AAID;;GAEG;AACH,qBACa,cAAe,YAAW,MAAM,EAAE,aAAa;IACnC,aAAa,EAAE,MAAM,CAAqB;IAEjE,OAAO,CAAC,YAAY,CAAC,CAAO;IAE5B;;;OAGG;IACI,QAAQ,IAAI,IAAI;IAUvB;;;OAGG;IACI,eAAe,IAAI,IAAI;CAK/B;AAED;;GAEG;AACH,qBAIa,WAAW;CAAG;AAE3B;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,cAAc,CAiCpD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,eAAe,CAuBtD"}
package/esm/tracing.js CHANGED
@@ -2,10 +2,11 @@ import { __assign, __decorate } from "tslib";
2
2
  import { Directive, Injectable, Input, NgModule } from '@angular/core';
3
3
  import { NavigationEnd, NavigationStart } from '@angular/router';
4
4
  import { getCurrentHub } from '@sentry/browser';
5
- import { getGlobalObject, isDebugBuild, logger, stripUrlQueryAndFragment, timestampWithMs } from '@sentry/utils';
5
+ import { getGlobalObject, logger, stripUrlQueryAndFragment, timestampWithMs } from '@sentry/utils';
6
6
  import { Subscription } from 'rxjs';
7
7
  import { filter, tap } from 'rxjs/operators';
8
8
  import { ANGULAR_INIT_OP, ANGULAR_OP, ANGULAR_ROUTING_OP } from './constants';
9
+ import { IS_DEBUG_BUILD } from './flags';
9
10
  import { runOutsideAngular } from './zone';
10
11
  var instrumentationInitialized;
11
12
  var stashedStartTransaction;
@@ -51,7 +52,7 @@ var TraceService = /** @class */ (function () {
51
52
  this._router = _router;
52
53
  this.navStart$ = this._router.events.pipe(filter(function (event) { return event instanceof NavigationStart; }), tap(function (event) {
53
54
  if (!instrumentationInitialized) {
54
- isDebugBuild() &&
55
+ IS_DEBUG_BUILD &&
55
56
  logger.error('Angular integration has tracing enabled, but Tracing integration is not configured');
56
57
  return;
57
58
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tracing.js","sourceRoot":"","sources":["../src/tracing.ts"],"names":[],"mappings":";AAAA,OAAO,EAAiB,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAqB,MAAM,eAAe,CAAC;AACzG,OAAO,EAAS,aAAa,EAAE,eAAe,EAAU,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACjH,OAAO,EAAc,YAAY,EAAE,MAAM,MAAM,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAE3C,IAAI,0BAAmC,CAAC;AACxC,IAAI,uBAAiF,CAAC;AACtF,IAAI,uCAAgD,CAAC;AAErD,IAAM,MAAM,GAAG,eAAe,EAAU,CAAC;AAEzC;;GAEG;AACH,MAAM,UAAU,sBAAsB,CACpC,sBAAgF,EAChF,0BAA0C,EAC1C,gCAAgD;IADhD,2CAAA,EAAA,iCAA0C;IAC1C,iDAAA,EAAA,uCAAgD;IAEhD,0BAA0B,GAAG,IAAI,CAAC;IAClC,uBAAuB,GAAG,sBAAsB,CAAC;IACjD,uCAAuC,GAAG,gCAAgC,CAAC;IAE3E,IAAI,0BAA0B,IAAI,MAAM,IAAI,MAAM,CAAC,QAAQ,EAAE;QAC3D,sBAAsB,CAAC;YACrB,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ;YAC9B,EAA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,MAAM,CAAC,WAAW,CAAG;oBAC1C,cAAc,EAAE,GAAG;iBACpB,CAAC,CAAC;aACJ;YACD,IAAI,cAAc,EAAE;gBAClB,sEAAsE;gBACtE,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;aACzC;QACH,CAAC,CAAC;QACF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { AfterViewInit, Directive, Injectable, Input, NgModule, OnDestroy, OnInit } from '@angular/core';\nimport { Event, NavigationEnd, NavigationStart, Router } from '@angular/router';\nimport { getCurrentHub } from '@sentry/browser';\nimport { Span, Transaction, TransactionContext } from '@sentry/types';\nimport { getGlobalObject, isDebugBuild, logger, stripUrlQueryAndFragment, timestampWithMs } from '@sentry/utils';\nimport { Observable, Subscription } from 'rxjs';\nimport { filter, tap } from 'rxjs/operators';\n\nimport { ANGULAR_INIT_OP, ANGULAR_OP, ANGULAR_ROUTING_OP } from './constants';\nimport { runOutsideAngular } from './zone';\n\nlet instrumentationInitialized: boolean;\nlet stashedStartTransaction: (context: TransactionContext) => Transaction | undefined;\nlet stashedStartTransactionOnLocationChange: boolean;\n\nconst global = getGlobalObject<Window>();\n\n/**\n * Creates routing instrumentation for Angular Router.\n */\nexport function routingInstrumentation(\n customStartTransaction: (context: TransactionContext) => Transaction | undefined,\n startTransactionOnPageLoad: boolean = true,\n startTransactionOnLocationChange: boolean = true,\n): void {\n instrumentationInitialized = true;\n stashedStartTransaction = customStartTransaction;\n stashedStartTransactionOnLocationChange = startTransactionOnLocationChange;\n\n if (startTransactionOnPageLoad && global && global.location) {\n customStartTransaction({\n name: global.location.pathname,\n op: 'pageload',\n });\n }\n}\n\nexport const instrumentAngularRouting = routingInstrumentation;\n\n/**\n * Grabs active transaction off scope\n */\nexport function getActiveTransaction(): Transaction | undefined {\n const currentHub = getCurrentHub();\n\n if (currentHub) {\n const scope = currentHub.getScope();\n if (scope) {\n return scope.getTransaction();\n }\n }\n\n return undefined;\n}\n\n/**\n * Angular's Service responsible for hooking into Angular Router and tracking current navigation process.\n * Creates a new transaction for every route change and measures a duration of routing process.\n */\n@Injectable({ providedIn: 'root' })\nexport class TraceService implements OnDestroy {\n public navStart$: Observable<Event> = this._router.events.pipe(\n filter(event => event instanceof NavigationStart),\n tap(event => {\n if (!instrumentationInitialized) {\n isDebugBuild() &&\n logger.error('Angular integration has tracing enabled, but Tracing integration is not configured');\n return;\n }\n\n const navigationEvent = event as NavigationStart;\n const strippedUrl = stripUrlQueryAndFragment(navigationEvent.url);\n let activeTransaction = getActiveTransaction();\n\n if (!activeTransaction && stashedStartTransactionOnLocationChange) {\n activeTransaction = stashedStartTransaction({\n name: strippedUrl,\n op: 'navigation',\n });\n }\n\n if (activeTransaction) {\n if (this._routingSpan) {\n this._routingSpan.finish();\n }\n this._routingSpan = activeTransaction.startChild({\n description: `${navigationEvent.url}`,\n op: ANGULAR_ROUTING_OP,\n tags: {\n 'routing.instrumentation': '@sentry/angular',\n url: strippedUrl,\n ...(navigationEvent.navigationTrigger && {\n navigationTrigger: navigationEvent.navigationTrigger,\n }),\n },\n });\n }\n }),\n );\n\n public navEnd$: Observable<Event> = this._router.events.pipe(\n filter(event => event instanceof NavigationEnd),\n tap(() => {\n if (this._routingSpan) {\n runOutsideAngular(() => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this._routingSpan!.finish();\n });\n this._routingSpan = null;\n }\n }),\n );\n\n private _routingSpan: Span | null = null;\n private _subscription: Subscription = new Subscription();\n\n public constructor(private readonly _router: Router) {\n this._subscription.add(this.navStart$.subscribe());\n this._subscription.add(this.navEnd$.subscribe());\n }\n\n /**\n * This is used to prevent memory leaks when the root view is created and destroyed multiple times,\n * since `subscribe` callbacks capture `this` and prevent many resources from being GC'd.\n */\n public ngOnDestroy(): void {\n this._subscription.unsubscribe();\n }\n}\n\nconst UNKNOWN_COMPONENT = 'unknown';\n\n/**\n * A directive that can be used to capture initialization lifecycle of the whole component.\n */\n@Directive({ selector: '[trace]' })\nexport class TraceDirective implements OnInit, AfterViewInit {\n @Input('trace') public componentName: string = UNKNOWN_COMPONENT;\n\n private _tracingSpan?: Span;\n\n /**\n * Implementation of OnInit lifecycle method\n * @inheritdoc\n */\n public ngOnInit(): void {\n const activeTransaction = getActiveTransaction();\n if (activeTransaction) {\n this._tracingSpan = activeTransaction.startChild({\n description: `<${this.componentName}>`,\n op: ANGULAR_INIT_OP,\n });\n }\n }\n\n /**\n * Implementation of AfterViewInit lifecycle method\n * @inheritdoc\n */\n public ngAfterViewInit(): void {\n if (this._tracingSpan) {\n this._tracingSpan.finish();\n }\n }\n}\n\n/**\n * A module serves as a single compilation unit for the `TraceDirective` and can be re-used by any other module.\n */\n@NgModule({\n declarations: [TraceDirective],\n exports: [TraceDirective],\n})\nexport class TraceModule {}\n\n/**\n * Decorator function that can be used to capture initialization lifecycle of the whole component.\n */\nexport function TraceClassDecorator(): ClassDecorator {\n let tracingSpan: Span;\n\n /* eslint-disable @typescript-eslint/no-unsafe-member-access */\n // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n return target => {\n const originalOnInit = target.prototype.ngOnInit;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n target.prototype.ngOnInit = function (...args: any[]): ReturnType<typeof originalOnInit> {\n const activeTransaction = getActiveTransaction();\n if (activeTransaction) {\n tracingSpan = activeTransaction.startChild({\n description: `<${target.name}>`,\n op: ANGULAR_INIT_OP,\n });\n }\n if (originalOnInit) {\n return originalOnInit.apply(this, args);\n }\n };\n\n const originalAfterViewInit = target.prototype.ngAfterViewInit;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n target.prototype.ngAfterViewInit = function (...args: any[]): ReturnType<typeof originalAfterViewInit> {\n if (tracingSpan) {\n tracingSpan.finish();\n }\n if (originalAfterViewInit) {\n return originalAfterViewInit.apply(this, args);\n }\n };\n };\n /* eslint-enable @typescript-eslint/no-unsafe-member-access */\n}\n\n/**\n * Decorator function that can be used to capture a single lifecycle methods of the component.\n */\nexport function TraceMethodDecorator(): MethodDecorator {\n // eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/ban-types\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const originalMethod = descriptor.value;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n descriptor.value = function (...args: any[]): ReturnType<typeof originalMethod> {\n const now = timestampWithMs();\n const activeTransaction = getActiveTransaction();\n if (activeTransaction) {\n activeTransaction.startChild({\n description: `<${target.constructor.name}>`,\n endTimestamp: now,\n op: `${ANGULAR_OP}.${String(propertyKey)}`,\n startTimestamp: now,\n });\n }\n if (originalMethod) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n return originalMethod.apply(this, args);\n }\n };\n return descriptor;\n };\n}\n"]}
1
+ {"version":3,"file":"tracing.js","sourceRoot":"","sources":["../src/tracing.ts"],"names":[],"mappings":";AAAA,OAAO,EAAiB,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAqB,MAAM,eAAe,CAAC;AACzG,OAAO,EAAS,aAAa,EAAE,eAAe,EAAU,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACnG,OAAO,EAAc,YAAY,EAAE,MAAM,MAAM,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAE3C,IAAI,0BAAmC,CAAC;AACxC,IAAI,uBAAiF,CAAC;AACtF,IAAI,uCAAgD,CAAC;AAErD,IAAM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cAAc,GAAG,UAAU,CAAC,KAAK,CAAC;QACxC,8DAA8D;QAC9D,UAAU,CAAC,KAAK,GAAG;YAAU,cAAc;iBAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;gBAAd,yBAAc;;YACzC,IAAM,GAAG,GAAG,eAAe,EAAE,CAAC;YAC9B,IAAM,iBAAiB,GAAG,oBAAoB,EAAE,CAAC;YACjD,IAAI,iBAAiB,EAAE;gBACrB,iBAAiB,CAAC,UAAU,CAAC;oBAC3B,WAAW,EAAE,MAAI,MAAM,CAAC,WAAW,CAAC,IAAI,MAAG;oBAC3C,YAAY,EAAE,GAAG;oBACjB,EAAE,EAAK,UAAU,SAAI,MAAM,CAAC,WAAW,CAAG;oBAC1C,cAAc,EAAE,GAAG;iBACpB,CAAC,CAAC;aACJ;YACD,IAAI,cAAc,EAAE;gBAClB,sEAAsE;gBACtE,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;aACzC;QACH,CAAC,CAAC;QACF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { AfterViewInit, Directive, Injectable, Input, NgModule, OnDestroy, OnInit } from '@angular/core';\nimport { Event, NavigationEnd, NavigationStart, Router } from '@angular/router';\nimport { getCurrentHub } from '@sentry/browser';\nimport { Span, Transaction, TransactionContext } from '@sentry/types';\nimport { getGlobalObject, logger, stripUrlQueryAndFragment, timestampWithMs } from '@sentry/utils';\nimport { Observable, Subscription } from 'rxjs';\nimport { filter, tap } from 'rxjs/operators';\n\nimport { ANGULAR_INIT_OP, ANGULAR_OP, ANGULAR_ROUTING_OP } from './constants';\nimport { IS_DEBUG_BUILD } from './flags';\nimport { runOutsideAngular } from './zone';\n\nlet instrumentationInitialized: boolean;\nlet stashedStartTransaction: (context: TransactionContext) => Transaction | undefined;\nlet stashedStartTransactionOnLocationChange: boolean;\n\nconst global = getGlobalObject<Window>();\n\n/**\n * Creates routing instrumentation for Angular Router.\n */\nexport function routingInstrumentation(\n customStartTransaction: (context: TransactionContext) => Transaction | undefined,\n startTransactionOnPageLoad: boolean = true,\n startTransactionOnLocationChange: boolean = true,\n): void {\n instrumentationInitialized = true;\n stashedStartTransaction = customStartTransaction;\n stashedStartTransactionOnLocationChange = startTransactionOnLocationChange;\n\n if (startTransactionOnPageLoad && global && global.location) {\n customStartTransaction({\n name: global.location.pathname,\n op: 'pageload',\n });\n }\n}\n\nexport const instrumentAngularRouting = routingInstrumentation;\n\n/**\n * Grabs active transaction off scope\n */\nexport function getActiveTransaction(): Transaction | undefined {\n const currentHub = getCurrentHub();\n\n if (currentHub) {\n const scope = currentHub.getScope();\n if (scope) {\n return scope.getTransaction();\n }\n }\n\n return undefined;\n}\n\n/**\n * Angular's Service responsible for hooking into Angular Router and tracking current navigation process.\n * Creates a new transaction for every route change and measures a duration of routing process.\n */\n@Injectable({ providedIn: 'root' })\nexport class TraceService implements OnDestroy {\n public navStart$: Observable<Event> = this._router.events.pipe(\n filter(event => event instanceof NavigationStart),\n tap(event => {\n if (!instrumentationInitialized) {\n IS_DEBUG_BUILD &&\n logger.error('Angular integration has tracing enabled, but Tracing integration is not configured');\n return;\n }\n\n const navigationEvent = event as NavigationStart;\n const strippedUrl = stripUrlQueryAndFragment(navigationEvent.url);\n let activeTransaction = getActiveTransaction();\n\n if (!activeTransaction && stashedStartTransactionOnLocationChange) {\n activeTransaction = stashedStartTransaction({\n name: strippedUrl,\n op: 'navigation',\n });\n }\n\n if (activeTransaction) {\n if (this._routingSpan) {\n this._routingSpan.finish();\n }\n this._routingSpan = activeTransaction.startChild({\n description: `${navigationEvent.url}`,\n op: ANGULAR_ROUTING_OP,\n tags: {\n 'routing.instrumentation': '@sentry/angular',\n url: strippedUrl,\n ...(navigationEvent.navigationTrigger && {\n navigationTrigger: navigationEvent.navigationTrigger,\n }),\n },\n });\n }\n }),\n );\n\n public navEnd$: Observable<Event> = this._router.events.pipe(\n filter(event => event instanceof NavigationEnd),\n tap(() => {\n if (this._routingSpan) {\n runOutsideAngular(() => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this._routingSpan!.finish();\n });\n this._routingSpan = null;\n }\n }),\n );\n\n private _routingSpan: Span | null = null;\n private _subscription: Subscription = new Subscription();\n\n public constructor(private readonly _router: Router) {\n this._subscription.add(this.navStart$.subscribe());\n this._subscription.add(this.navEnd$.subscribe());\n }\n\n /**\n * This is used to prevent memory leaks when the root view is created and destroyed multiple times,\n * since `subscribe` callbacks capture `this` and prevent many resources from being GC'd.\n */\n public ngOnDestroy(): void {\n this._subscription.unsubscribe();\n }\n}\n\nconst UNKNOWN_COMPONENT = 'unknown';\n\n/**\n * A directive that can be used to capture initialization lifecycle of the whole component.\n */\n@Directive({ selector: '[trace]' })\nexport class TraceDirective implements OnInit, AfterViewInit {\n @Input('trace') public componentName: string = UNKNOWN_COMPONENT;\n\n private _tracingSpan?: Span;\n\n /**\n * Implementation of OnInit lifecycle method\n * @inheritdoc\n */\n public ngOnInit(): void {\n const activeTransaction = getActiveTransaction();\n if (activeTransaction) {\n this._tracingSpan = activeTransaction.startChild({\n description: `<${this.componentName}>`,\n op: ANGULAR_INIT_OP,\n });\n }\n }\n\n /**\n * Implementation of AfterViewInit lifecycle method\n * @inheritdoc\n */\n public ngAfterViewInit(): void {\n if (this._tracingSpan) {\n this._tracingSpan.finish();\n }\n }\n}\n\n/**\n * A module serves as a single compilation unit for the `TraceDirective` and can be re-used by any other module.\n */\n@NgModule({\n declarations: [TraceDirective],\n exports: [TraceDirective],\n})\nexport class TraceModule {}\n\n/**\n * Decorator function that can be used to capture initialization lifecycle of the whole component.\n */\nexport function TraceClassDecorator(): ClassDecorator {\n let tracingSpan: Span;\n\n /* eslint-disable @typescript-eslint/no-unsafe-member-access */\n // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n return target => {\n const originalOnInit = target.prototype.ngOnInit;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n target.prototype.ngOnInit = function (...args: any[]): ReturnType<typeof originalOnInit> {\n const activeTransaction = getActiveTransaction();\n if (activeTransaction) {\n tracingSpan = activeTransaction.startChild({\n description: `<${target.name}>`,\n op: ANGULAR_INIT_OP,\n });\n }\n if (originalOnInit) {\n return originalOnInit.apply(this, args);\n }\n };\n\n const originalAfterViewInit = target.prototype.ngAfterViewInit;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n target.prototype.ngAfterViewInit = function (...args: any[]): ReturnType<typeof originalAfterViewInit> {\n if (tracingSpan) {\n tracingSpan.finish();\n }\n if (originalAfterViewInit) {\n return originalAfterViewInit.apply(this, args);\n }\n };\n };\n /* eslint-enable @typescript-eslint/no-unsafe-member-access */\n}\n\n/**\n * Decorator function that can be used to capture a single lifecycle methods of the component.\n */\nexport function TraceMethodDecorator(): MethodDecorator {\n // eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/ban-types\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const originalMethod = descriptor.value;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n descriptor.value = function (...args: any[]): ReturnType<typeof originalMethod> {\n const now = timestampWithMs();\n const activeTransaction = getActiveTransaction();\n if (activeTransaction) {\n activeTransaction.startChild({\n description: `<${target.constructor.name}>`,\n endTimestamp: now,\n op: `${ANGULAR_OP}.${String(propertyKey)}`,\n startTimestamp: now,\n });\n }\n if (originalMethod) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n return originalMethod.apply(this, args);\n }\n };\n return descriptor;\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/angular",
3
- "version": "6.19.2",
3
+ "version": "6.19.5",
4
4
  "description": "Official Sentry SDK for Angular",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/angular",
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "main": "dist/index.js",
13
13
  "module": "esm/index.js",
14
- "types": "dist/index.d.ts",
14
+ "types": "build/types/index.d.ts",
15
15
  "publishConfig": {
16
16
  "access": "public"
17
17
  },
@@ -21,9 +21,9 @@
21
21
  "@angular/router": "10.x || 11.x || 12.x || 13.x"
22
22
  },
23
23
  "dependencies": {
24
- "@sentry/browser": "6.19.2",
25
- "@sentry/types": "6.19.2",
26
- "@sentry/utils": "6.19.2",
24
+ "@sentry/browser": "6.19.5",
25
+ "@sentry/types": "6.19.5",
26
+ "@sentry/utils": "6.19.5",
27
27
  "rxjs": "^6.6.0",
28
28
  "tslib": "^1.9.3"
29
29
  },
@@ -50,11 +50,11 @@
50
50
  "clean": "rimraf dist esm build coverage",
51
51
  "fix": "run-s fix:eslint fix:prettier",
52
52
  "fix:eslint": "eslint . --format stylish --fix",
53
- "fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
53
+ "fix:prettier": "prettier --write \"{src,test,scripts}/**/*.ts\"",
54
54
  "link:yarn": "yarn link",
55
55
  "lint": "run-s lint:prettier lint:eslint",
56
56
  "lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
57
- "lint:prettier": "prettier --check \"{src,test}/**/*.ts\""
57
+ "lint:prettier": "prettier --check \"{src,test,scripts}/**/*.ts\""
58
58
  },
59
59
  "volta": {
60
60
  "extends": "../../package.json"