vc-error-handlers 0.1.2 → 0.1.3
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/esm2020/lib/configuration.mjs +2 -1
- package/esm2020/lib/shared/errorhandler/sentry-error.handler.mjs +8 -5
- package/fesm2015/vc-error-handlers.mjs +8 -3
- package/fesm2015/vc-error-handlers.mjs.map +1 -1
- package/fesm2020/vc-error-handlers.mjs +8 -3
- package/fesm2020/vc-error-handlers.mjs.map +1 -1
- package/lib/configuration.d.ts +1 -0
- package/lib/shared/errorhandler/sentry-error.handler.d.ts +4 -2
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export class Configurations {
|
|
2
2
|
constructor() {
|
|
3
3
|
this.sentryConfig = {};
|
|
4
|
+
this.userDetails = {};
|
|
4
5
|
}
|
|
5
6
|
}
|
|
6
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
7
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlndXJhdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL3ZjLWVycm9yLWhhbmRsZXJzL3NyYy9saWIvY29uZmlndXJhdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxNQUFNLE9BQU8sY0FBYztJQUd6QjtRQUNFLElBQUksQ0FBQyxZQUFZLEdBQUcsRUFBRSxDQUFDO1FBQ3ZCLElBQUksQ0FBQyxXQUFXLEdBQUcsRUFBRSxDQUFDO0lBQ3hCLENBQUM7Q0FDRiIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBjbGFzcyBDb25maWd1cmF0aW9ucyB7XHJcbiAgcHVibGljIHNlbnRyeUNvbmZpZzogYW55O1xyXG4gIHB1YmxpYyB1c2VyRGV0YWlscz86IGFueTtcclxuICBjb25zdHJ1Y3RvcigpIHtcclxuICAgIHRoaXMuc2VudHJ5Q29uZmlnID0ge307XHJcbiAgICB0aGlzLnVzZXJEZXRhaWxzID0ge307XHJcbiAgfVxyXG59XHJcbiJdfQ==
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Injectable, Optional } from '@angular/core';
|
|
2
2
|
import * as Sentry from '@sentry/angular-ivy';
|
|
3
3
|
import * as i0 from "@angular/core";
|
|
4
|
-
import * as i1 from "
|
|
4
|
+
import * as i1 from "@vcomply/authorizer";
|
|
5
|
+
import * as i2 from "../../configuration";
|
|
5
6
|
export class SentryErrorHandler {
|
|
6
|
-
constructor(config) {
|
|
7
|
+
constructor(authorizerService, config) {
|
|
8
|
+
this.authorizerService = authorizerService;
|
|
7
9
|
if (config?.sentryConfig) {
|
|
8
10
|
const SENTRY_CONFIG = config.sentryConfig;
|
|
9
11
|
Sentry.init({
|
|
@@ -18,6 +20,7 @@ export class SentryErrorHandler {
|
|
|
18
20
|
replaysSessionSampleRate: SENTRY_CONFIG.REPLAY_SESSION_SAMPLE_RATE,
|
|
19
21
|
replaysOnErrorSampleRate: SENTRY_CONFIG.REPLAY_ON_ERROR_SAMPLE_RATE,
|
|
20
22
|
});
|
|
23
|
+
Sentry.setUser({ userDetails: this.authorizerService.getUser() });
|
|
21
24
|
}
|
|
22
25
|
}
|
|
23
26
|
handleError(error) {
|
|
@@ -32,11 +35,11 @@ export class SentryErrorHandler {
|
|
|
32
35
|
}
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
|
-
SentryErrorHandler.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: SentryErrorHandler, deps: [{ token: i1.Configurations, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
38
|
+
SentryErrorHandler.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: SentryErrorHandler, deps: [{ token: i1.AuthorizerService }, { token: i2.Configurations, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
36
39
|
SentryErrorHandler.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: SentryErrorHandler });
|
|
37
40
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: SentryErrorHandler, decorators: [{
|
|
38
41
|
type: Injectable
|
|
39
|
-
}], ctorParameters: function () { return [{ type: i1.Configurations, decorators: [{
|
|
42
|
+
}], ctorParameters: function () { return [{ type: i1.AuthorizerService }, { type: i2.Configurations, decorators: [{
|
|
40
43
|
type: Optional
|
|
41
44
|
}] }]; } });
|
|
42
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
45
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VudHJ5LWVycm9yLmhhbmRsZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9wcm9qZWN0cy92Yy1lcnJvci1oYW5kbGVycy9zcmMvbGliL3NoYXJlZC9lcnJvcmhhbmRsZXIvc2VudHJ5LWVycm9yLmhhbmRsZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFnQixVQUFVLEVBQUUsUUFBUSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBQ25FLE9BQU8sS0FBSyxNQUFNLE1BQU0scUJBQXFCLENBQUM7Ozs7QUFLOUMsTUFBTSxPQUFPLGtCQUFrQjtJQUM3QixZQUNVLGlCQUFvQyxFQUNoQyxNQUF1QjtRQUQzQixzQkFBaUIsR0FBakIsaUJBQWlCLENBQW1CO1FBRzVDLElBQUksTUFBTSxFQUFFLFlBQVksRUFBRTtZQUN4QixNQUFNLGFBQWEsR0FBRyxNQUFNLENBQUMsWUFBWSxDQUFDO1lBQzFDLE1BQU0sQ0FBQyxJQUFJLENBQUM7Z0JBQ1YsR0FBRyxFQUFF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dLFxyXG4gICAgICAgIHRyYWNlc1NhbXBsZVJhdGU6IFNFTlRSWV9DT05GSUcuVFJBQ0VTX1NBTVBMRV9SQVRFLFxyXG4gICAgICAgIHJlcGxheXNTZXNzaW9uU2FtcGxlUmF0ZTogU0VOVFJZX0NPTkZJRy5SRVBMQVlfU0VTU0lPTl9TQU1QTEVfUkFURSxcclxuICAgICAgICByZXBsYXlzT25FcnJvclNhbXBsZVJhdGU6IFNFTlRSWV9DT05GSUcuUkVQTEFZX09OX0VSUk9SX1NBTVBMRV9SQVRFLFxyXG4gICAgICB9KTtcclxuICAgICAgU2VudHJ5LnNldFVzZXIoeyB1c2VyRGV0YWlsczogdGhpcy5hdXRob3JpemVyU2VydmljZS5nZXRVc2VyKCkgfSk7XHJcbiAgICB9XHJcbiAgfVxyXG5cclxuICBoYW5kbGVFcnJvcihlcnJvcjogYW55KSB7XHJcbiAgICBjb25zdCBFUlJPUiA9IGVycm9yPy5vcmlnaW5hbEVycm9yIHx8IGVycm9yO1xyXG4gICAgdGhpcy5oYW5kbGVDaHVua0Vycm9yKEVSUk9SKTtcclxuICAgIFNlbnRyeS5jYXB0dXJlRXhjZXB0aW9uKEVSUk9SKTtcclxuICB9XHJcblxyXG4gIGhhbmRsZUNodW5rRXJyb3IoZXJyb3I6IEVycm9yKSB7XHJcbiAgICBjb25zdCBjaHVua0ZhaWxlZE1lc3NhZ2UgPSAvTG9hZGluZyBjaHVuayBbXFxkXSsgZmFpbGVkLztcclxuICAgIGlmIChjaHVua0ZhaWxlZE1lc3NhZ2UudGVzdChlcnJvcj8ubWVzc2FnZSkpIHtcclxuICAgICAgd2luZG93LmxvY2F0aW9uLnJlbG9hZCgpO1xyXG4gICAgfVxyXG4gIH1cclxufVxyXG4iXX0=
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Injectable, Component, Optional, InjectionToken, ErrorHandler, NgModule } from '@angular/core';
|
|
3
3
|
import * as Sentry from '@sentry/angular-ivy';
|
|
4
|
+
import * as i1 from '@vcomply/authorizer';
|
|
4
5
|
|
|
5
6
|
class VcErrorHandlersService {
|
|
6
7
|
constructor() { }
|
|
@@ -41,11 +42,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
|
|
|
41
42
|
class Configurations {
|
|
42
43
|
constructor() {
|
|
43
44
|
this.sentryConfig = {};
|
|
45
|
+
this.userDetails = {};
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
class SentryErrorHandler {
|
|
48
|
-
constructor(config) {
|
|
50
|
+
constructor(authorizerService, config) {
|
|
51
|
+
this.authorizerService = authorizerService;
|
|
49
52
|
if (config === null || config === void 0 ? void 0 : config.sentryConfig) {
|
|
50
53
|
const SENTRY_CONFIG = config.sentryConfig;
|
|
51
54
|
Sentry.init({
|
|
@@ -60,6 +63,7 @@ class SentryErrorHandler {
|
|
|
60
63
|
replaysSessionSampleRate: SENTRY_CONFIG.REPLAY_SESSION_SAMPLE_RATE,
|
|
61
64
|
replaysOnErrorSampleRate: SENTRY_CONFIG.REPLAY_ON_ERROR_SAMPLE_RATE,
|
|
62
65
|
});
|
|
66
|
+
Sentry.setUser({ userDetails: this.authorizerService.getUser() });
|
|
63
67
|
}
|
|
64
68
|
}
|
|
65
69
|
handleError(error) {
|
|
@@ -74,12 +78,12 @@ class SentryErrorHandler {
|
|
|
74
78
|
}
|
|
75
79
|
}
|
|
76
80
|
}
|
|
77
|
-
SentryErrorHandler.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: SentryErrorHandler, deps: [{ token: Configurations, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
81
|
+
SentryErrorHandler.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: SentryErrorHandler, deps: [{ token: i1.AuthorizerService }, { token: Configurations, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
78
82
|
SentryErrorHandler.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: SentryErrorHandler });
|
|
79
83
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: SentryErrorHandler, decorators: [{
|
|
80
84
|
type: Injectable
|
|
81
85
|
}], ctorParameters: function () {
|
|
82
|
-
return [{ type: Configurations, decorators: [{
|
|
86
|
+
return [{ type: i1.AuthorizerService }, { type: Configurations, decorators: [{
|
|
83
87
|
type: Optional
|
|
84
88
|
}] }];
|
|
85
89
|
} });
|
|
@@ -115,3 +119,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
|
|
|
115
119
|
*/
|
|
116
120
|
|
|
117
121
|
export { FOR_ROOT_SENTRY_OPTIONS_TOKEN, VcErrorHandlersComponent, VcErrorHandlersModule, VcErrorHandlersService };
|
|
122
|
+
//# sourceMappingURL=vc-error-handlers.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vc-error-handlers.mjs","sources":["../../../projects/vc-error-handlers/src/lib/vc-error-handlers.service.ts","../../../projects/vc-error-handlers/src/lib/vc-error-handlers.component.ts","../../../projects/vc-error-handlers/src/lib/configuration.ts","../../../projects/vc-error-handlers/src/lib/shared/errorhandler/sentry-error.handler.ts","../../../projects/vc-error-handlers/src/lib/vc-error-handlers.module.ts","../../../projects/vc-error-handlers/src/public-api.ts","../../../projects/vc-error-handlers/src/vc-error-handlers.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class VcErrorHandlersService {\r\n\r\n constructor() { }\r\n}\r\n","import { Component, OnInit } from '@angular/core';\r\n\r\n@Component({\r\n selector: 'lib-vc-error-handlers',\r\n template: `\r\n <p>\r\n vc-error-handlers works!\r\n </p>\r\n `,\r\n styles: [\r\n ]\r\n})\r\nexport class VcErrorHandlersComponent implements OnInit {\r\n\r\n constructor() { }\r\n\r\n ngOnInit(): void {\r\n }\r\n\r\n}\r\n","export class Configurations {\r\n public sentryConfig: any;\r\n
|
|
1
|
+
{"version":3,"file":"vc-error-handlers.mjs","sources":["../../../projects/vc-error-handlers/src/lib/vc-error-handlers.service.ts","../../../projects/vc-error-handlers/src/lib/vc-error-handlers.component.ts","../../../projects/vc-error-handlers/src/lib/configuration.ts","../../../projects/vc-error-handlers/src/lib/shared/errorhandler/sentry-error.handler.ts","../../../projects/vc-error-handlers/src/lib/vc-error-handlers.module.ts","../../../projects/vc-error-handlers/src/public-api.ts","../../../projects/vc-error-handlers/src/vc-error-handlers.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class VcErrorHandlersService {\r\n\r\n constructor() { }\r\n}\r\n","import { Component, OnInit } from '@angular/core';\r\n\r\n@Component({\r\n selector: 'lib-vc-error-handlers',\r\n template: `\r\n <p>\r\n vc-error-handlers works!\r\n </p>\r\n `,\r\n styles: [\r\n ]\r\n})\r\nexport class VcErrorHandlersComponent implements OnInit {\r\n\r\n constructor() { }\r\n\r\n ngOnInit(): void {\r\n }\r\n\r\n}\r\n","export class Configurations {\r\n public sentryConfig: any;\r\n public userDetails?: any;\r\n constructor() {\r\n this.sentryConfig = {};\r\n this.userDetails = {};\r\n }\r\n}\r\n","import { ErrorHandler, Injectable, Optional } from '@angular/core';\r\nimport * as Sentry from '@sentry/angular-ivy';\r\nimport { Configurations } from '../../configuration';\r\nimport { AuthorizerService } from '@vcomply/authorizer';\r\n\r\n@Injectable()\r\nexport class SentryErrorHandler implements ErrorHandler {\r\n constructor(\r\n private authorizerService: AuthorizerService,\r\n @Optional() config?: Configurations\r\n ) {\r\n if (config?.sentryConfig) {\r\n const SENTRY_CONFIG = config.sentryConfig;\r\n Sentry.init({\r\n dsn: SENTRY_CONFIG?.DSN,\r\n integrations: [\r\n new Sentry.BrowserTracing({\r\n tracePropagationTargets: SENTRY_CONFIG.ALLOW_ORIGIN,\r\n routingInstrumentation: Sentry.routingInstrumentation,\r\n }),\r\n ],\r\n tracesSampleRate: SENTRY_CONFIG.TRACES_SAMPLE_RATE,\r\n replaysSessionSampleRate: SENTRY_CONFIG.REPLAY_SESSION_SAMPLE_RATE,\r\n replaysOnErrorSampleRate: SENTRY_CONFIG.REPLAY_ON_ERROR_SAMPLE_RATE,\r\n });\r\n Sentry.setUser({ userDetails: this.authorizerService.getUser() });\r\n }\r\n }\r\n\r\n handleError(error: any) {\r\n const ERROR = error?.originalError || error;\r\n this.handleChunkError(ERROR);\r\n Sentry.captureException(ERROR);\r\n }\r\n\r\n handleChunkError(error: Error) {\r\n const chunkFailedMessage = /Loading chunk [\\d]+ failed/;\r\n if (chunkFailedMessage.test(error?.message)) {\r\n window.location.reload();\r\n }\r\n }\r\n}\r\n","import {\r\n ErrorHandler,\r\n InjectionToken,\r\n ModuleWithProviders,\r\n NgModule,\r\n} from '@angular/core';\r\nimport { VcErrorHandlersComponent } from './vc-error-handlers.component';\r\nimport { BrowserOptions } from '@sentry/browser';\r\nimport { GlobalErrorHandler } from './shared/errorhandler/chunk-error.handler';\r\nimport { SentryErrorHandler } from './shared/errorhandler/sentry-error.handler';\r\nimport { Configurations } from './configuration';\r\n\r\nexport const FOR_ROOT_SENTRY_OPTIONS_TOKEN = new InjectionToken<BrowserOptions>(\r\n 'forRoot() SentryErrorHandler options'\r\n);\r\n\r\n@NgModule({\r\n declarations: [VcErrorHandlersComponent],\r\n imports: [],\r\n exports: [VcErrorHandlersComponent],\r\n providers: [{ provide: ErrorHandler, useClass: SentryErrorHandler }],\r\n})\r\nexport class VcErrorHandlersModule {\r\n public static forRoot(\r\n environmentConfig: Configurations\r\n ): ModuleWithProviders<VcErrorHandlersModule> {\r\n return {\r\n ngModule: VcErrorHandlersModule,\r\n providers: [{ provide: Configurations, useValue: environmentConfig }],\r\n };\r\n }\r\n}\r\n","/*\r\n * Public API Surface of vc-error-handlers\r\n */\r\n\r\nexport * from './lib/vc-error-handlers.service';\r\nexport * from './lib/vc-error-handlers.component';\r\nexport * from './lib/vc-error-handlers.module';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;MAKa,sBAAsB;IAEjC,iBAAiB;;mHAFN,sBAAsB;uHAAtB,sBAAsB,cAFrB,MAAM;2FAEP,sBAAsB;kBAHlC,UAAU;mBAAC;oBACV,UAAU,EAAE,MAAM;iBACnB;;;MCQY,wBAAwB;IAEnC,iBAAiB;IAEjB,QAAQ;KACP;;qHALU,wBAAwB;yGAAxB,wBAAwB,6DARzB;;;;GAIT;2FAIU,wBAAwB;kBAVpC,SAAS;mBAAC;oBACT,QAAQ,EAAE,uBAAuB;oBACjC,QAAQ,EAAE;;;;GAIT;oBACD,MAAM,EAAE,EACP;iBACF;;;MCXY,cAAc;IAGzB;QACE,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;KACvB;;;MCAU,kBAAkB;IAC7B,YACU,iBAAoC,EAChC,MAAuB;QAD3B,sBAAiB,GAAjB,iBAAiB,CAAmB;QAG5C,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,YAAY,EAAE;YACxB,MAAM,aAAa,GAAG,MAAM,CAAC,YAAY,CAAC;YAC1C,MAAM,CAAC,IAAI,CAAC;gBACV,GAAG,EAAE,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,GAAG;gBACvB,YAAY,EAAE;oBACZ,IAAI,MAAM,CAAC,cAAc,CAAC;wBACxB,uBAAuB,EAAE,aAAa,CAAC,YAAY;wBACnD,sBAAsB,EAAE,MAAM,CAAC,sBAAsB;qBACtD,CAAC;iBACH;gBACD,gBAAgB,EAAE,aAAa,CAAC,kBAAkB;gBAClD,wBAAwB,EAAE,aAAa,CAAC,0BAA0B;gBAClE,wBAAwB,EAAE,aAAa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CAAC;oBACnC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,kBAAkB,EAAE,CAAC;iBACrE;;;ACrBD;;;;ACAA;;;;;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Injectable, Component, Optional, InjectionToken, ErrorHandler, NgModule } from '@angular/core';
|
|
3
3
|
import * as Sentry from '@sentry/angular-ivy';
|
|
4
|
+
import * as i1 from '@vcomply/authorizer';
|
|
4
5
|
|
|
5
6
|
class VcErrorHandlersService {
|
|
6
7
|
constructor() { }
|
|
@@ -41,11 +42,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
|
|
|
41
42
|
class Configurations {
|
|
42
43
|
constructor() {
|
|
43
44
|
this.sentryConfig = {};
|
|
45
|
+
this.userDetails = {};
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
class SentryErrorHandler {
|
|
48
|
-
constructor(config) {
|
|
50
|
+
constructor(authorizerService, config) {
|
|
51
|
+
this.authorizerService = authorizerService;
|
|
49
52
|
if (config?.sentryConfig) {
|
|
50
53
|
const SENTRY_CONFIG = config.sentryConfig;
|
|
51
54
|
Sentry.init({
|
|
@@ -60,6 +63,7 @@ class SentryErrorHandler {
|
|
|
60
63
|
replaysSessionSampleRate: SENTRY_CONFIG.REPLAY_SESSION_SAMPLE_RATE,
|
|
61
64
|
replaysOnErrorSampleRate: SENTRY_CONFIG.REPLAY_ON_ERROR_SAMPLE_RATE,
|
|
62
65
|
});
|
|
66
|
+
Sentry.setUser({ userDetails: this.authorizerService.getUser() });
|
|
63
67
|
}
|
|
64
68
|
}
|
|
65
69
|
handleError(error) {
|
|
@@ -74,11 +78,11 @@ class SentryErrorHandler {
|
|
|
74
78
|
}
|
|
75
79
|
}
|
|
76
80
|
}
|
|
77
|
-
SentryErrorHandler.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: SentryErrorHandler, deps: [{ token: Configurations, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
81
|
+
SentryErrorHandler.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: SentryErrorHandler, deps: [{ token: i1.AuthorizerService }, { token: Configurations, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
78
82
|
SentryErrorHandler.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: SentryErrorHandler });
|
|
79
83
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: SentryErrorHandler, decorators: [{
|
|
80
84
|
type: Injectable
|
|
81
|
-
}], ctorParameters: function () { return [{ type: Configurations, decorators: [{
|
|
85
|
+
}], ctorParameters: function () { return [{ type: i1.AuthorizerService }, { type: Configurations, decorators: [{
|
|
82
86
|
type: Optional
|
|
83
87
|
}] }]; } });
|
|
84
88
|
|
|
@@ -113,3 +117,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
|
|
|
113
117
|
*/
|
|
114
118
|
|
|
115
119
|
export { FOR_ROOT_SENTRY_OPTIONS_TOKEN, VcErrorHandlersComponent, VcErrorHandlersModule, VcErrorHandlersService };
|
|
120
|
+
//# sourceMappingURL=vc-error-handlers.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vc-error-handlers.mjs","sources":["../../../projects/vc-error-handlers/src/lib/vc-error-handlers.service.ts","../../../projects/vc-error-handlers/src/lib/vc-error-handlers.component.ts","../../../projects/vc-error-handlers/src/lib/configuration.ts","../../../projects/vc-error-handlers/src/lib/shared/errorhandler/sentry-error.handler.ts","../../../projects/vc-error-handlers/src/lib/vc-error-handlers.module.ts","../../../projects/vc-error-handlers/src/public-api.ts","../../../projects/vc-error-handlers/src/vc-error-handlers.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class VcErrorHandlersService {\r\n\r\n constructor() { }\r\n}\r\n","import { Component, OnInit } from '@angular/core';\r\n\r\n@Component({\r\n selector: 'lib-vc-error-handlers',\r\n template: `\r\n <p>\r\n vc-error-handlers works!\r\n </p>\r\n `,\r\n styles: [\r\n ]\r\n})\r\nexport class VcErrorHandlersComponent implements OnInit {\r\n\r\n constructor() { }\r\n\r\n ngOnInit(): void {\r\n }\r\n\r\n}\r\n","export class Configurations {\r\n public sentryConfig: any;\r\n
|
|
1
|
+
{"version":3,"file":"vc-error-handlers.mjs","sources":["../../../projects/vc-error-handlers/src/lib/vc-error-handlers.service.ts","../../../projects/vc-error-handlers/src/lib/vc-error-handlers.component.ts","../../../projects/vc-error-handlers/src/lib/configuration.ts","../../../projects/vc-error-handlers/src/lib/shared/errorhandler/sentry-error.handler.ts","../../../projects/vc-error-handlers/src/lib/vc-error-handlers.module.ts","../../../projects/vc-error-handlers/src/public-api.ts","../../../projects/vc-error-handlers/src/vc-error-handlers.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class VcErrorHandlersService {\r\n\r\n constructor() { }\r\n}\r\n","import { Component, OnInit } from '@angular/core';\r\n\r\n@Component({\r\n selector: 'lib-vc-error-handlers',\r\n template: `\r\n <p>\r\n vc-error-handlers works!\r\n </p>\r\n `,\r\n styles: [\r\n ]\r\n})\r\nexport class VcErrorHandlersComponent implements OnInit {\r\n\r\n constructor() { }\r\n\r\n ngOnInit(): void {\r\n }\r\n\r\n}\r\n","export class Configurations {\r\n public sentryConfig: any;\r\n public userDetails?: any;\r\n constructor() {\r\n this.sentryConfig = {};\r\n this.userDetails = {};\r\n }\r\n}\r\n","import { ErrorHandler, Injectable, Optional } from '@angular/core';\r\nimport * as Sentry from '@sentry/angular-ivy';\r\nimport { Configurations } from '../../configuration';\r\nimport { AuthorizerService } from '@vcomply/authorizer';\r\n\r\n@Injectable()\r\nexport class SentryErrorHandler implements ErrorHandler {\r\n constructor(\r\n private authorizerService: AuthorizerService,\r\n @Optional() config?: Configurations\r\n ) {\r\n if (config?.sentryConfig) {\r\n const SENTRY_CONFIG = config.sentryConfig;\r\n Sentry.init({\r\n dsn: SENTRY_CONFIG?.DSN,\r\n integrations: [\r\n new Sentry.BrowserTracing({\r\n tracePropagationTargets: SENTRY_CONFIG.ALLOW_ORIGIN,\r\n routingInstrumentation: Sentry.routingInstrumentation,\r\n }),\r\n ],\r\n tracesSampleRate: SENTRY_CONFIG.TRACES_SAMPLE_RATE,\r\n replaysSessionSampleRate: SENTRY_CONFIG.REPLAY_SESSION_SAMPLE_RATE,\r\n replaysOnErrorSampleRate: SENTRY_CONFIG.REPLAY_ON_ERROR_SAMPLE_RATE,\r\n });\r\n Sentry.setUser({ userDetails: this.authorizerService.getUser() });\r\n }\r\n }\r\n\r\n handleError(error: any) {\r\n const ERROR = error?.originalError || error;\r\n this.handleChunkError(ERROR);\r\n Sentry.captureException(ERROR);\r\n }\r\n\r\n handleChunkError(error: Error) {\r\n const chunkFailedMessage = /Loading chunk [\\d]+ failed/;\r\n if (chunkFailedMessage.test(error?.message)) {\r\n window.location.reload();\r\n }\r\n }\r\n}\r\n","import {\r\n ErrorHandler,\r\n InjectionToken,\r\n ModuleWithProviders,\r\n NgModule,\r\n} from '@angular/core';\r\nimport { VcErrorHandlersComponent } from './vc-error-handlers.component';\r\nimport { BrowserOptions } from '@sentry/browser';\r\nimport { GlobalErrorHandler } from './shared/errorhandler/chunk-error.handler';\r\nimport { SentryErrorHandler } from './shared/errorhandler/sentry-error.handler';\r\nimport { Configurations } from './configuration';\r\n\r\nexport const FOR_ROOT_SENTRY_OPTIONS_TOKEN = new InjectionToken<BrowserOptions>(\r\n 'forRoot() SentryErrorHandler options'\r\n);\r\n\r\n@NgModule({\r\n declarations: [VcErrorHandlersComponent],\r\n imports: [],\r\n exports: [VcErrorHandlersComponent],\r\n providers: [{ provide: ErrorHandler, useClass: SentryErrorHandler }],\r\n})\r\nexport class VcErrorHandlersModule {\r\n public static forRoot(\r\n environmentConfig: Configurations\r\n ): ModuleWithProviders<VcErrorHandlersModule> {\r\n return {\r\n ngModule: VcErrorHandlersModule,\r\n providers: [{ provide: Configurations, useValue: environmentConfig }],\r\n };\r\n }\r\n}\r\n","/*\r\n * Public API Surface of vc-error-handlers\r\n */\r\n\r\nexport * from './lib/vc-error-handlers.service';\r\nexport * from './lib/vc-error-handlers.component';\r\nexport * from './lib/vc-error-handlers.module';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;MAKa,sBAAsB;IAEjC,iBAAiB;;mHAFN,sBAAsB;uHAAtB,sBAAsB,cAFrB,MAAM;2FAEP,sBAAsB;kBAHlC,UAAU;mBAAC;oBACV,UAAU,EAAE,MAAM;iBACnB;;;MCQY,wBAAwB;IAEnC,iBAAiB;IAEjB,QAAQ;KACP;;qHALU,wBAAwB;yGAAxB,wBAAwB,6DARzB;;;;GAIT;2FAIU,wBAAwB;kBAVpC,SAAS;mBAAC;oBACT,QAAQ,EAAE,uBAAuB;oBACjC,QAAQ,EAAE;;;;GAIT;oBACD,MAAM,EAAE,EACP;iBACF;;;MCXY,cAAc;IAGzB;QACE,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;KACvB;;;MCAU,kBAAkB;IAC7B,YACU,iBAAoC,EAChC,MAAuB;QAD3B,sBAAiB,GAAjB,iBAAiB,CAAmB;QAG5C,IAAI,MAAM,EAAE,YAAY,EAAE;YACxB,MAAM,aAAa,GAAG,MAAM,CAAC,YAAY,CAAC;YAC1C,MAAM,CAAC,IAAI,CAAC;gBACV,GAAG,EAAE,aAAa,EAAE,GAAG;gBACvB,YAAY,EAAE;oBACZ,IAAI,MAAM,CAAC,cAAc,CAAC;wB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C,YAF3D,EAAE;2FAIA,qBAAqB;kBANjC,QAAQ;mBAAC;oBACR,YAAY,EAAE,CAAC,wBAAwB,CAAC;oBACxC,OAAO,EAAE,EAAE;oBACX,OAAO,EAAE,CAAC,wBAAwB,CAAC;oBACnC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,kBAAkB,EAAE,CAAC;iBACrE;;;ACrBD;;;;ACAA;;;;;;"}
|
package/lib/configuration.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { ErrorHandler } from '@angular/core';
|
|
2
2
|
import { Configurations } from '../../configuration';
|
|
3
|
+
import { AuthorizerService } from '@vcomply/authorizer';
|
|
3
4
|
import * as i0 from "@angular/core";
|
|
4
5
|
export declare class SentryErrorHandler implements ErrorHandler {
|
|
5
|
-
|
|
6
|
+
private authorizerService;
|
|
7
|
+
constructor(authorizerService: AuthorizerService, config?: Configurations);
|
|
6
8
|
handleError(error: any): void;
|
|
7
9
|
handleChunkError(error: Error): void;
|
|
8
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<SentryErrorHandler, [{ optional: true; }]>;
|
|
10
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SentryErrorHandler, [null, { optional: true; }]>;
|
|
9
11
|
static ɵprov: i0.ɵɵInjectableDeclaration<SentryErrorHandler>;
|
|
10
12
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vc-error-handlers",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@angular/common": " 13.x || 14.x || 15.x || 16.x || 17.x || 18.x || 19.x || 20.x",
|
|
6
6
|
"@angular/core": "13.x || 14.x || 15.x || 16.x || 17.x || 18.x || 19.x || 20.x"
|