@eventista/ticketing-common 1.0.1030 → 1.0.1032-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/exception/exception.filter.d.ts +3 -0
- package/dist/exception/exception.filter.js +59 -0
- package/dist/exception/exception.filter.js.map +1 -1
- package/dist/exception/unified-exception.filter.d.ts +9 -0
- package/dist/exception/unified-exception.filter.js +152 -0
- package/dist/exception/unified-exception.filter.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/logger/custom.logger.d.ts +5 -1
- package/dist/logger/custom.logger.js +27 -0
- package/dist/logger/custom.logger.js.map +1 -1
- package/dist/logger/examples/logger-sentry.example.d.ts +32 -0
- package/dist/logger/examples/logger-sentry.example.js +211 -0
- package/dist/logger/examples/logger-sentry.example.js.map +1 -0
- package/dist/sentry/decorators/index.d.ts +2 -0
- package/dist/sentry/decorators/index.js +19 -0
- package/dist/sentry/decorators/index.js.map +1 -0
- package/dist/sentry/decorators/sentry-capture.decorator.d.ts +9 -0
- package/dist/sentry/decorators/sentry-capture.decorator.js +13 -0
- package/dist/sentry/decorators/sentry-capture.decorator.js.map +1 -0
- package/dist/sentry/decorators/sentry-trace.decorator.d.ts +9 -0
- package/dist/sentry/decorators/sentry-trace.decorator.js +8 -0
- package/dist/sentry/decorators/sentry-trace.decorator.js.map +1 -0
- package/dist/sentry/examples/optimized-usage.example.d.ts +33 -0
- package/dist/sentry/examples/optimized-usage.example.js +300 -0
- package/dist/sentry/examples/optimized-usage.example.js.map +1 -0
- package/dist/sentry/examples/sentry-usage.example.d.ts +39 -0
- package/dist/sentry/examples/sentry-usage.example.js +262 -0
- package/dist/sentry/examples/sentry-usage.example.js.map +1 -0
- package/dist/sentry/index.d.ts +10 -0
- package/dist/sentry/index.js +27 -0
- package/dist/sentry/index.js.map +1 -0
- package/dist/sentry/interceptors/index.d.ts +2 -0
- package/dist/sentry/interceptors/index.js +19 -0
- package/dist/sentry/interceptors/index.js.map +1 -0
- package/dist/sentry/interceptors/sentry-capture.interceptor.d.ts +8 -0
- package/dist/sentry/interceptors/sentry-capture.interceptor.js +80 -0
- package/dist/sentry/interceptors/sentry-capture.interceptor.js.map +1 -0
- package/dist/sentry/interceptors/sentry-trace.interceptor.d.ts +8 -0
- package/dist/sentry/interceptors/sentry-trace.interceptor.js +56 -0
- package/dist/sentry/interceptors/sentry-trace.interceptor.js.map +1 -0
- package/dist/sentry/sentry-logger.helper.d.ts +22 -0
- package/dist/sentry/sentry-logger.helper.js +153 -0
- package/dist/sentry/sentry-logger.helper.js.map +1 -0
- package/dist/sentry/sentry-safe.module.d.ts +11 -0
- package/dist/sentry/sentry-safe.module.js +82 -0
- package/dist/sentry/sentry-safe.module.js.map +1 -0
- package/dist/sentry/sentry.advanced-config.d.ts +35 -0
- package/dist/sentry/sentry.advanced-config.js +99 -0
- package/dist/sentry/sentry.advanced-config.js.map +1 -0
- package/dist/sentry/sentry.config.d.ts +20 -0
- package/dist/sentry/sentry.config.js +20 -0
- package/dist/sentry/sentry.config.js.map +1 -0
- package/dist/sentry/sentry.filter.d.ts +12 -0
- package/dist/sentry/sentry.filter.js +139 -0
- package/dist/sentry/sentry.filter.js.map +1 -0
- package/dist/sentry/sentry.interceptor.d.ts +9 -0
- package/dist/sentry/sentry.interceptor.js +80 -0
- package/dist/sentry/sentry.interceptor.js.map +1 -0
- package/dist/sentry/sentry.module.d.ts +2 -0
- package/dist/sentry/sentry.module.js +45 -0
- package/dist/sentry/sentry.module.js.map +1 -0
- package/dist/sentry/sentry.service.d.ts +56 -0
- package/dist/sentry/sentry.service.js +255 -0
- package/dist/sentry/sentry.service.js.map +1 -0
- package/dist/sentry/types/index.d.ts +30 -0
- package/dist/sentry/types/index.js +3 -0
- package/dist/sentry/types/index.js.map +1 -0
- package/dist/shared.module.js +3 -0
- package/dist/shared.module.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -2
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SentryInterceptor = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const rxjs_1 = require("rxjs");
|
|
15
|
+
const operators_1 = require("rxjs/operators");
|
|
16
|
+
const sentry_service_1 = require("./sentry.service");
|
|
17
|
+
let SentryInterceptor = class SentryInterceptor {
|
|
18
|
+
constructor(sentryService) {
|
|
19
|
+
this.sentryService = sentryService;
|
|
20
|
+
}
|
|
21
|
+
intercept(context, next) {
|
|
22
|
+
const request = context.switchToHttp().getRequest();
|
|
23
|
+
const response = context.switchToHttp().getResponse();
|
|
24
|
+
this.sentryService.withScope((scope) => {
|
|
25
|
+
scope.setTag('http.method', request.method);
|
|
26
|
+
scope.setTag('http.url', request.url);
|
|
27
|
+
scope.setContext('request', {
|
|
28
|
+
method: request.method,
|
|
29
|
+
url: request.url,
|
|
30
|
+
headers: this.sanitizeHeaders(request.headers),
|
|
31
|
+
query: request.query,
|
|
32
|
+
params: request.params,
|
|
33
|
+
});
|
|
34
|
+
if (request.user) {
|
|
35
|
+
scope.setUser({
|
|
36
|
+
id: request.user.id || request.user.sub,
|
|
37
|
+
email: request.user.email,
|
|
38
|
+
username: request.user.username,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return this.sentryService.startSpan({
|
|
43
|
+
name: `${request.method} ${request.route?.path || request.url}`,
|
|
44
|
+
op: 'http.server',
|
|
45
|
+
}, () => {
|
|
46
|
+
return next.handle().pipe((0, operators_1.tap)(() => {
|
|
47
|
+
this.sentryService.setTag('http.status_code', response.statusCode.toString());
|
|
48
|
+
}), (0, operators_1.catchError)((error) => {
|
|
49
|
+
this.sentryService.withScope((scope) => {
|
|
50
|
+
scope.setTag('http.status_code', error.status || 500);
|
|
51
|
+
scope.setContext('error', {
|
|
52
|
+
name: error.name,
|
|
53
|
+
message: error.message,
|
|
54
|
+
stack: error.stack,
|
|
55
|
+
});
|
|
56
|
+
if (!(error instanceof common_1.HttpException) || error.getStatus() >= 500) {
|
|
57
|
+
this.sentryService.captureException(error, context.getClass().name);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
return (0, rxjs_1.throwError)(() => error);
|
|
61
|
+
}));
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
sanitizeHeaders(headers) {
|
|
65
|
+
const sensitiveHeaders = ['authorization', 'cookie', 'x-api-key', 'x-auth-token'];
|
|
66
|
+
const sanitized = { ...headers };
|
|
67
|
+
for (const header of sensitiveHeaders) {
|
|
68
|
+
if (header in sanitized) {
|
|
69
|
+
sanitized[header] = '[REDACTED]';
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return sanitized;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
exports.SentryInterceptor = SentryInterceptor;
|
|
76
|
+
exports.SentryInterceptor = SentryInterceptor = __decorate([
|
|
77
|
+
(0, common_1.Injectable)(),
|
|
78
|
+
__metadata("design:paramtypes", [sentry_service_1.SentryService])
|
|
79
|
+
], SentryInterceptor);
|
|
80
|
+
//# sourceMappingURL=sentry.interceptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentry.interceptor.js","sourceRoot":"","sources":["../../src/sentry/sentry.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAMwB;AACxB,+BAA8C;AAC9C,8CAAiD;AAEjD,qDAAiD;AAG1C,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC5B,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAE7D,SAAS,CAAC,OAAyB,EAAE,IAAiB;QACpD,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACpD,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,WAAW,EAAE,CAAC;QAGtD,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;YACrC,KAAK,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;YAC5C,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;YACtC,KAAK,CAAC,UAAU,CAAC,SAAS,EAAE;gBAC1B,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,GAAG,EAAE,OAAO,CAAC,GAAG;gBAChB,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC;gBAC9C,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,MAAM,EAAE,OAAO,CAAC,MAAM;aACvB,CAAC,CAAC;YAGH,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;gBACjB,KAAK,CAAC,OAAO,CAAC;oBACZ,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG;oBACvC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK;oBACzB,QAAQ,EAAE,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C,CACF,CAAC;IACJ,CAAC;IAEO,eAAe,CAAC,OAA4B;QAClD,MAAM,gBAAgB,GAAG,CAAC,eAAe,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;QAClF,MAAM,SAAS,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC;QAEjC,KAAK,MAAM,MAAM,IAAI,gBAAgB,EAAE,CAAC;YACtC,IAAI,MAAM,IAAI,SAAS,EAAE,CAAC;gBACxB,SAAS,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC;YACnC,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF,CAAA;AA3EY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;qCAEiC,8BAAa;GAD9C,iBAAiB,CA2E7B"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.SentryModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const config_1 = require("@nestjs/config");
|
|
12
|
+
const core_1 = require("@nestjs/core");
|
|
13
|
+
const sentry_service_1 = require("./sentry.service");
|
|
14
|
+
const sentry_interceptor_1 = require("./sentry.interceptor");
|
|
15
|
+
const sentry_trace_interceptor_1 = require("./interceptors/sentry-trace.interceptor");
|
|
16
|
+
const sentry_capture_interceptor_1 = require("./interceptors/sentry-capture.interceptor");
|
|
17
|
+
const sentry_config_1 = require("./sentry.config");
|
|
18
|
+
let SentryModule = class SentryModule {
|
|
19
|
+
};
|
|
20
|
+
exports.SentryModule = SentryModule;
|
|
21
|
+
exports.SentryModule = SentryModule = __decorate([
|
|
22
|
+
(0, common_1.Global)(),
|
|
23
|
+
(0, common_1.Module)({
|
|
24
|
+
imports: [
|
|
25
|
+
config_1.ConfigModule.forFeature(sentry_config_1.default),
|
|
26
|
+
],
|
|
27
|
+
providers: [
|
|
28
|
+
sentry_service_1.SentryService,
|
|
29
|
+
{
|
|
30
|
+
provide: core_1.APP_INTERCEPTOR,
|
|
31
|
+
useClass: sentry_interceptor_1.SentryInterceptor,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
provide: core_1.APP_INTERCEPTOR,
|
|
35
|
+
useClass: sentry_trace_interceptor_1.SentryTraceInterceptor,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
provide: core_1.APP_INTERCEPTOR,
|
|
39
|
+
useClass: sentry_capture_interceptor_1.SentryCaptureInterceptor,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
exports: [sentry_service_1.SentryService],
|
|
43
|
+
})
|
|
44
|
+
], SentryModule);
|
|
45
|
+
//# sourceMappingURL=sentry.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentry.module.js","sourceRoot":"","sources":["../../src/sentry/sentry.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAgD;AAChD,2CAA8C;AAC9C,uCAA+C;AAC/C,qDAAiD;AACjD,6DAAyD;AACzD,sFAAiF;AACjF,0FAAqF;AACrF,mDAA2C;AA8BpC,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,oCAAY;uBAAZ,YAAY;IA5BxB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,qBAAY,CAAC,UAAU,CAAC,uBAAY,CAAC;SACtC;QACD,SAAS,EAAE;YACT,8BAAa;YAEb;gBACE,OAAO,EAAE,sBAAe;gBACxB,QAAQ,EAAE,sCAAiB;aAC5B;YACD;gBACE,OAAO,EAAE,sBAAe;gBACxB,QAAQ,EAAE,iDAAsB;aACjC;YACD;gBACE,OAAO,EAAE,sBAAe;gBACxB,QAAQ,EAAE,qDAAwB;aACnC;SAMF;QACD,OAAO,EAAE,CAAC,8BAAa,CAAC;KACzB,CAAC;GACW,YAAY,CAAG"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { OnModuleInit } from '@nestjs/common';
|
|
2
|
+
import { ConfigService } from '@nestjs/config';
|
|
3
|
+
import * as Sentry from '@sentry/nestjs';
|
|
4
|
+
export declare class SentryService implements OnModuleInit {
|
|
5
|
+
private readonly configService;
|
|
6
|
+
private readonly logger;
|
|
7
|
+
private isInitialized;
|
|
8
|
+
constructor(configService: ConfigService);
|
|
9
|
+
onModuleInit(): Promise<void>;
|
|
10
|
+
private initializeSentry;
|
|
11
|
+
private buildIntegrations;
|
|
12
|
+
private defaultBeforeSend;
|
|
13
|
+
private defaultBeforeSendTransaction;
|
|
14
|
+
private sanitizeData;
|
|
15
|
+
captureException(exception: any, context?: string): string;
|
|
16
|
+
captureMessage(message: string, level?: Sentry.SeverityLevel, context?: string): string;
|
|
17
|
+
addBreadcrumb(breadcrumb: Sentry.Breadcrumb): void;
|
|
18
|
+
setUser(user: Sentry.User): void;
|
|
19
|
+
setTag(key: string, value: string): void;
|
|
20
|
+
setContext(key: string, context: Record<string, any>): void;
|
|
21
|
+
withScope(callback: (scope: Sentry.Scope) => void): void;
|
|
22
|
+
startSpan<T>(context: {
|
|
23
|
+
name: string;
|
|
24
|
+
op?: string;
|
|
25
|
+
}, callback: () => T): T;
|
|
26
|
+
getCurrentScope(): any;
|
|
27
|
+
flush(timeout?: number): Promise<boolean>;
|
|
28
|
+
close(timeout?: number): Promise<boolean>;
|
|
29
|
+
isEnabled(): boolean;
|
|
30
|
+
captureMessageWithOptions(message: string, level?: Sentry.SeverityLevel, options?: {
|
|
31
|
+
context?: string;
|
|
32
|
+
metadata?: any;
|
|
33
|
+
tags?: Record<string, string>;
|
|
34
|
+
extra?: Record<string, any>;
|
|
35
|
+
}): string;
|
|
36
|
+
captureExceptionWithContext(exception: any, options?: {
|
|
37
|
+
context?: string;
|
|
38
|
+
metadata?: any;
|
|
39
|
+
tags?: Record<string, string>;
|
|
40
|
+
extra?: Record<string, any>;
|
|
41
|
+
level?: Sentry.SeverityLevel;
|
|
42
|
+
}): string;
|
|
43
|
+
withSpan<T>(spanContext: {
|
|
44
|
+
name: string;
|
|
45
|
+
op?: string;
|
|
46
|
+
description?: string;
|
|
47
|
+
}, callback: () => T | Promise<T>): T | Promise<T>;
|
|
48
|
+
setGlobalUser(user: {
|
|
49
|
+
id?: string | number;
|
|
50
|
+
email?: string;
|
|
51
|
+
username?: string;
|
|
52
|
+
[key: string]: any;
|
|
53
|
+
}): void;
|
|
54
|
+
setGlobalTags(tags: Record<string, string>): void;
|
|
55
|
+
clearUser(): void;
|
|
56
|
+
}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var SentryService_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.SentryService = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const config_1 = require("@nestjs/config");
|
|
16
|
+
const Sentry = require("@sentry/nestjs");
|
|
17
|
+
const profiling_node_1 = require("@sentry/profiling-node");
|
|
18
|
+
let SentryService = SentryService_1 = class SentryService {
|
|
19
|
+
constructor(configService) {
|
|
20
|
+
this.configService = configService;
|
|
21
|
+
this.logger = new common_1.Logger(SentryService_1.name);
|
|
22
|
+
this.isInitialized = false;
|
|
23
|
+
}
|
|
24
|
+
async onModuleInit() {
|
|
25
|
+
await this.initializeSentry();
|
|
26
|
+
}
|
|
27
|
+
async initializeSentry() {
|
|
28
|
+
const sentryConfig = this.configService.get('sentry');
|
|
29
|
+
if (!sentryConfig?.enabled || !sentryConfig.dsn) {
|
|
30
|
+
this.logger.warn('Sentry is disabled or DSN is not provided');
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const integrations = this.buildIntegrations(sentryConfig);
|
|
35
|
+
Sentry.init({
|
|
36
|
+
dsn: sentryConfig.dsn,
|
|
37
|
+
environment: sentryConfig.environment,
|
|
38
|
+
release: sentryConfig.release,
|
|
39
|
+
debug: sentryConfig.debug,
|
|
40
|
+
tracesSampleRate: sentryConfig.tracesSampleRate,
|
|
41
|
+
profilesSampleRate: sentryConfig.profilesSampleRate,
|
|
42
|
+
integrations,
|
|
43
|
+
beforeSend: sentryConfig.beforeSend || this.defaultBeforeSend.bind(this),
|
|
44
|
+
beforeSendTransaction: sentryConfig.beforeSendTransaction || this.defaultBeforeSendTransaction.bind(this),
|
|
45
|
+
attachStacktrace: true,
|
|
46
|
+
sendDefaultPii: false,
|
|
47
|
+
});
|
|
48
|
+
this.isInitialized = true;
|
|
49
|
+
this.logger.log(`Sentry initialized successfully for environment: ${sentryConfig.environment}`);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
this.logger.error('Failed to initialize Sentry', error.stack);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
buildIntegrations(config) {
|
|
56
|
+
const integrations = [
|
|
57
|
+
Sentry.httpIntegration(),
|
|
58
|
+
Sentry.expressIntegration(),
|
|
59
|
+
];
|
|
60
|
+
if (config.profilesSampleRate > 0) {
|
|
61
|
+
integrations.push((0, profiling_node_1.nodeProfilingIntegration)());
|
|
62
|
+
}
|
|
63
|
+
if (config.integrations?.graphql !== false) {
|
|
64
|
+
integrations.push(Sentry.graphqlIntegration());
|
|
65
|
+
}
|
|
66
|
+
if (config.integrations?.mongo !== false) {
|
|
67
|
+
integrations.push(Sentry.mongoIntegration());
|
|
68
|
+
}
|
|
69
|
+
return integrations;
|
|
70
|
+
}
|
|
71
|
+
defaultBeforeSend(event) {
|
|
72
|
+
if (event.exception) {
|
|
73
|
+
const error = event.exception.values?.[0];
|
|
74
|
+
if (error?.type === 'ValidationError' || error?.type === 'BadRequestException') {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (event.request?.data) {
|
|
79
|
+
event.request.data = this.sanitizeData(event.request.data);
|
|
80
|
+
}
|
|
81
|
+
return event;
|
|
82
|
+
}
|
|
83
|
+
defaultBeforeSendTransaction(event) {
|
|
84
|
+
if (event.transaction?.includes('health') || event.transaction?.includes('metrics')) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
return event;
|
|
88
|
+
}
|
|
89
|
+
sanitizeData(data) {
|
|
90
|
+
if (typeof data !== 'object' || data === null) {
|
|
91
|
+
return data;
|
|
92
|
+
}
|
|
93
|
+
const sensitiveFields = ['password', 'token', 'authorization', 'secret', 'key', 'credential'];
|
|
94
|
+
const sanitized = { ...data };
|
|
95
|
+
for (const field of sensitiveFields) {
|
|
96
|
+
if (field in sanitized) {
|
|
97
|
+
sanitized[field] = '[REDACTED]';
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return sanitized;
|
|
101
|
+
}
|
|
102
|
+
captureException(exception, context) {
|
|
103
|
+
if (!this.isInitialized) {
|
|
104
|
+
this.logger.warn('Sentry not initialized, cannot capture exception');
|
|
105
|
+
return '';
|
|
106
|
+
}
|
|
107
|
+
return Sentry.captureException(exception, {
|
|
108
|
+
tags: context ? { context } : undefined,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
captureMessage(message, level = 'info', context) {
|
|
112
|
+
if (!this.isInitialized) {
|
|
113
|
+
this.logger.warn('Sentry not initialized, cannot capture message');
|
|
114
|
+
return '';
|
|
115
|
+
}
|
|
116
|
+
return Sentry.captureMessage(message, {
|
|
117
|
+
level,
|
|
118
|
+
tags: context ? { context } : undefined,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
addBreadcrumb(breadcrumb) {
|
|
122
|
+
if (!this.isInitialized) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
Sentry.addBreadcrumb(breadcrumb);
|
|
126
|
+
}
|
|
127
|
+
setUser(user) {
|
|
128
|
+
if (!this.isInitialized) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
Sentry.setUser(user);
|
|
132
|
+
}
|
|
133
|
+
setTag(key, value) {
|
|
134
|
+
if (!this.isInitialized) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
Sentry.setTag(key, value);
|
|
138
|
+
}
|
|
139
|
+
setContext(key, context) {
|
|
140
|
+
if (!this.isInitialized) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
Sentry.setContext(key, context);
|
|
144
|
+
}
|
|
145
|
+
withScope(callback) {
|
|
146
|
+
if (!this.isInitialized) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
Sentry.withScope(callback);
|
|
150
|
+
}
|
|
151
|
+
startSpan(context, callback) {
|
|
152
|
+
if (!this.isInitialized) {
|
|
153
|
+
return callback();
|
|
154
|
+
}
|
|
155
|
+
return Sentry.startSpan(context, callback);
|
|
156
|
+
}
|
|
157
|
+
getCurrentScope() {
|
|
158
|
+
return Sentry.getCurrentScope();
|
|
159
|
+
}
|
|
160
|
+
flush(timeout) {
|
|
161
|
+
if (!this.isInitialized) {
|
|
162
|
+
return Promise.resolve(false);
|
|
163
|
+
}
|
|
164
|
+
return Sentry.flush(timeout);
|
|
165
|
+
}
|
|
166
|
+
close(timeout) {
|
|
167
|
+
if (!this.isInitialized) {
|
|
168
|
+
return Promise.resolve(false);
|
|
169
|
+
}
|
|
170
|
+
return Sentry.close(timeout);
|
|
171
|
+
}
|
|
172
|
+
isEnabled() {
|
|
173
|
+
return this.isInitialized;
|
|
174
|
+
}
|
|
175
|
+
captureMessageWithOptions(message, level = 'info', options = {}) {
|
|
176
|
+
if (!this.isInitialized) {
|
|
177
|
+
this.logger.warn('Sentry not initialized, cannot capture message');
|
|
178
|
+
return '';
|
|
179
|
+
}
|
|
180
|
+
return Sentry.withScope((scope) => {
|
|
181
|
+
scope.setLevel(level);
|
|
182
|
+
if (options.context) {
|
|
183
|
+
scope.setTag('context', options.context);
|
|
184
|
+
}
|
|
185
|
+
if (options.tags) {
|
|
186
|
+
Object.entries(options.tags).forEach(([key, value]) => {
|
|
187
|
+
scope.setTag(key, value);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
if (options.metadata) {
|
|
191
|
+
scope.setContext('metadata', this.sanitizeData(options.metadata));
|
|
192
|
+
}
|
|
193
|
+
if (options.extra) {
|
|
194
|
+
scope.setContext('extra', this.sanitizeData(options.extra));
|
|
195
|
+
}
|
|
196
|
+
return Sentry.captureMessage(message, level);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
captureExceptionWithContext(exception, options = {}) {
|
|
200
|
+
if (!this.isInitialized) {
|
|
201
|
+
this.logger.warn('Sentry not initialized, cannot capture exception');
|
|
202
|
+
return '';
|
|
203
|
+
}
|
|
204
|
+
return Sentry.withScope((scope) => {
|
|
205
|
+
scope.setLevel(options.level || 'error');
|
|
206
|
+
if (options.context) {
|
|
207
|
+
scope.setTag('context', options.context);
|
|
208
|
+
}
|
|
209
|
+
if (options.tags) {
|
|
210
|
+
Object.entries(options.tags).forEach(([key, value]) => {
|
|
211
|
+
scope.setTag(key, value);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
if (options.metadata) {
|
|
215
|
+
scope.setContext('metadata', this.sanitizeData(options.metadata));
|
|
216
|
+
}
|
|
217
|
+
if (options.extra) {
|
|
218
|
+
scope.setContext('extra', this.sanitizeData(options.extra));
|
|
219
|
+
}
|
|
220
|
+
return Sentry.captureException(exception);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
withSpan(spanContext, callback) {
|
|
224
|
+
if (!this.isInitialized) {
|
|
225
|
+
return callback();
|
|
226
|
+
}
|
|
227
|
+
return Sentry.startSpan(spanContext, callback);
|
|
228
|
+
}
|
|
229
|
+
setGlobalUser(user) {
|
|
230
|
+
if (!this.isInitialized) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
Sentry.setUser(this.sanitizeData(user));
|
|
234
|
+
}
|
|
235
|
+
setGlobalTags(tags) {
|
|
236
|
+
if (!this.isInitialized) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
Object.entries(tags).forEach(([key, value]) => {
|
|
240
|
+
Sentry.setTag(key, value);
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
clearUser() {
|
|
244
|
+
if (!this.isInitialized) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
Sentry.setUser(null);
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
exports.SentryService = SentryService;
|
|
251
|
+
exports.SentryService = SentryService = SentryService_1 = __decorate([
|
|
252
|
+
(0, common_1.Injectable)(),
|
|
253
|
+
__metadata("design:paramtypes", [config_1.ConfigService])
|
|
254
|
+
], SentryService);
|
|
255
|
+
//# sourceMappingURL=sentry.service.js.map
|
|
@@ -0,0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AM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;IACL,CAAC;IAKD,SAAS;QACP,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACxB,OAAO;QACT,CAAC;QAED,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;CACF,CAAA;AApWY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;qCAKiC,sBAAa;GAJ9C,aAAa,CAoWzB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface SentryUser {
|
|
2
|
+
id?: string | number;
|
|
3
|
+
email?: string;
|
|
4
|
+
username?: string;
|
|
5
|
+
ip_address?: string;
|
|
6
|
+
segment?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface SentryBreadcrumb {
|
|
9
|
+
message?: string;
|
|
10
|
+
category?: string;
|
|
11
|
+
level?: 'fatal' | 'error' | 'warning' | 'log' | 'info' | 'debug';
|
|
12
|
+
data?: Record<string, any>;
|
|
13
|
+
timestamp?: number;
|
|
14
|
+
type?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface SentrySpanContext {
|
|
17
|
+
name: string;
|
|
18
|
+
op?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
data?: Record<string, any>;
|
|
21
|
+
tags?: Record<string, string>;
|
|
22
|
+
}
|
|
23
|
+
export interface SentryErrorContext {
|
|
24
|
+
tags?: Record<string, string>;
|
|
25
|
+
extra?: Record<string, any>;
|
|
26
|
+
user?: SentryUser;
|
|
27
|
+
level?: 'fatal' | 'error' | 'warning' | 'log' | 'info' | 'debug';
|
|
28
|
+
fingerprint?: string[];
|
|
29
|
+
}
|
|
30
|
+
export type SentryLevel = 'fatal' | 'error' | 'warning' | 'log' | 'info' | 'debug';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sentry/types/index.ts"],"names":[],"mappings":""}
|
package/dist/shared.module.js
CHANGED
|
@@ -14,6 +14,7 @@ const mongodb_module_1 = require("./database/mongodb/mongodb.module");
|
|
|
14
14
|
const cluster_module_1 = require("./cluster/modules/cluster.module");
|
|
15
15
|
const redis_module_1 = require("./database/redis/redis.module");
|
|
16
16
|
const schema_module_1 = require("./schemas/schema.module");
|
|
17
|
+
const sentry_module_1 = require("./sentry/sentry.module");
|
|
17
18
|
let SharedModule = class SharedModule {
|
|
18
19
|
};
|
|
19
20
|
exports.SharedModule = SharedModule;
|
|
@@ -30,6 +31,7 @@ exports.SharedModule = SharedModule = __decorate([
|
|
|
30
31
|
cluster_module_1.ClusterModule,
|
|
31
32
|
redis_module_1.RedisModule,
|
|
32
33
|
schema_module_1.SchemaModule,
|
|
34
|
+
sentry_module_1.SentryModule,
|
|
33
35
|
],
|
|
34
36
|
exports: [
|
|
35
37
|
config_1.ConfigModule,
|
|
@@ -38,6 +40,7 @@ exports.SharedModule = SharedModule = __decorate([
|
|
|
38
40
|
cluster_module_1.ClusterModule,
|
|
39
41
|
redis_module_1.RedisModule,
|
|
40
42
|
schema_module_1.SchemaModule,
|
|
43
|
+
sentry_module_1.SentryModule,
|
|
41
44
|
],
|
|
42
45
|
providers: [],
|
|
43
46
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.module.js","sourceRoot":"","sources":["../src/shared.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAgD;AAChD,2CAA8C;AAC9C,0DAAsD;AACtD,sEAAkE;AAClE,qEAAiE;AACjE,gEAA4D;AAG5D,2DAAuD;
|
|
1
|
+
{"version":3,"file":"shared.module.js","sourceRoot":"","sources":["../src/shared.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAgD;AAChD,2CAA8C;AAC9C,0DAAsD;AACtD,sEAAkE;AAClE,qEAAiE;AACjE,gEAA4D;AAG5D,2DAAuD;AACvD,0DAAsD;AA4B/C,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAI,CAAA;AAAhB,oCAAY;uBAAZ,YAAY;IA1BxB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,qBAAY,CAAC,OAAO,CAAC;gBACnB,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,CAAC,WAAW,EAAE,YAAY,EAAE,UAAU,CAAC;aACrD,CAAC;YAEF,8BAAa;YACb,4BAAY;YACZ,8BAAa;YACb,0BAAW;YACX,4BAAY;YACZ,4BAAY;SACb;QACD,OAAO,EAAE;YACP,qBAAY;YACZ,8BAAa;YACb,4BAAY;YACZ,8BAAa;YACb,0BAAW;YACX,4BAAY;YACZ,4BAAY;SACb;QACD,SAAS,EAAE,EAAE;KACd,CAAC;GACW,YAAY,CAAI"}
|