@sentry/angular 8.0.0-alpha.3 → 8.0.0-alpha.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/angular",
3
- "version": "8.0.0-alpha.3",
3
+ "version": "8.0.0-alpha.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",
@@ -9,22 +9,22 @@
9
9
  "engines": {
10
10
  "node": ">=14.18"
11
11
  },
12
- "main": "bundles/sentry-angular.umd.js",
13
- "module": "fesm2015/sentry-angular.js",
12
+ "type": "module",
13
+ "module": "fesm2015/sentry-angular.mjs",
14
14
  "publishConfig": {
15
15
  "access": "public"
16
16
  },
17
17
  "peerDependencies": {
18
- "@angular/common": ">= 10.x <= 15.x",
19
- "@angular/core": ">= 10.x <= 15.x",
20
- "@angular/router": ">= 10.x <= 15.x",
18
+ "@angular/common": ">= 14.x <= 17.x",
19
+ "@angular/core": ">= 14.x <= 17.x",
20
+ "@angular/router": ">= 14.x <= 17.x",
21
21
  "rxjs": "^6.5.5 || ^7.x"
22
22
  },
23
23
  "dependencies": {
24
- "@sentry/browser": "8.0.0-alpha.3",
25
- "@sentry/core": "8.0.0-alpha.3",
26
- "@sentry/types": "8.0.0-alpha.3",
27
- "@sentry/utils": "8.0.0-alpha.3",
24
+ "@sentry/browser": "8.0.0-alpha.5",
25
+ "@sentry/core": "8.0.0-alpha.5",
26
+ "@sentry/types": "8.0.0-alpha.5",
27
+ "@sentry/utils": "8.0.0-alpha.5",
28
28
  "tslib": "^2.4.1"
29
29
  },
30
30
  "volta": {
@@ -47,9 +47,22 @@
47
47
  }
48
48
  }
49
49
  },
50
- "es2015": "fesm2015/sentry-angular.js",
51
- "esm2015": "esm2015/sentry-angular.js",
52
- "fesm2015": "fesm2015/sentry-angular.js",
53
- "typings": "sentry-angular.d.ts",
54
- "metadata": "sentry-angular.metadata.json"
55
- }
50
+ "es2020": "fesm2020/sentry-angular.mjs",
51
+ "esm2020": "esm2020/sentry-angular.mjs",
52
+ "fesm2020": "fesm2020/sentry-angular.mjs",
53
+ "fesm2015": "fesm2015/sentry-angular.mjs",
54
+ "typings": "index.d.ts",
55
+ "exports": {
56
+ "./package.json": {
57
+ "default": "./package.json"
58
+ },
59
+ ".": {
60
+ "types": "./index.d.ts",
61
+ "esm2020": "./esm2020/sentry-angular.mjs",
62
+ "es2020": "./fesm2020/sentry-angular.mjs",
63
+ "es2015": "./fesm2015/sentry-angular.mjs",
64
+ "node": "./fesm2015/sentry-angular.mjs",
65
+ "default": "./fesm2020/sentry-angular.mjs"
66
+ }
67
+ }
68
+ }
package/tracing.d.ts CHANGED
@@ -4,6 +4,7 @@ import { Router } from '@angular/router';
4
4
  import { browserTracingIntegration as originalBrowserTracingIntegration } from '@sentry/browser';
5
5
  import type { Integration, Span } from '@sentry/types';
6
6
  import type { Observable } from 'rxjs';
7
+ import * as i0 from "@angular/core";
7
8
  /**
8
9
  * A custom browser tracing integration for Angular.
9
10
  *
@@ -57,6 +58,8 @@ export declare class TraceService implements OnDestroy {
57
58
  * don't create a navigation root span
58
59
  */
59
60
  private _isPageloadOngoing;
61
+ static ɵfac: i0.ɵɵFactoryDeclaration<TraceService, never>;
62
+ static ɵprov: i0.ɵɵInjectableDeclaration<TraceService>;
60
63
  }
61
64
  /**
62
65
  * A directive that can be used to capture initialization lifecycle of the whole component.
@@ -74,11 +77,16 @@ export declare class TraceDirective implements OnInit, AfterViewInit {
74
77
  * @inheritdoc
75
78
  */
76
79
  ngAfterViewInit(): void;
80
+ static ɵfac: i0.ɵɵFactoryDeclaration<TraceDirective, never>;
81
+ static ɵdir: i0.ɵɵDirectiveDeclaration<TraceDirective, "[trace]", never, { "componentName": "trace"; }, {}, never, never, false>;
77
82
  }
78
83
  /**
79
84
  * A module serves as a single compilation unit for the `TraceDirective` and can be re-used by any other module.
80
85
  */
81
86
  export declare class TraceModule {
87
+ static ɵfac: i0.ɵɵFactoryDeclaration<TraceModule, never>;
88
+ static ɵmod: i0.ɵɵNgModuleDeclaration<TraceModule, [typeof TraceDirective], never, [typeof TraceDirective]>;
89
+ static ɵinj: i0.ɵɵInjectorDeclaration<TraceModule>;
82
90
  }
83
91
  interface TraceClassOptions {
84
92
  /**
@@ -1,555 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@sentry/browser'), require('@angular/core'), require('@sentry/core'), require('@sentry/utils'), require('@angular/common/http'), require('@angular/router'), require('rxjs'), require('rxjs/operators')) :
3
- typeof define === 'function' && define.amd ? define('@sentry/angular', ['exports', '@sentry/browser', '@angular/core', '@sentry/core', '@sentry/utils', '@angular/common/http', '@angular/router', 'rxjs', 'rxjs/operators'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.sentry = global.sentry || {}, global.sentry.angular = {}), global.Sentry, global.ng.core, global.Sentry.core, global.Sentry.util, global.ng.common.http, global.ng.router, global.rxjs, global.rxjs.operators));
5
- })(this, (function (exports, Sentry, i0, core, utils, http, i1, rxjs, operators) { 'use strict';
6
-
7
- function _interopNamespace(e) {
8
- if (e && e.__esModule) return e;
9
- var n = Object.create(null);
10
- if (e) {
11
- Object.keys(e).forEach(function (k) {
12
- if (k !== 'default') {
13
- var d = Object.getOwnPropertyDescriptor(e, k);
14
- Object.defineProperty(n, k, d.get ? d : {
15
- enumerable: true,
16
- get: function () { return e[k]; }
17
- });
18
- }
19
- });
20
- }
21
- n["default"] = e;
22
- return Object.freeze(n);
23
- }
24
-
25
- var Sentry__namespace = /*#__PURE__*/_interopNamespace(Sentry);
26
- var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
27
- var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
28
-
29
- /*
30
- * This file defines flags and constants that can be modified during compile time in order to facilitate tree shaking
31
- * for users.
32
- *
33
- * We define "magic strings" like `__SENTRY_DEBUG__` that may get replaced with actual values during our, or the user's
34
- * build process. Take care when introducing new flags - they must not throw if they are not replaced. See the Debug
35
- * Build Flags section in CONTRIBUTING.md.
36
- */
37
- /** Flag that is true for debug builds, false otherwise. */
38
- var IS_DEBUG_BUILD = typeof __SENTRY_DEBUG__ === 'undefined' ? true : __SENTRY_DEBUG__;
39
-
40
- /**
41
- * Inits the Angular SDK
42
- */
43
- function init(options) {
44
- var opts = Object.assign({
45
- // Filter out BrowserApiErrors integration as it interferes with our Angular `ErrorHandler`:
46
- // BrowserApiErrors would catch certain errors before they reach the `ErrorHandler` and thus provide a
47
- // lower fidelity error than what `SentryErrorHandler` (see errorhandler.ts) would provide.
48
- // see:
49
- // - https://github.com/getsentry/sentry-javascript/issues/5417#issuecomment-1453407097
50
- // - https://github.com/getsentry/sentry-javascript/issues/2744
51
- defaultIntegrations: Sentry.getDefaultIntegrations(options).filter(function (integration) {
52
- return integration.name !== 'BrowserApiErrors';
53
- })
54
- }, options);
55
- core.applySdkMetadata(opts, 'angular');
56
- checkAndSetAngularVersion();
57
- Sentry.init(opts);
58
- }
59
- function checkAndSetAngularVersion() {
60
- var ANGULAR_MINIMUM_VERSION = 10;
61
- var angularVersion = i0.VERSION && i0.VERSION.major ? parseInt(i0.VERSION.major, 10) : undefined;
62
- if (angularVersion) {
63
- if (angularVersion < ANGULAR_MINIMUM_VERSION) {
64
- IS_DEBUG_BUILD &&
65
- utils.logger.warn("The Sentry SDK does not officially support Angular " + angularVersion + ".", "This version of the Sentry SDK supports Angular " + ANGULAR_MINIMUM_VERSION + " and above.", 'Please consider upgrading your Angular version or downgrading the Sentry SDK.');
66
- }
67
- Sentry.setContext('angular', { version: angularVersion });
68
- }
69
- }
70
-
71
- // There're 2 types of Angular applications:
72
- // 1) zone-full (by default)
73
- // 2) zone-less
74
- // The developer can avoid importing the `zone.js` package and tells Angular that
75
- // he is responsible for running the change detection by himself. This is done by
76
- // "nooping" the zone through `CompilerOptions` when bootstrapping the root module.
77
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
78
- var isNgZoneEnabled = typeof Zone !== 'undefined' && !!Zone.current;
79
- /**
80
- * The function that does the same job as `NgZone.runOutsideAngular`.
81
- */
82
- function runOutsideAngular(callback) {
83
- // The `Zone.root.run` basically will run the `callback` in the most parent zone.
84
- // Any asynchronous API used inside the `callback` won't catch Angular's zone
85
- // since `Zone.current` will reference `Zone.root`.
86
- // The Angular's zone is forked from the `Zone.root`. In this case, `zone.js` won't
87
- // trigger change detection, and `ApplicationRef.tick()` will not be run.
88
- // Caretaker note: we're using `Zone.root` except `NgZone.runOutsideAngular` since this
89
- // will require injecting the `NgZone` facade. That will create a breaking change for
90
- // projects already using the `@sentry/angular`.
91
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
92
- return isNgZoneEnabled ? Zone.root.run(callback) : callback();
93
- }
94
-
95
- // https://github.com/angular/angular/blob/master/packages/core/src/util/errors.ts
96
- function tryToUnwrapZonejsError(error) {
97
- // TODO: once Angular14 is the minimum requirement ERROR_ORIGINAL_ERROR and
98
- // getOriginalError from error.ts can be used directly.
99
- return error && error.ngOriginalError
100
- ? error.ngOriginalError
101
- : error;
102
- }
103
- function extractHttpModuleError(error) {
104
- // The `error` property of http exception can be either an `Error` object, which we can use directly...
105
- if (isErrorOrErrorLikeObject(error.error)) {
106
- return error.error;
107
- }
108
- // ... or an`ErrorEvent`, which can provide us with the message but no stack...
109
- if (error.error instanceof ErrorEvent && error.error.message) {
110
- return error.error.message;
111
- }
112
- // ...or the request body itself, which we can use as a message instead.
113
- if (typeof error.error === 'string') {
114
- return "Server returned code " + error.status + " with body \"" + error.error + "\"";
115
- }
116
- // If we don't have any detailed information, fallback to the request message itself.
117
- return error.message;
118
- }
119
- function isErrorOrErrorLikeObject(value) {
120
- if (value instanceof Error) {
121
- return true;
122
- }
123
- if (value === null || typeof value !== 'object') {
124
- return false;
125
- }
126
- var candidate = value;
127
- return (utils.isString(candidate.name) &&
128
- utils.isString(candidate.message) &&
129
- (undefined === candidate.stack || utils.isString(candidate.stack)));
130
- }
131
- /**
132
- * Implementation of Angular's ErrorHandler provider that can be used as a drop-in replacement for the stock one.
133
- */
134
- var SentryErrorHandler = /** @class */ (function () {
135
- function SentryErrorHandler(options) {
136
- this._registeredAfterSendEventHandler = false;
137
- this._options = Object.assign({ logErrors: true }, options);
138
- }
139
- /**
140
- * Method called for every value captured through the ErrorHandler
141
- */
142
- SentryErrorHandler.prototype.handleError = function (error) {
143
- var _this = this;
144
- var extractedError = this._extractError(error) || 'Handled unknown error';
145
- // Capture handled exception and send it to Sentry.
146
- var eventId = runOutsideAngular(function () { return Sentry__namespace.captureException(extractedError, {
147
- mechanism: { type: 'angular', handled: false },
148
- }); });
149
- // When in development mode, log the error to console for immediate feedback.
150
- if (this._options.logErrors) {
151
- // eslint-disable-next-line no-console
152
- console.error(extractedError);
153
- }
154
- // Optionally show user dialog to provide details on what happened.
155
- if (this._options.showDialog) {
156
- var client = Sentry__namespace.getClient();
157
- if (client && !this._registeredAfterSendEventHandler) {
158
- client.on('afterSendEvent', function (event) {
159
- if (!event.type && event.event_id) {
160
- Sentry__namespace.showReportDialog(Object.assign(Object.assign({}, _this._options.dialogOptions), { eventId: event.event_id }));
161
- }
162
- });
163
- // We only want to register this hook once in the lifetime of the error handler
164
- this._registeredAfterSendEventHandler = true;
165
- }
166
- else if (!client) {
167
- Sentry__namespace.showReportDialog(Object.assign(Object.assign({}, this._options.dialogOptions), { eventId: eventId }));
168
- }
169
- }
170
- };
171
- /**
172
- * Used to pull a desired value that will be used to capture an event out of the raw value captured by ErrorHandler.
173
- */
174
- SentryErrorHandler.prototype._extractError = function (error) {
175
- // Allow custom overrides of extracting function
176
- if (this._options.extractor) {
177
- var defaultExtractor = this._defaultExtractor.bind(this);
178
- return this._options.extractor(error, defaultExtractor);
179
- }
180
- return this._defaultExtractor(error);
181
- };
182
- /**
183
- * Default implementation of error extraction that handles default error wrapping, HTTP responses, ErrorEvent and few other known cases.
184
- */
185
- SentryErrorHandler.prototype._defaultExtractor = function (errorCandidate) {
186
- var error = tryToUnwrapZonejsError(errorCandidate);
187
- // If it's http module error, extract as much information from it as we can.
188
- if (error instanceof http.HttpErrorResponse) {
189
- return extractHttpModuleError(error);
190
- }
191
- // We can handle messages and Error objects directly.
192
- if (typeof error === 'string' || isErrorOrErrorLikeObject(error)) {
193
- return error;
194
- }
195
- // Nothing was extracted, fallback to default error message.
196
- return null;
197
- };
198
- return SentryErrorHandler;
199
- }());
200
- SentryErrorHandler.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function SentryErrorHandler_Factory() { return new SentryErrorHandler(i0__namespace.ɵɵinject("errorHandlerOptions")); }, token: SentryErrorHandler, providedIn: "root" });
201
- SentryErrorHandler.decorators = [
202
- { type: i0.Injectable, args: [{ providedIn: 'root' },] }
203
- ];
204
- SentryErrorHandler.ctorParameters = function () { return [
205
- { type: undefined, decorators: [{ type: i0.Inject, args: ['errorHandlerOptions',] }] }
206
- ]; };
207
- /**
208
- * Factory function that creates an instance of a preconfigured ErrorHandler provider.
209
- */
210
- function createErrorHandler(config) {
211
- return new SentryErrorHandler(config);
212
- }
213
-
214
- var ANGULAR_ROUTING_OP = 'ui.angular.routing';
215
- var ANGULAR_INIT_OP = 'ui.angular.init';
216
- var ANGULAR_OP = 'ui.angular';
217
-
218
- var instrumentationInitialized;
219
- /**
220
- * A custom browser tracing integration for Angular.
221
- *
222
- * Use this integration in combination with `TraceService`
223
- */
224
- function browserTracingIntegration(options) {
225
- if (options === void 0) { options = {}; }
226
- // If the user opts out to set this up, we just don't initialize this.
227
- // That way, the TraceService will not actually do anything, functionally disabling this.
228
- if (options.instrumentNavigation !== false) {
229
- instrumentationInitialized = true;
230
- }
231
- return Sentry.browserTracingIntegration(Object.assign(Object.assign({}, options), { instrumentNavigation: false }));
232
- }
233
- /**
234
- * This function is extracted to make unit testing easier.
235
- */
236
- function _updateSpanAttributesForParametrizedUrl(route, span) {
237
- var attributes = (span && Sentry.spanToJSON(span).data) || {};
238
- if (span && attributes[Sentry.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] === 'url') {
239
- span.updateName(route);
240
- span.setAttribute(Sentry.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route');
241
- span.setAttribute(Sentry.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, "auto." + Sentry.spanToJSON(span).op + ".angular");
242
- }
243
- }
244
- /**
245
- * Angular's Service responsible for hooking into Angular Router and tracking current navigation process.
246
- * Creates a new transaction for every route change and measures a duration of routing process.
247
- */
248
- var TraceService = /** @class */ (function () {
249
- function TraceService(_router) {
250
- var _this = this;
251
- this._router = _router;
252
- this.navStart$ = this._router.events.pipe(operators.filter(function (event) { return event instanceof i1.NavigationStart; }), operators.tap(function (navigationEvent) {
253
- var _a, _b;
254
- if (!instrumentationInitialized) {
255
- IS_DEBUG_BUILD &&
256
- utils.logger.error('Angular integration has tracing enabled, but Tracing integration is not configured');
257
- return;
258
- }
259
- if (_this._routingSpan) {
260
- _this._routingSpan.end();
261
- _this._routingSpan = null;
262
- }
263
- var client = Sentry.getClient();
264
- var strippedUrl = utils.stripUrlQueryAndFragment(navigationEvent.url);
265
- if (client) {
266
- // see comment in `_isPageloadOngoing` for rationale
267
- if (!_this._isPageloadOngoing()) {
268
- Sentry.startBrowserTracingNavigationSpan(client, {
269
- name: strippedUrl,
270
- attributes: (_a = {},
271
- _a[Sentry.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] = 'auto.navigation.angular',
272
- _a[Sentry.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] = 'url',
273
- _a),
274
- });
275
- }
276
- else {
277
- // The first time we end up here, we set the pageload flag to false
278
- // Subsequent navigations are going to get their own navigation root span
279
- // even if the pageload root span is still ongoing.
280
- _this._pageloadOngoing = false;
281
- }
282
- _this._routingSpan =
283
- Sentry.startInactiveSpan({
284
- name: "" + navigationEvent.url,
285
- op: ANGULAR_ROUTING_OP,
286
- attributes: Object.assign((_b = {}, _b[Sentry.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] = 'auto.ui.angular', _b[Sentry.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] = 'url', _b.url = strippedUrl, _b), (navigationEvent.navigationTrigger && {
287
- navigationTrigger: navigationEvent.navigationTrigger,
288
- })),
289
- }) || null;
290
- return;
291
- }
292
- }));
293
- // The ResolveEnd event is fired when the Angular router has resolved the URL and
294
- // the parameter<->value mapping. It holds the new resolved router state with
295
- // the mapping and the new URL.
296
- // Only After this event, the route is activated, meaning that the transaction
297
- // can be updated with the parameterized route name before e.g. the route's root
298
- // component is initialized. This should be early enough before outgoing requests
299
- // are made from the new route, with the exceptions of requests being made during
300
- // a navigation.
301
- this.resEnd$ = this._router.events.pipe(operators.filter(function (event) { return event instanceof i1.ResolveEnd; }), operators.tap(function (event) {
302
- var route = getParameterizedRouteFromSnapshot(event.state.root);
303
- if (route) {
304
- Sentry.getCurrentScope().setTransactionName(route);
305
- }
306
- var activeSpan = Sentry.getActiveSpan();
307
- var rootSpan = activeSpan && Sentry.getRootSpan(activeSpan);
308
- _updateSpanAttributesForParametrizedUrl(route, rootSpan);
309
- }));
310
- this.navEnd$ = this._router.events.pipe(operators.filter(function (event) { return event instanceof i1.NavigationEnd || event instanceof i1.NavigationCancel || event instanceof i1.NavigationError; }), operators.tap(function () {
311
- if (_this._routingSpan) {
312
- runOutsideAngular(function () {
313
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
314
- _this._routingSpan.end();
315
- });
316
- _this._routingSpan = null;
317
- }
318
- }));
319
- this._routingSpan = null;
320
- this._pageloadOngoing = true;
321
- this._subscription = new rxjs.Subscription();
322
- this._subscription.add(this.navStart$.subscribe());
323
- this._subscription.add(this.resEnd$.subscribe());
324
- this._subscription.add(this.navEnd$.subscribe());
325
- }
326
- /**
327
- * This is used to prevent memory leaks when the root view is created and destroyed multiple times,
328
- * since `subscribe` callbacks capture `this` and prevent many resources from being GC'd.
329
- */
330
- TraceService.prototype.ngOnDestroy = function () {
331
- this._subscription.unsubscribe();
332
- };
333
- /**
334
- * We only _avoid_ creating a navigation root span in one case:
335
- *
336
- * There is an ongoing pageload span AND the router didn't yet emit the first navigation start event
337
- *
338
- * The first navigation start event will create the child routing span
339
- * and update the pageload root span name on ResolveEnd.
340
- *
341
- * There's an edge case we need to avoid here: If the router fires the first navigation start event
342
- * _after_ the pageload root span finished. This is why we check for the pageload root span.
343
- * Possible real-world scenario: Angular application and/or router is bootstrapped after the pageload
344
- * idle root span finished
345
- *
346
- * The overall rationale is:
347
- * - if we already avoided creating a navigation root span once, we don't avoid it again
348
- * (i.e. set `_pageloadOngoing` to `false`)
349
- * - if `_pageloadOngoing` is already `false`, create a navigation root span
350
- * - if there's no active/pageload root span, create a navigation root span
351
- * - only if there's an ongoing pageload root span AND `_pageloadOngoing` is still `true,
352
- * don't create a navigation root span
353
- */
354
- TraceService.prototype._isPageloadOngoing = function () {
355
- if (!this._pageloadOngoing) {
356
- // pageload is already finished, no need to update
357
- return false;
358
- }
359
- var activeSpan = Sentry.getActiveSpan();
360
- if (!activeSpan) {
361
- this._pageloadOngoing = false;
362
- return false;
363
- }
364
- var rootSpan = Sentry.getRootSpan(activeSpan);
365
- this._pageloadOngoing = Sentry.spanToJSON(rootSpan).op === 'pageload';
366
- return this._pageloadOngoing;
367
- };
368
- return TraceService;
369
- }());
370
- TraceService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function TraceService_Factory() { return new TraceService(i0__namespace.ɵɵinject(i1__namespace.Router)); }, token: TraceService, providedIn: "root" });
371
- TraceService.decorators = [
372
- { type: i0.Injectable, args: [{ providedIn: 'root' },] }
373
- ];
374
- TraceService.ctorParameters = function () { return [
375
- { type: i1.Router }
376
- ]; };
377
- var UNKNOWN_COMPONENT = 'unknown';
378
- /**
379
- * A directive that can be used to capture initialization lifecycle of the whole component.
380
- */
381
- var TraceDirective = /** @class */ (function () {
382
- function TraceDirective() {
383
- }
384
- /**
385
- * Implementation of OnInit lifecycle method
386
- * @inheritdoc
387
- */
388
- TraceDirective.prototype.ngOnInit = function () {
389
- var _a;
390
- if (!this.componentName) {
391
- this.componentName = UNKNOWN_COMPONENT;
392
- }
393
- if (Sentry.getActiveSpan()) {
394
- this._tracingSpan = Sentry.startInactiveSpan({
395
- name: "<" + this.componentName + ">",
396
- op: ANGULAR_INIT_OP,
397
- attributes: (_a = {}, _a[Sentry.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] = 'auto.ui.angular.trace_directive', _a),
398
- });
399
- }
400
- };
401
- /**
402
- * Implementation of AfterViewInit lifecycle method
403
- * @inheritdoc
404
- */
405
- TraceDirective.prototype.ngAfterViewInit = function () {
406
- if (this._tracingSpan) {
407
- this._tracingSpan.end();
408
- }
409
- };
410
- return TraceDirective;
411
- }());
412
- TraceDirective.decorators = [
413
- { type: i0.Directive, args: [{ selector: '[trace]' },] }
414
- ];
415
- TraceDirective.propDecorators = {
416
- componentName: [{ type: i0.Input, args: ['trace',] }]
417
- };
418
- /**
419
- * A module serves as a single compilation unit for the `TraceDirective` and can be re-used by any other module.
420
- */
421
- var TraceModule = /** @class */ (function () {
422
- function TraceModule() {
423
- }
424
- return TraceModule;
425
- }());
426
- TraceModule.decorators = [
427
- { type: i0.NgModule, args: [{
428
- declarations: [TraceDirective],
429
- exports: [TraceDirective],
430
- },] }
431
- ];
432
- /**
433
- * Decorator function that can be used to capture initialization lifecycle of the whole component.
434
- */
435
- function TraceClass(options) {
436
- var tracingSpan;
437
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
438
- return function (target) {
439
- var originalOnInit = target.prototype.ngOnInit;
440
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
441
- target.prototype.ngOnInit = function () {
442
- var _a;
443
- var args = [];
444
- for (var _i = 0; _i < arguments.length; _i++) {
445
- args[_i] = arguments[_i];
446
- }
447
- tracingSpan = Sentry.startInactiveSpan({
448
- onlyIfParent: true,
449
- name: "<" + (options && options.name ? options.name : 'unnamed') + ">",
450
- op: ANGULAR_INIT_OP,
451
- attributes: (_a = {},
452
- _a[Sentry.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] = 'auto.ui.angular.trace_class_decorator',
453
- _a),
454
- });
455
- if (originalOnInit) {
456
- return originalOnInit.apply(this, args);
457
- }
458
- };
459
- var originalAfterViewInit = target.prototype.ngAfterViewInit;
460
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
461
- target.prototype.ngAfterViewInit = function () {
462
- var args = [];
463
- for (var _i = 0; _i < arguments.length; _i++) {
464
- args[_i] = arguments[_i];
465
- }
466
- if (tracingSpan) {
467
- tracingSpan.end();
468
- }
469
- if (originalAfterViewInit) {
470
- return originalAfterViewInit.apply(this, args);
471
- }
472
- };
473
- };
474
- /* eslint-enable @typescript-eslint/no-unsafe-member-access */
475
- }
476
- /**
477
- * Decorator function that can be used to capture a single lifecycle methods of the component.
478
- */
479
- function TraceMethod(options) {
480
- // eslint-disable-next-line @typescript-eslint/ban-types
481
- return function (target, propertyKey, descriptor) {
482
- var originalMethod = descriptor.value;
483
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
484
- descriptor.value = function () {
485
- var _a;
486
- var args = [];
487
- for (var _i = 0; _i < arguments.length; _i++) {
488
- args[_i] = arguments[_i];
489
- }
490
- var now = utils.timestampInSeconds();
491
- Sentry.startInactiveSpan({
492
- onlyIfParent: true,
493
- name: "<" + (options && options.name ? options.name : 'unnamed') + ">",
494
- op: ANGULAR_OP + "." + String(propertyKey),
495
- startTime: now,
496
- attributes: (_a = {},
497
- _a[Sentry.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] = 'auto.ui.angular.trace_method_decorator',
498
- _a),
499
- }).end(now);
500
- if (originalMethod) {
501
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
502
- return originalMethod.apply(this, args);
503
- }
504
- };
505
- return descriptor;
506
- };
507
- }
508
- /**
509
- * Takes the parameterized route from a given ActivatedRouteSnapshot and concatenates the snapshot's
510
- * child route with its parent to produce the complete parameterized URL of the activated route.
511
- * This happens recursively until the last child (i.e. the end of the URL) is reached.
512
- *
513
- * @param route the ActivatedRouteSnapshot of which its path and its child's path is concatenated
514
- *
515
- * @returns the concatenated parameterized route string
516
- */
517
- function getParameterizedRouteFromSnapshot(route) {
518
- var parts = [];
519
- var currentRoute = route && route.firstChild;
520
- while (currentRoute) {
521
- var path = currentRoute && currentRoute.routeConfig && currentRoute.routeConfig.path;
522
- if (path === null || path === undefined) {
523
- break;
524
- }
525
- parts.push(path);
526
- currentRoute = currentRoute.firstChild;
527
- }
528
- var fullPath = parts.filter(function (part) { return part; }).join('/');
529
- return fullPath ? "/" + fullPath + "/" : '/';
530
- }
531
-
532
- /**
533
- * Generated bundle index. Do not edit.
534
- */
535
-
536
- exports.SentryErrorHandler = SentryErrorHandler;
537
- exports.TraceClass = TraceClass;
538
- exports.TraceDirective = TraceDirective;
539
- exports.TraceMethod = TraceMethod;
540
- exports.TraceModule = TraceModule;
541
- exports.TraceService = TraceService;
542
- exports.browserTracingIntegration = browserTracingIntegration;
543
- exports.createErrorHandler = createErrorHandler;
544
- exports.init = init;
545
- Object.keys(Sentry).forEach(function (k) {
546
- if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
547
- enumerable: true,
548
- get: function () { return Sentry[k]; }
549
- });
550
- });
551
-
552
- Object.defineProperty(exports, '__esModule', { value: true });
553
-
554
- }));
555
- //# sourceMappingURL=sentry-angular.umd.js.map