@sentry/angular 7.0.0-alpha.0 → 7.0.0-beta.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.
Files changed (96) hide show
  1. package/README.md +6 -3
  2. package/bundles/sentry-angular.umd.js +442 -0
  3. package/bundles/sentry-angular.umd.js.map +1 -0
  4. package/bundles/sentry-angular.umd.min.js +2 -0
  5. package/bundles/sentry-angular.umd.min.js.map +1 -0
  6. package/{build/types/constants.d.ts → constants.d.ts} +4 -0
  7. package/constants.d.ts.map +1 -0
  8. package/{build/types/errorhandler.d.ts → errorhandler.d.ts} +0 -0
  9. package/errorhandler.d.ts.map +1 -0
  10. package/esm2015/constants.js +8 -0
  11. package/esm2015/errorhandler.js +90 -0
  12. package/esm2015/flags.js +16 -0
  13. package/esm2015/index.js +9 -0
  14. package/esm2015/sdk.js +33 -0
  15. package/esm2015/sentry-angular.js +5 -0
  16. package/esm2015/tracing.js +218 -0
  17. package/esm2015/zone.js +24 -0
  18. package/fesm2015/sentry-angular.js +385 -0
  19. package/fesm2015/sentry-angular.js.map +1 -0
  20. package/{build/types/flags.d.ts → flags.d.ts} +0 -0
  21. package/flags.d.ts.map +1 -0
  22. package/{build/types/index.d.ts → index.d.ts} +2 -1
  23. package/index.d.ts.map +1 -0
  24. package/package.json +15 -40
  25. package/{build/types/sdk.d.ts → sdk.d.ts} +0 -0
  26. package/sdk.d.ts.map +1 -0
  27. package/sentry-angular.d.ts +5 -0
  28. package/sentry-angular.d.ts.map +1 -0
  29. package/sentry-angular.metadata.json +1 -0
  30. package/{build/types/tracing.d.ts → tracing.d.ts} +0 -0
  31. package/tracing.d.ts.map +1 -0
  32. package/{build/types/zone.d.ts → zone.d.ts} +0 -0
  33. package/zone.d.ts.map +1 -0
  34. package/build/types/constants.d.ts.map +0 -1
  35. package/build/types/errorhandler.d.ts.map +0 -1
  36. package/build/types/flags.d.ts.map +0 -1
  37. package/build/types/index.d.ts.map +0 -1
  38. package/build/types/sdk.d.ts.map +0 -1
  39. package/build/types/tracing.d.ts.map +0 -1
  40. package/build/types/zone.d.ts.map +0 -1
  41. package/cjs/constants.d.ts +0 -4
  42. package/cjs/constants.d.ts.map +0 -1
  43. package/cjs/constants.js +0 -5
  44. package/cjs/constants.js.map +0 -1
  45. package/cjs/errorhandler.d.ts +0 -41
  46. package/cjs/errorhandler.d.ts.map +0 -1
  47. package/cjs/errorhandler.js +0 -89
  48. package/cjs/errorhandler.js.map +0 -1
  49. package/cjs/flags.d.ts +0 -3
  50. package/cjs/flags.d.ts.map +0 -1
  51. package/cjs/flags.js +0 -17
  52. package/cjs/flags.js.map +0 -1
  53. package/cjs/index.d.ts +0 -7
  54. package/cjs/index.d.ts.map +0 -1
  55. package/cjs/index.js +0 -19
  56. package/cjs/index.js.map +0 -1
  57. package/cjs/sdk.d.ts +0 -6
  58. package/cjs/sdk.d.ts.map +0 -1
  59. package/cjs/sdk.js +0 -21
  60. package/cjs/sdk.js.map +0 -1
  61. package/cjs/tracing.d.ts +0 -61
  62. package/cjs/tracing.d.ts.map +0 -1
  63. package/cjs/tracing.js +0 -241
  64. package/cjs/tracing.js.map +0 -1
  65. package/cjs/zone.d.ts +0 -5
  66. package/cjs/zone.d.ts.map +0 -1
  67. package/cjs/zone.js +0 -26
  68. package/cjs/zone.js.map +0 -1
  69. package/esm/constants.d.ts +0 -4
  70. package/esm/constants.d.ts.map +0 -1
  71. package/esm/constants.js +0 -4
  72. package/esm/constants.js.map +0 -1
  73. package/esm/errorhandler.d.ts +0 -41
  74. package/esm/errorhandler.d.ts.map +0 -1
  75. package/esm/errorhandler.js +0 -87
  76. package/esm/errorhandler.js.map +0 -1
  77. package/esm/flags.d.ts +0 -3
  78. package/esm/flags.d.ts.map +0 -1
  79. package/esm/flags.js +0 -16
  80. package/esm/flags.js.map +0 -1
  81. package/esm/index.d.ts +0 -7
  82. package/esm/index.d.ts.map +0 -1
  83. package/esm/index.js +0 -9
  84. package/esm/index.js.map +0 -1
  85. package/esm/sdk.d.ts +0 -6
  86. package/esm/sdk.d.ts.map +0 -1
  87. package/esm/sdk.js +0 -19
  88. package/esm/sdk.js.map +0 -1
  89. package/esm/tracing.d.ts +0 -61
  90. package/esm/tracing.d.ts.map +0 -1
  91. package/esm/tracing.js +0 -236
  92. package/esm/tracing.js.map +0 -1
  93. package/esm/zone.d.ts +0 -5
  94. package/esm/zone.d.ts.map +0 -1
  95. package/esm/zone.js +0 -24
  96. package/esm/zone.js.map +0 -1
package/cjs/zone.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"zone.js","sourceRoot":"","sources":["../src/zone.ts"],"names":[],"mappings":";AAIA,4CAA4C;AAC5C,4BAA4B;AAC5B,eAAe;AACf,iFAAiF;AACjF,iFAAiF;AACjF,mFAAmF;AACnF,sEAAsE;AACtE,IAAM,eAAe,GAAG,OAAO,IAAI,KAAK,WAAW,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;AAEtE;;GAEG;AACH,SAAgB,iBAAiB,CAAI,QAAiB;IACpD,iFAAiF;IACjF,6EAA6E;IAC7E,mDAAmD;IACnD,mFAAmF;IACnF,yEAAyE;IACzE,uFAAuF;IACvF,qFAAqF;IACrF,gDAAgD;IAChD,sEAAsE;IACtE,OAAO,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;AAChE,CAAC;AAXD,8CAWC","sourcesContent":["// That's the `global.Zone` exposed when the `zone.js` package is used.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ndeclare const Zone: any;\n\n// There're 2 types of Angular applications:\n// 1) zone-full (by default)\n// 2) zone-less\n// The developer can avoid importing the `zone.js` package and tells Angular that\n// he is responsible for running the change detection by himself. This is done by\n// \"nooping\" the zone through `CompilerOptions` when bootstrapping the root module.\n// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\nconst isNgZoneEnabled = typeof Zone !== 'undefined' && !!Zone.current;\n\n/**\n * The function that does the same job as `NgZone.runOutsideAngular`.\n */\nexport function runOutsideAngular<T>(callback: () => T): T {\n // The `Zone.root.run` basically will run the `callback` in the most parent zone.\n // Any asynchronous API used inside the `callback` won't catch Angular's zone\n // since `Zone.current` will reference `Zone.root`.\n // The Angular's zone is forked from the `Zone.root`. In this case, `zone.js` won't\n // trigger change detection, and `ApplicationRef.tick()` will not be run.\n // Caretaker note: we're using `Zone.root` except `NgZone.runOutsideAngular` since this\n // will require injecting the `NgZone` facade. That will create a breaking change for\n // projects already using the `@sentry/angular`.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n return isNgZoneEnabled ? Zone.root.run(callback) : callback();\n}\n"]}
@@ -1,4 +0,0 @@
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
@@ -1 +0,0 @@
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"}
package/esm/constants.js DELETED
@@ -1,4 +0,0 @@
1
- export var ANGULAR_ROUTING_OP = 'ui.angular.routing';
2
- export var ANGULAR_INIT_OP = 'ui.angular.init';
3
- export var ANGULAR_OP = 'ui.angular';
4
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,kBAAkB,GAAG,oBAAoB,CAAC;AAEvD,MAAM,CAAC,IAAM,eAAe,GAAG,iBAAiB,CAAC;AAEjD,MAAM,CAAC,IAAM,UAAU,GAAG,YAAY,CAAC","sourcesContent":["export const ANGULAR_ROUTING_OP = 'ui.angular.routing';\n\nexport const ANGULAR_INIT_OP = 'ui.angular.init';\n\nexport const ANGULAR_OP = 'ui.angular';\n"]}
@@ -1,41 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,87 +0,0 @@
1
- import { __assign, __decorate } from "tslib";
2
- import { HttpErrorResponse } from '@angular/common/http';
3
- import { Injectable } from '@angular/core';
4
- import * as Sentry from '@sentry/browser';
5
- import { runOutsideAngular } from './zone';
6
- /**
7
- * Implementation of Angular's ErrorHandler provider that can be used as a drop-in replacement for the stock one.
8
- */
9
- var SentryErrorHandler = /** @class */ (function () {
10
- function SentryErrorHandler(options) {
11
- this._options = __assign({ logErrors: true }, options);
12
- }
13
- /**
14
- * Method called for every value captured through the ErrorHandler
15
- */
16
- SentryErrorHandler.prototype.handleError = function (error) {
17
- var extractedError = this._extractError(error) || 'Handled unknown error';
18
- // Capture handled exception and send it to Sentry.
19
- var eventId = runOutsideAngular(function () { return Sentry.captureException(extractedError); });
20
- // When in development mode, log the error to console for immediate feedback.
21
- if (this._options.logErrors) {
22
- // eslint-disable-next-line no-console
23
- console.error(extractedError);
24
- }
25
- // Optionally show user dialog to provide details on what happened.
26
- if (this._options.showDialog) {
27
- Sentry.showReportDialog(__assign(__assign({}, this._options.dialogOptions), { eventId: eventId }));
28
- }
29
- };
30
- /**
31
- * Used to pull a desired value that will be used to capture an event out of the raw value captured by ErrorHandler.
32
- */
33
- SentryErrorHandler.prototype._extractError = function (error) {
34
- // Allow custom overrides of extracting function
35
- if (this._options.extractor) {
36
- var defaultExtractor = this._defaultExtractor.bind(this);
37
- return this._options.extractor(error, defaultExtractor);
38
- }
39
- return this._defaultExtractor(error);
40
- };
41
- /**
42
- * Default implementation of error extraction that handles default error wrapping, HTTP responses, ErrorEvent and few other known cases.
43
- */
44
- SentryErrorHandler.prototype._defaultExtractor = function (errorCandidate) {
45
- var error = errorCandidate;
46
- // Try to unwrap zone.js error.
47
- // https://github.com/angular/angular/blob/master/packages/core/src/util/errors.ts
48
- if (error && error.ngOriginalError) {
49
- error = error.ngOriginalError;
50
- }
51
- // We can handle messages and Error objects directly.
52
- if (typeof error === 'string' || error instanceof Error) {
53
- return error;
54
- }
55
- // If it's http module error, extract as much information from it as we can.
56
- if (error instanceof HttpErrorResponse) {
57
- // The `error` property of http exception can be either an `Error` object, which we can use directly...
58
- if (error.error instanceof Error) {
59
- return error.error;
60
- }
61
- // ... or an`ErrorEvent`, which can provide us with the message but no stack...
62
- if (error.error instanceof ErrorEvent && error.error.message) {
63
- return error.error.message;
64
- }
65
- // ...or the request body itself, which we can use as a message instead.
66
- if (typeof error.error === 'string') {
67
- return "Server returned code " + error.status + " with body \"" + error.error + "\"";
68
- }
69
- // If we don't have any detailed information, fallback to the request message itself.
70
- return error.message;
71
- }
72
- // Nothing was extracted, fallback to default error message.
73
- return null;
74
- };
75
- SentryErrorHandler = __decorate([
76
- Injectable({ providedIn: 'root' })
77
- ], SentryErrorHandler);
78
- return SentryErrorHandler;
79
- }());
80
- /**
81
- * Factory function that creates an instance of a preconfigured ErrorHandler provider.
82
- */
83
- function createErrorHandler(config) {
84
- return new SentryErrorHandler(config);
85
- }
86
- export { createErrorHandler, SentryErrorHandler };
87
- //# sourceMappingURL=errorhandler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errorhandler.js","sourceRoot":"","sources":["../src/errorhandler.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAuC,UAAU,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAiB3C;;GAEG;AAEH;IAGE,4BAAmB,OAA6B;QAC9C,IAAI,CAAC,QAAQ,cACX,SAAS,EAAE,IAAI,IACZ,OAAO,CACX,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,wCAAW,GAAlB,UAAmB,KAAc;QAC/B,IAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,uBAAuB,CAAC;QAE5E,mDAAmD;QACnD,IAAM,OAAO,GAAG,iBAAiB,CAAC,cAAM,OAAA,MAAM,CAAC,gBAAgB,CAAC,cAAc,CAAC,EAAvC,CAAuC,CAAC,CAAC;QAEjF,6EAA6E;QAC7E,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE;YAC3B,sCAAsC;YACtC,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;SAC/B;QAED,mEAAmE;QACnE,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE;YAC5B,MAAM,CAAC,gBAAgB,uBAAM,IAAI,CAAC,QAAQ,CAAC,aAAa,KAAE,OAAO,SAAA,IAAG,CAAC;SACtE;IACH,CAAC;IAED;;OAEG;IACO,0C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kBAAkB;QADvB,UAAU,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;OAC7B,kBAAkB,CAqFvB;IAAD,yBAAC;CAAA,AArFD,IAqFC;AAED;;GAEG;AACH,SAAS,kBAAkB,CAAC,MAA4B;IACtD,OAAO,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC;AACxC,CAAC;AAED,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["import { HttpErrorResponse } from '@angular/common/http';\nimport { ErrorHandler as AngularErrorHandler, Injectable } from '@angular/core';\nimport * as Sentry from '@sentry/browser';\n\nimport { runOutsideAngular } from './zone';\n\n/**\n * Options used to configure the behavior of the Angular ErrorHandler.\n */\nexport interface ErrorHandlerOptions {\n logErrors?: boolean;\n showDialog?: boolean;\n dialogOptions?: Sentry.ReportDialogOptions;\n /**\n * Custom implementation of error extraction from the raw value captured by the Angular.\n * @param error Value captured by Angular's ErrorHandler provider\n * @param defaultExtractor Default implementation that can be used as the fallback in case of custom implementation\n */\n extractor?(error: unknown, defaultExtractor: (error: unknown) => unknown): unknown;\n}\n\n/**\n * Implementation of Angular's ErrorHandler provider that can be used as a drop-in replacement for the stock one.\n */\n@Injectable({ providedIn: 'root' })\nclass SentryErrorHandler implements AngularErrorHandler {\n protected readonly _options: ErrorHandlerOptions;\n\n public constructor(options?: ErrorHandlerOptions) {\n this._options = {\n logErrors: true,\n ...options,\n };\n }\n\n /**\n * Method called for every value captured through the ErrorHandler\n */\n public handleError(error: unknown): void {\n const extractedError = this._extractError(error) || 'Handled unknown error';\n\n // Capture handled exception and send it to Sentry.\n const eventId = runOutsideAngular(() => Sentry.captureException(extractedError));\n\n // When in development mode, log the error to console for immediate feedback.\n if (this._options.logErrors) {\n // eslint-disable-next-line no-console\n console.error(extractedError);\n }\n\n // Optionally show user dialog to provide details on what happened.\n if (this._options.showDialog) {\n Sentry.showReportDialog({ ...this._options.dialogOptions, eventId });\n }\n }\n\n /**\n * Used to pull a desired value that will be used to capture an event out of the raw value captured by ErrorHandler.\n */\n protected _extractError(error: unknown): unknown {\n // Allow custom overrides of extracting function\n if (this._options.extractor) {\n const defaultExtractor = this._defaultExtractor.bind(this);\n return this._options.extractor(error, defaultExtractor);\n }\n\n return this._defaultExtractor(error);\n }\n\n /**\n * Default implementation of error extraction that handles default error wrapping, HTTP responses, ErrorEvent and few other known cases.\n */\n protected _defaultExtractor(errorCandidate: unknown): unknown {\n let error = errorCandidate;\n\n // Try to unwrap zone.js error.\n // https://github.com/angular/angular/blob/master/packages/core/src/util/errors.ts\n if (error && (error as { ngOriginalError: Error }).ngOriginalError) {\n error = (error as { ngOriginalError: Error }).ngOriginalError;\n }\n\n // We can handle messages and Error objects directly.\n if (typeof error === 'string' || error instanceof Error) {\n return error;\n }\n\n // If it's http module error, extract as much information from it as we can.\n if (error instanceof HttpErrorResponse) {\n // The `error` property of http exception can be either an `Error` object, which we can use directly...\n if (error.error instanceof Error) {\n return error.error;\n }\n\n // ... or an`ErrorEvent`, which can provide us with the message but no stack...\n if (error.error instanceof ErrorEvent && error.error.message) {\n return error.error.message;\n }\n\n // ...or the request body itself, which we can use as a message instead.\n if (typeof error.error === 'string') {\n return `Server returned code ${error.status} with body \"${error.error}\"`;\n }\n\n // If we don't have any detailed information, fallback to the request message itself.\n return error.message;\n }\n\n // Nothing was extracted, fallback to default error message.\n return null;\n }\n}\n\n/**\n * Factory function that creates an instance of a preconfigured ErrorHandler provider.\n */\nfunction createErrorHandler(config?: ErrorHandlerOptions): SentryErrorHandler {\n return new SentryErrorHandler(config);\n}\n\nexport { createErrorHandler, SentryErrorHandler };\n"]}
package/esm/flags.d.ts DELETED
@@ -1,3 +0,0 @@
1
- /** Flag that is true for debug builds, false otherwise. */
2
- export declare const IS_DEBUG_BUILD: boolean;
3
- //# sourceMappingURL=flags.d.ts.map
@@ -1 +0,0 @@
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 DELETED
@@ -1,16 +0,0 @@
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
package/esm/flags.js.map DELETED
@@ -1 +0,0 @@
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"]}
package/esm/index.d.ts DELETED
@@ -1,7 +0,0 @@
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
@@ -1 +0,0 @@
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"}
package/esm/index.js DELETED
@@ -1,9 +0,0 @@
1
- export * from '@sentry/browser';
2
- export { init } from './sdk';
3
- export { createErrorHandler, SentryErrorHandler } from './errorhandler';
4
- export { getActiveTransaction,
5
- // TODO `instrumentAngularRouting` is just an alias for `routingInstrumentation`; deprecate the latter at some point
6
- instrumentAngularRouting, // new name
7
- routingInstrumentation, // legacy name
8
- TraceClassDecorator, TraceMethodDecorator, TraceDirective, TraceModule, TraceService, } from './tracing';
9
- //# sourceMappingURL=index.js.map
package/esm/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAuB,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAC7F,OAAO,EACL,oBAAoB;AACpB,oHAAoH;AACpH,wBAAwB,EAAE,WAAW;AACrC,sBAAsB,EAAE,cAAc;AACtC,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,YAAY,GACb,MAAM,WAAW,CAAC","sourcesContent":["export * from '@sentry/browser';\n\nexport { init } from './sdk';\nexport { createErrorHandler, ErrorHandlerOptions, SentryErrorHandler } from './errorhandler';\nexport {\n getActiveTransaction,\n // TODO `instrumentAngularRouting` is just an alias for `routingInstrumentation`; deprecate the latter at some point\n instrumentAngularRouting, // new name\n routingInstrumentation, // legacy name\n TraceClassDecorator,\n TraceMethodDecorator,\n TraceDirective,\n TraceModule,\n TraceService,\n} from './tracing';\n"]}
package/esm/sdk.d.ts DELETED
@@ -1,6 +0,0 @@
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
package/esm/sdk.d.ts.map DELETED
@@ -1 +0,0 @@
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"}
package/esm/sdk.js DELETED
@@ -1,19 +0,0 @@
1
- import { init as browserInit, SDK_VERSION } from '@sentry/browser';
2
- /**
3
- * Inits the Angular SDK
4
- */
5
- export function init(options) {
6
- options._metadata = options._metadata || {};
7
- options._metadata.sdk = {
8
- name: 'sentry.javascript.angular',
9
- packages: [
10
- {
11
- name: 'npm:@sentry/angular',
12
- version: SDK_VERSION,
13
- },
14
- ],
15
- version: SDK_VERSION,
16
- };
17
- browserInit(options);
18
- }
19
- //# sourceMappingURL=sdk.js.map
package/esm/sdk.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,IAAI,IAAI,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnF;;GAEG;AACH,MAAM,UAAU,IAAI,CAAC,OAAuB;IAC1C,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC;IAC5C,OAAO,CAAC,SAAS,CAAC,GAAG,GAAG;QACtB,IAAI,EAAE,2BAA2B;QACjC,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,qBAAqB;gBAC3B,OAAO,EAAE,WAAW;aACrB;SACF;QACD,OAAO,EAAE,WAAW;KACrB,CAAC;IACF,WAAW,CAAC,OAAO,CAAC,CAAC;AACvB,CAAC","sourcesContent":["import { BrowserOptions, init as browserInit, SDK_VERSION } from '@sentry/browser';\n\n/**\n * Inits the Angular SDK\n */\nexport function init(options: BrowserOptions): void {\n options._metadata = options._metadata || {};\n options._metadata.sdk = {\n name: 'sentry.javascript.angular',\n packages: [\n {\n name: 'npm:@sentry/angular',\n version: SDK_VERSION,\n },\n ],\n version: SDK_VERSION,\n };\n browserInit(options);\n}\n"]}
package/esm/tracing.d.ts DELETED
@@ -1,61 +0,0 @@
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
@@ -1 +0,0 @@
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"}
package/esm/tracing.js DELETED
@@ -1,236 +0,0 @@
1
- import { __assign, __decorate } from "tslib";
2
- import { Directive, Injectable, Input, NgModule } from '@angular/core';
3
- import { NavigationEnd, NavigationStart } from '@angular/router';
4
- import { getCurrentHub } from '@sentry/browser';
5
- import { getGlobalObject, logger, stripUrlQueryAndFragment, timestampWithMs } from '@sentry/utils';
6
- import { Subscription } from 'rxjs';
7
- import { filter, tap } from 'rxjs/operators';
8
- import { ANGULAR_INIT_OP, ANGULAR_OP, ANGULAR_ROUTING_OP } from './constants';
9
- import { IS_DEBUG_BUILD } from './flags';
10
- import { runOutsideAngular } from './zone';
11
- var instrumentationInitialized;
12
- var stashedStartTransaction;
13
- var stashedStartTransactionOnLocationChange;
14
- var global = getGlobalObject();
15
- /**
16
- * Creates routing instrumentation for Angular Router.
17
- */
18
- export function routingInstrumentation(customStartTransaction, startTransactionOnPageLoad, startTransactionOnLocationChange) {
19
- if (startTransactionOnPageLoad === void 0) { startTransactionOnPageLoad = true; }
20
- if (startTransactionOnLocationChange === void 0) { startTransactionOnLocationChange = true; }
21
- instrumentationInitialized = true;
22
- stashedStartTransaction = customStartTransaction;
23
- stashedStartTransactionOnLocationChange = startTransactionOnLocationChange;
24
- if (startTransactionOnPageLoad && global && global.location) {
25
- customStartTransaction({
26
- name: global.location.pathname,
27
- op: 'pageload',
28
- });
29
- }
30
- }
31
- export var instrumentAngularRouting = routingInstrumentation;
32
- /**
33
- * Grabs active transaction off scope
34
- */
35
- export function getActiveTransaction() {
36
- var currentHub = getCurrentHub();
37
- if (currentHub) {
38
- var scope = currentHub.getScope();
39
- if (scope) {
40
- return scope.getTransaction();
41
- }
42
- }
43
- return undefined;
44
- }
45
- /**
46
- * Angular's Service responsible for hooking into Angular Router and tracking current navigation process.
47
- * Creates a new transaction for every route change and measures a duration of routing process.
48
- */
49
- var TraceService = /** @class */ (function () {
50
- function TraceService(_router) {
51
- var _this = this;
52
- this._router = _router;
53
- this.navStart$ = this._router.events.pipe(filter(function (event) { return event instanceof NavigationStart; }), tap(function (event) {
54
- if (!instrumentationInitialized) {
55
- IS_DEBUG_BUILD &&
56
- logger.error('Angular integration has tracing enabled, but Tracing integration is not configured');
57
- return;
58
- }
59
- var navigationEvent = event;
60
- var strippedUrl = stripUrlQueryAndFragment(navigationEvent.url);
61
- var activeTransaction = getActiveTransaction();
62
- if (!activeTransaction && stashedStartTransactionOnLocationChange) {
63
- activeTransaction = stashedStartTransaction({
64
- name: strippedUrl,
65
- op: 'navigation',
66
- });
67
- }
68
- if (activeTransaction) {
69
- if (_this._routingSpan) {
70
- _this._routingSpan.finish();
71
- }
72
- _this._routingSpan = activeTransaction.startChild({
73
- description: "" + navigationEvent.url,
74
- op: ANGULAR_ROUTING_OP,
75
- tags: __assign({ 'routing.instrumentation': '@sentry/angular', url: strippedUrl }, (navigationEvent.navigationTrigger && {
76
- navigationTrigger: navigationEvent.navigationTrigger,
77
- })),
78
- });
79
- }
80
- }));
81
- this.navEnd$ = this._router.events.pipe(filter(function (event) { return event instanceof NavigationEnd; }), tap(function () {
82
- if (_this._routingSpan) {
83
- runOutsideAngular(function () {
84
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
85
- _this._routingSpan.finish();
86
- });
87
- _this._routingSpan = null;
88
- }
89
- }));
90
- this._routingSpan = null;
91
- this._subscription = new Subscription();
92
- this._subscription.add(this.navStart$.subscribe());
93
- this._subscription.add(this.navEnd$.subscribe());
94
- }
95
- /**
96
- * This is used to prevent memory leaks when the root view is created and destroyed multiple times,
97
- * since `subscribe` callbacks capture `this` and prevent many resources from being GC'd.
98
- */
99
- TraceService.prototype.ngOnDestroy = function () {
100
- this._subscription.unsubscribe();
101
- };
102
- TraceService = __decorate([
103
- Injectable({ providedIn: 'root' })
104
- ], TraceService);
105
- return TraceService;
106
- }());
107
- export { TraceService };
108
- var UNKNOWN_COMPONENT = 'unknown';
109
- /**
110
- * A directive that can be used to capture initialization lifecycle of the whole component.
111
- */
112
- var TraceDirective = /** @class */ (function () {
113
- function TraceDirective() {
114
- this.componentName = UNKNOWN_COMPONENT;
115
- }
116
- /**
117
- * Implementation of OnInit lifecycle method
118
- * @inheritdoc
119
- */
120
- TraceDirective.prototype.ngOnInit = function () {
121
- var activeTransaction = getActiveTransaction();
122
- if (activeTransaction) {
123
- this._tracingSpan = activeTransaction.startChild({
124
- description: "<" + this.componentName + ">",
125
- op: ANGULAR_INIT_OP,
126
- });
127
- }
128
- };
129
- /**
130
- * Implementation of AfterViewInit lifecycle method
131
- * @inheritdoc
132
- */
133
- TraceDirective.prototype.ngAfterViewInit = function () {
134
- if (this._tracingSpan) {
135
- this._tracingSpan.finish();
136
- }
137
- };
138
- __decorate([
139
- Input('trace')
140
- ], TraceDirective.prototype, "componentName", void 0);
141
- TraceDirective = __decorate([
142
- Directive({ selector: '[trace]' })
143
- ], TraceDirective);
144
- return TraceDirective;
145
- }());
146
- export { TraceDirective };
147
- /**
148
- * A module serves as a single compilation unit for the `TraceDirective` and can be re-used by any other module.
149
- */
150
- var TraceModule = /** @class */ (function () {
151
- function TraceModule() {
152
- }
153
- TraceModule = __decorate([
154
- NgModule({
155
- declarations: [TraceDirective],
156
- exports: [TraceDirective],
157
- })
158
- ], TraceModule);
159
- return TraceModule;
160
- }());
161
- export { TraceModule };
162
- /**
163
- * Decorator function that can be used to capture initialization lifecycle of the whole component.
164
- */
165
- export function TraceClassDecorator() {
166
- var tracingSpan;
167
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
168
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
169
- return function (target) {
170
- var originalOnInit = target.prototype.ngOnInit;
171
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
172
- target.prototype.ngOnInit = function () {
173
- var args = [];
174
- for (var _i = 0; _i < arguments.length; _i++) {
175
- args[_i] = arguments[_i];
176
- }
177
- var activeTransaction = getActiveTransaction();
178
- if (activeTransaction) {
179
- tracingSpan = activeTransaction.startChild({
180
- description: "<" + target.name + ">",
181
- op: ANGULAR_INIT_OP,
182
- });
183
- }
184
- if (originalOnInit) {
185
- return originalOnInit.apply(this, args);
186
- }
187
- };
188
- var originalAfterViewInit = target.prototype.ngAfterViewInit;
189
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
190
- target.prototype.ngAfterViewInit = function () {
191
- var args = [];
192
- for (var _i = 0; _i < arguments.length; _i++) {
193
- args[_i] = arguments[_i];
194
- }
195
- if (tracingSpan) {
196
- tracingSpan.finish();
197
- }
198
- if (originalAfterViewInit) {
199
- return originalAfterViewInit.apply(this, args);
200
- }
201
- };
202
- };
203
- /* eslint-enable @typescript-eslint/no-unsafe-member-access */
204
- }
205
- /**
206
- * Decorator function that can be used to capture a single lifecycle methods of the component.
207
- */
208
- export function TraceMethodDecorator() {
209
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/ban-types
210
- return function (target, propertyKey, descriptor) {
211
- var originalMethod = descriptor.value;
212
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
213
- descriptor.value = function () {
214
- var args = [];
215
- for (var _i = 0; _i < arguments.length; _i++) {
216
- args[_i] = arguments[_i];
217
- }
218
- var now = timestampWithMs();
219
- var activeTransaction = getActiveTransaction();
220
- if (activeTransaction) {
221
- activeTransaction.startChild({
222
- description: "<" + target.constructor.name + ">",
223
- endTimestamp: now,
224
- op: ANGULAR_OP + "." + String(propertyKey),
225
- startTimestamp: now,
226
- });
227
- }
228
- if (originalMethod) {
229
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
230
- return originalMethod.apply(this, args);
231
- }
232
- };
233
- return descriptor;
234
- };
235
- }
236
- //# sourceMappingURL=tracing.js.map
@@ -1 +0,0 @@
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,EA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AED;;GAEG;AACH,MAAM,UAAU,oBAAoB;IAClC,0GAA0G;IAC1G,OAAO,UAAC,MAAc,EAAE,WAA4B,EAAE,UAA8B;QAClF,IAAM,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/esm/zone.d.ts DELETED
@@ -1,5 +0,0 @@
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
package/esm/zone.d.ts.map DELETED
@@ -1 +0,0 @@
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"}