@eventista/ticketing-common 1.0.1045 → 1.1.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.
Files changed (96) hide show
  1. package/dist/exception/examples/error-test.example.d.ts +14 -0
  2. package/dist/exception/examples/error-test.example.js +91 -0
  3. package/dist/exception/examples/error-test.example.js.map +1 -0
  4. package/dist/exception/exception.filter.d.ts +4 -0
  5. package/dist/exception/exception.filter.js +89 -0
  6. package/dist/exception/exception.filter.js.map +1 -1
  7. package/dist/exception/unified-exception.filter.d.ts +9 -0
  8. package/dist/exception/unified-exception.filter.js +152 -0
  9. package/dist/exception/unified-exception.filter.js.map +1 -0
  10. package/dist/index.d.ts +2 -0
  11. package/dist/index.js +2 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/logger/custom.logger.d.ts +5 -1
  14. package/dist/logger/custom.logger.js +27 -0
  15. package/dist/logger/custom.logger.js.map +1 -1
  16. package/dist/logger/examples/logger-sentry.example.d.ts +32 -0
  17. package/dist/logger/examples/logger-sentry.example.js +211 -0
  18. package/dist/logger/examples/logger-sentry.example.js.map +1 -0
  19. package/dist/schemas/gift-record/gift-record.interfaces.d.ts +1 -0
  20. package/dist/schemas/gift-record/gift-record.interfaces.js +1 -0
  21. package/dist/schemas/gift-record/gift-record.interfaces.js.map +1 -1
  22. package/dist/schemas/gift-record/gift-record.schema.d.ts +3 -2
  23. package/dist/schemas/gift-record/gift-record.schema.js +7 -3
  24. package/dist/schemas/gift-record/gift-record.schema.js.map +1 -1
  25. package/dist/schemas/ticket-classes/ticket-classes.interfaces.d.ts +1 -0
  26. package/dist/schemas/ticket-classes/ticket-classes.schemas.d.ts +1 -0
  27. package/dist/schemas/ticket-classes/ticket-classes.schemas.js +6 -0
  28. package/dist/schemas/ticket-classes/ticket-classes.schemas.js.map +1 -1
  29. package/dist/schemas/zones/zone.schema.js.map +1 -1
  30. package/dist/sentry/config/api-tracking.config.d.ts +11 -0
  31. package/dist/sentry/config/api-tracking.config.js +55 -0
  32. package/dist/sentry/config/api-tracking.config.js.map +1 -0
  33. package/dist/sentry/decorators/index.d.ts +2 -0
  34. package/dist/sentry/decorators/index.js +19 -0
  35. package/dist/sentry/decorators/index.js.map +1 -0
  36. package/dist/sentry/decorators/sentry-capture.decorator.d.ts +9 -0
  37. package/dist/sentry/decorators/sentry-capture.decorator.js +13 -0
  38. package/dist/sentry/decorators/sentry-capture.decorator.js.map +1 -0
  39. package/dist/sentry/decorators/sentry-trace.decorator.d.ts +9 -0
  40. package/dist/sentry/decorators/sentry-trace.decorator.js +8 -0
  41. package/dist/sentry/decorators/sentry-trace.decorator.js.map +1 -0
  42. package/dist/sentry/examples/interceptor-test.example.d.ts +11 -0
  43. package/dist/sentry/examples/interceptor-test.example.js +50 -0
  44. package/dist/sentry/examples/interceptor-test.example.js.map +1 -0
  45. package/dist/sentry/examples/optimized-usage.example.d.ts +33 -0
  46. package/dist/sentry/examples/optimized-usage.example.js +300 -0
  47. package/dist/sentry/examples/optimized-usage.example.js.map +1 -0
  48. package/dist/sentry/examples/sentry-usage.example.d.ts +39 -0
  49. package/dist/sentry/examples/sentry-usage.example.js +262 -0
  50. package/dist/sentry/examples/sentry-usage.example.js.map +1 -0
  51. package/dist/sentry/index.d.ts +11 -0
  52. package/dist/sentry/index.js +28 -0
  53. package/dist/sentry/index.js.map +1 -0
  54. package/dist/sentry/interceptors/api-stats.interceptor.d.ts +13 -0
  55. package/dist/sentry/interceptors/api-stats.interceptor.js +189 -0
  56. package/dist/sentry/interceptors/api-stats.interceptor.js.map +1 -0
  57. package/dist/sentry/interceptors/index.d.ts +3 -0
  58. package/dist/sentry/interceptors/index.js +20 -0
  59. package/dist/sentry/interceptors/index.js.map +1 -0
  60. package/dist/sentry/interceptors/sentry-capture.interceptor.d.ts +8 -0
  61. package/dist/sentry/interceptors/sentry-capture.interceptor.js +80 -0
  62. package/dist/sentry/interceptors/sentry-capture.interceptor.js.map +1 -0
  63. package/dist/sentry/interceptors/sentry-trace.interceptor.d.ts +8 -0
  64. package/dist/sentry/interceptors/sentry-trace.interceptor.js +56 -0
  65. package/dist/sentry/interceptors/sentry-trace.interceptor.js.map +1 -0
  66. package/dist/sentry/sentry-logger.helper.d.ts +22 -0
  67. package/dist/sentry/sentry-logger.helper.js +153 -0
  68. package/dist/sentry/sentry-logger.helper.js.map +1 -0
  69. package/dist/sentry/sentry-safe.module.d.ts +12 -0
  70. package/dist/sentry/sentry-safe.module.js +89 -0
  71. package/dist/sentry/sentry-safe.module.js.map +1 -0
  72. package/dist/sentry/sentry.advanced-config.d.ts +35 -0
  73. package/dist/sentry/sentry.advanced-config.js +99 -0
  74. package/dist/sentry/sentry.advanced-config.js.map +1 -0
  75. package/dist/sentry/sentry.config.d.ts +21 -0
  76. package/dist/sentry/sentry.config.js +20 -0
  77. package/dist/sentry/sentry.config.js.map +1 -0
  78. package/dist/sentry/sentry.filter.d.ts +12 -0
  79. package/dist/sentry/sentry.filter.js +139 -0
  80. package/dist/sentry/sentry.filter.js.map +1 -0
  81. package/dist/sentry/sentry.interceptor.d.ts +9 -0
  82. package/dist/sentry/sentry.interceptor.js +80 -0
  83. package/dist/sentry/sentry.interceptor.js.map +1 -0
  84. package/dist/sentry/sentry.module.d.ts +2 -0
  85. package/dist/sentry/sentry.module.js +50 -0
  86. package/dist/sentry/sentry.module.js.map +1 -0
  87. package/dist/sentry/sentry.service.d.ts +56 -0
  88. package/dist/sentry/sentry.service.js +258 -0
  89. package/dist/sentry/sentry.service.js.map +1 -0
  90. package/dist/sentry/types/index.d.ts +30 -0
  91. package/dist/sentry/types/index.js +3 -0
  92. package/dist/sentry/types/index.js.map +1 -0
  93. package/dist/shared.module.js +3 -0
  94. package/dist/shared.module.js.map +1 -1
  95. package/dist/tsconfig.tsbuildinfo +1 -1
  96. package/package.json +3 -1
@@ -0,0 +1,14 @@
1
+ export declare class ErrorTestController {
2
+ test500Error(): void;
3
+ testDatabaseError(): void;
4
+ testValidationError(data: any): {
5
+ success: boolean;
6
+ };
7
+ testTimeoutError(): Promise<void>;
8
+ testUserError(id: string): {
9
+ user: {
10
+ id: string;
11
+ name: string;
12
+ };
13
+ };
14
+ }
@@ -0,0 +1,91 @@
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 __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.ErrorTestController = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ let ErrorTestController = class ErrorTestController {
18
+ test500Error() {
19
+ throw new Error('Test 500 error for Sentry tracking');
20
+ }
21
+ testDatabaseError() {
22
+ const error = new Error('Database connection timeout');
23
+ error.name = 'DatabaseError';
24
+ error.code = 'ECONNREFUSED';
25
+ error.errno = -61;
26
+ error.syscall = 'connect';
27
+ throw error;
28
+ }
29
+ testValidationError(data) {
30
+ if (!data.email) {
31
+ const error = new Error('Email is required');
32
+ error.name = 'ValidationError';
33
+ throw error;
34
+ }
35
+ return { success: true };
36
+ }
37
+ async testTimeoutError() {
38
+ await new Promise((_, reject) => {
39
+ setTimeout(() => {
40
+ const error = new Error('Request timeout after 30 seconds');
41
+ error.name = 'TimeoutError';
42
+ reject(error);
43
+ }, 100);
44
+ });
45
+ }
46
+ testUserError(id) {
47
+ if (id === 'invalid') {
48
+ const error = new Error(`User with ID ${id} not found`);
49
+ error.name = 'UserNotFoundError';
50
+ throw error;
51
+ }
52
+ return { user: { id, name: 'Test User' } };
53
+ }
54
+ };
55
+ exports.ErrorTestController = ErrorTestController;
56
+ __decorate([
57
+ (0, common_1.Get)('500'),
58
+ __metadata("design:type", Function),
59
+ __metadata("design:paramtypes", []),
60
+ __metadata("design:returntype", void 0)
61
+ ], ErrorTestController.prototype, "test500Error", null);
62
+ __decorate([
63
+ (0, common_1.Get)('database'),
64
+ __metadata("design:type", Function),
65
+ __metadata("design:paramtypes", []),
66
+ __metadata("design:returntype", void 0)
67
+ ], ErrorTestController.prototype, "testDatabaseError", null);
68
+ __decorate([
69
+ (0, common_1.Post)('validation'),
70
+ __param(0, (0, common_1.Body)()),
71
+ __metadata("design:type", Function),
72
+ __metadata("design:paramtypes", [Object]),
73
+ __metadata("design:returntype", void 0)
74
+ ], ErrorTestController.prototype, "testValidationError", null);
75
+ __decorate([
76
+ (0, common_1.Get)('timeout'),
77
+ __metadata("design:type", Function),
78
+ __metadata("design:paramtypes", []),
79
+ __metadata("design:returntype", Promise)
80
+ ], ErrorTestController.prototype, "testTimeoutError", null);
81
+ __decorate([
82
+ (0, common_1.Get)('user/:id'),
83
+ __param(0, (0, common_1.Param)('id')),
84
+ __metadata("design:type", Function),
85
+ __metadata("design:paramtypes", [String]),
86
+ __metadata("design:returntype", void 0)
87
+ ], ErrorTestController.prototype, "testUserError", null);
88
+ exports.ErrorTestController = ErrorTestController = __decorate([
89
+ (0, common_1.Controller)('test-errors')
90
+ ], ErrorTestController);
91
+ //# sourceMappingURL=error-test.example.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-test.example.js","sourceRoot":"","sources":["../../../src/exception/examples/error-test.example.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoE;AAG7D,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAG9B,YAAY;QACV,MAAM,IAAI,KAAK,CAAC,oC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E,EAAE,CAAC;IAC7C,CAAC;CACF,CAAA;AAhDY,kDAAmB;AAG9B;IADC,IAAA,YAAG,EAAC,KAAK,CAAC;;;;uDAGV;AAGD;IADC,IAAA,YAAG,EAAC,UAAU,CAAC;;;;4DAQf;AAGD;IADC,IAAA,aAAI,EAAC,YAAY,CAAC;IACE,WAAA,IAAA,aAAI,GAAE,CAAA;;;;8DAO1B;AAGK;IADL,IAAA,YAAG,EAAC,SAAS,CAAC;;;;2DAUd;AAGD;IADC,IAAA,YAAG,EAAC,UAAU,CAAC;IACD,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;wDAOzB;8BA/CU,mBAAmB;IAD/B,IAAA,mBAAU,EAAC,aAAa,CAAC;GACb,mBAAmB,CAgD/B"}
@@ -2,5 +2,9 @@ import { ArgumentsHost, ExceptionFilter } from '@nestjs/common';
2
2
  export declare class GlobalExceptionFilter implements ExceptionFilter {
3
3
  private readonly logger;
4
4
  catch(exception: any, host: ArgumentsHost): any;
5
+ private captureToSentry;
6
+ private getStatusMessage;
7
+ private sanitizeHeaders;
8
+ private sanitizeBody;
5
9
  private logError;
6
10
  }
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.GlobalExceptionFilter = void 0;
11
11
  const common_1 = require("@nestjs/common");
12
12
  const custom_logger_1 = require("../logger/custom.logger");
13
+ const sentry_logger_helper_1 = require("../sentry/sentry-logger.helper");
13
14
  let GlobalExceptionFilter = GlobalExceptionFilter_1 = class GlobalExceptionFilter {
14
15
  constructor() {
15
16
  this.logger = new custom_logger_1.CustomLogger(GlobalExceptionFilter_1.name);
@@ -21,6 +22,9 @@ let GlobalExceptionFilter = GlobalExceptionFilter_1 = class GlobalExceptionFilte
21
22
  const status = exception instanceof common_1.HttpException
22
23
  ? exception.getStatus()
23
24
  : common_1.HttpStatus.INTERNAL_SERVER_ERROR;
25
+ if (status >= 500 || !(exception instanceof common_1.HttpException)) {
26
+ this.captureToSentry(exception, request, status);
27
+ }
24
28
  if (status === common_1.HttpStatus.BAD_REQUEST && exception instanceof common_1.HttpException) {
25
29
  const exceptionResponse = exception.getResponse();
26
30
  if (exceptionResponse.message === 'Validation failed' && exceptionResponse.errors) {
@@ -58,6 +62,91 @@ let GlobalExceptionFilter = GlobalExceptionFilter_1 = class GlobalExceptionFilte
58
62
  this.logError(exception, request);
59
63
  response.status(status).send(errorResponse);
60
64
  }
65
+ captureToSentry(exception, request, status) {
66
+ try {
67
+ sentry_logger_helper_1.SentryLoggerHelper.captureException(exception, `HTTP ${status} Error: ${exception.message}`, 'GlobalExceptionFilter', {
68
+ enabled: true,
69
+ rateLimitPerMinute: 60,
70
+ });
71
+ sentry_logger_helper_1.SentryLoggerHelper.captureMessage(`Server Error ${status}: ${request.method} ${request.url}`, 'error', 'GlobalExceptionFilter', {
72
+ exception: {
73
+ name: exception.name,
74
+ message: exception.message,
75
+ stack: exception.stack,
76
+ code: exception.code || null,
77
+ errno: exception.errno || null,
78
+ syscall: exception.syscall || null,
79
+ },
80
+ request: {
81
+ method: request.method,
82
+ url: request.url,
83
+ originalUrl: request.originalUrl,
84
+ baseUrl: request.baseUrl,
85
+ path: request.path,
86
+ headers: this.sanitizeHeaders(request.headers),
87
+ query: request.query,
88
+ body: this.sanitizeBody(request.body),
89
+ params: request.params,
90
+ ip: request.ip,
91
+ },
92
+ response: {
93
+ statusCode: status,
94
+ statusMessage: this.getStatusMessage(status),
95
+ },
96
+ user: request.user ? {
97
+ id: request.user.id || request.user.sub,
98
+ email: request.user.email,
99
+ username: request.user.username,
100
+ } : null,
101
+ context: {
102
+ timestamp: new Date().toISOString(),
103
+ environment: process.env.NODE_ENV,
104
+ service: process.env.SERVICE_NAME || 'unknown',
105
+ version: process.env.npm_package_version || 'unknown',
106
+ },
107
+ }, {
108
+ enabled: true,
109
+ sensitiveFields: ['password', 'token', 'authorization', 'cookie', 'secret'],
110
+ });
111
+ }
112
+ catch (error) {
113
+ console.error('Failed to capture exception to Sentry:', error);
114
+ }
115
+ }
116
+ getStatusMessage(status) {
117
+ const statusMessages = {
118
+ 500: 'Internal Server Error',
119
+ 501: 'Not Implemented',
120
+ 502: 'Bad Gateway',
121
+ 503: 'Service Unavailable',
122
+ 504: 'Gateway Timeout',
123
+ 505: 'HTTP Version Not Supported',
124
+ };
125
+ return statusMessages[status] || 'Unknown Error';
126
+ }
127
+ sanitizeHeaders(headers) {
128
+ const sensitiveHeaders = ['authorization', 'cookie', 'x-api-key', 'x-auth-token'];
129
+ const sanitized = { ...headers };
130
+ for (const header of sensitiveHeaders) {
131
+ if (header in sanitized) {
132
+ sanitized[header] = '[REDACTED]';
133
+ }
134
+ }
135
+ return sanitized;
136
+ }
137
+ sanitizeBody(body) {
138
+ if (!body || typeof body !== 'object') {
139
+ return body;
140
+ }
141
+ const sensitiveFields = ['password', 'token', 'authorization', 'secret', 'key', 'credential'];
142
+ const sanitized = { ...body };
143
+ for (const field of sensitiveFields) {
144
+ if (field in sanitized) {
145
+ sanitized[field] = '[REDACTED]';
146
+ }
147
+ }
148
+ return sanitized;
149
+ }
61
150
  logError(exception, request) {
62
151
  const status = exception instanceof common_1.HttpException
63
152
  ? exception.getStatus()
@@ -1 +1 @@
1
- {"version":3,"file":"exception.filter.js","sourceRoot":"","sources":["../../src/exception/exception.filter.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAMwB;AACxB,2DAAuD;AAGhD,IAAM,qBAAqB,6BAA3B,MAAM,qBAAqB;IAA3B;QACY,WAAM,GAAG,IAAI,4BAAY,CAAC,uBAAqB,CAAC,IAAI,CAAC,CAAC;IA0FzE,CAAC;IAxFC,KAAK,CAAC,SAAc,EAAE,IAAmB;QACvC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC;QAGjC,MAAM,MAAM,GACV,SAAS,YAAY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EAAE,SAAS,CAAC,OAAO;gBAC1B,KAAK,EAAE,SAAS,CAAC,KAAK;aACvB;YACD,OAAO,EAAE;gBACP,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,MAAM,EAAE,OAAO,CAAC,MAAM;aACvB;YACD,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC,CACF,CAAC;IACJ,CAAC;CACF,CAAA;AAjNY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,cAAK,GAAE;GACK,qBAAqB,CAiNjC"}
@@ -0,0 +1,9 @@
1
+ import { ArgumentsHost, ExceptionFilter } from '@nestjs/common';
2
+ export declare class UnifiedExceptionFilter implements ExceptionFilter {
3
+ private readonly logger;
4
+ catch(exception: any, host: ArgumentsHost): any;
5
+ private captureToSentry;
6
+ private logError;
7
+ private sanitizeHeaders;
8
+ private sanitizeBody;
9
+ }
@@ -0,0 +1,152 @@
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 UnifiedExceptionFilter_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.UnifiedExceptionFilter = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ const custom_logger_1 = require("../logger/custom.logger");
13
+ const sentry_logger_helper_1 = require("../sentry/sentry-logger.helper");
14
+ let UnifiedExceptionFilter = UnifiedExceptionFilter_1 = class UnifiedExceptionFilter {
15
+ constructor() {
16
+ this.logger = new custom_logger_1.CustomLogger(UnifiedExceptionFilter_1.name);
17
+ }
18
+ catch(exception, host) {
19
+ const ctx = host.switchToHttp();
20
+ const response = ctx.getResponse();
21
+ const request = ctx.getRequest();
22
+ const status = exception instanceof common_1.HttpException
23
+ ? exception.getStatus()
24
+ : common_1.HttpStatus.INTERNAL_SERVER_ERROR;
25
+ if (status >= 500 || !(exception instanceof common_1.HttpException)) {
26
+ this.captureToSentry(exception, request, status);
27
+ }
28
+ if (status === common_1.HttpStatus.BAD_REQUEST && exception instanceof common_1.HttpException) {
29
+ const exceptionResponse = exception.getResponse();
30
+ if (exceptionResponse.message === 'Validation failed' && exceptionResponse.errors) {
31
+ const errorResponse = {
32
+ statusCode: status,
33
+ message: exceptionResponse.message,
34
+ errors: exceptionResponse.errors,
35
+ path: request.url,
36
+ timestamp: new Date().toISOString(),
37
+ data: exception instanceof common_1.HttpException ? exception.getResponse()['data'] : null,
38
+ };
39
+ return response.status(status).json(errorResponse);
40
+ }
41
+ }
42
+ if (exception instanceof common_1.HttpException) {
43
+ const exceptionResponse = exception.getResponse();
44
+ const errorResponse = {
45
+ statusCode: status,
46
+ errorCode: exceptionResponse.code || status,
47
+ message: exception.message,
48
+ path: request.url,
49
+ timestamp: new Date().toISOString(),
50
+ data: exception instanceof common_1.HttpException ? exception.getResponse()['data'] : null,
51
+ };
52
+ return response.status(status).json(errorResponse);
53
+ }
54
+ const errorResponse = {
55
+ statusCode: status,
56
+ errorCode: status,
57
+ message: 'Hệ thống đang bận, vui lòng thử lại sau.',
58
+ path: request.url,
59
+ timestamp: new Date().toISOString(),
60
+ data: null,
61
+ };
62
+ this.logError(exception, request, status);
63
+ response.status(status).json(errorResponse);
64
+ }
65
+ captureToSentry(exception, request, status) {
66
+ try {
67
+ sentry_logger_helper_1.SentryLoggerHelper.captureException(exception, `HTTP ${status} Error: ${exception.message}`, 'UnifiedExceptionFilter', {
68
+ enabled: true,
69
+ rateLimitPerMinute: 60,
70
+ });
71
+ sentry_logger_helper_1.SentryLoggerHelper.captureMessage(`Unhandled exception in ${request.method} ${request.url}`, 'error', 'UnifiedExceptionFilter', {
72
+ exception: {
73
+ name: exception.name,
74
+ message: exception.message,
75
+ stack: exception.stack,
76
+ },
77
+ request: {
78
+ method: request.method,
79
+ url: request.url,
80
+ headers: this.sanitizeHeaders(request.headers),
81
+ query: request.query,
82
+ body: this.sanitizeBody(request.body),
83
+ params: request.params,
84
+ },
85
+ response: {
86
+ statusCode: status,
87
+ },
88
+ }, {
89
+ enabled: true,
90
+ sensitiveFields: ['password', 'token', 'authorization', 'cookie'],
91
+ });
92
+ }
93
+ catch (error) {
94
+ console.error('Failed to capture exception to Sentry:', error);
95
+ }
96
+ }
97
+ logError(exception, request, status) {
98
+ const errorInfo = {
99
+ exception: {
100
+ name: exception.name,
101
+ message: exception.message,
102
+ stack: exception.stack,
103
+ },
104
+ request: {
105
+ method: request.method,
106
+ url: request.url,
107
+ headers: this.sanitizeHeaders(request.headers),
108
+ query: request.query,
109
+ body: this.sanitizeBody(request.body),
110
+ params: request.params,
111
+ },
112
+ response: {
113
+ statusCode: status,
114
+ },
115
+ timestamp: new Date().toISOString(),
116
+ };
117
+ if (status >= 500) {
118
+ this.logger.error(`[${request.method}] ${request.url} - Status: ${status}`, errorInfo);
119
+ }
120
+ else {
121
+ this.logger.warn(`[${request.method}] ${request.url} - Status: ${status}`, errorInfo);
122
+ }
123
+ }
124
+ sanitizeHeaders(headers) {
125
+ const sensitiveHeaders = ['authorization', 'cookie', 'x-api-key', 'x-auth-token'];
126
+ const sanitized = { ...headers };
127
+ for (const header of sensitiveHeaders) {
128
+ if (header in sanitized) {
129
+ sanitized[header] = '[REDACTED]';
130
+ }
131
+ }
132
+ return sanitized;
133
+ }
134
+ sanitizeBody(body) {
135
+ if (!body || typeof body !== 'object') {
136
+ return body;
137
+ }
138
+ const sensitiveFields = ['password', 'token', 'authorization', 'secret', 'key', 'credential'];
139
+ const sanitized = { ...body };
140
+ for (const field of sensitiveFields) {
141
+ if (field in sanitized) {
142
+ sanitized[field] = '[REDACTED]';
143
+ }
144
+ }
145
+ return sanitized;
146
+ }
147
+ };
148
+ exports.UnifiedExceptionFilter = UnifiedExceptionFilter;
149
+ exports.UnifiedExceptionFilter = UnifiedExceptionFilter = UnifiedExceptionFilter_1 = __decorate([
150
+ (0, common_1.Catch)()
151
+ ], UnifiedExceptionFilter);
152
+ //# sourceMappingURL=unified-exception.filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unified-exception.filter.js","sourceRoot":"","sources":["../../src/exception/unified-exception.filter.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAMwB;AACxB,2DAAuD;AACvD,yEAAoE;AAG7D,IAAM,sBAAsB,8BAA5B,MAAM,sBAAsB;IAA5B;QACY,WAAM,GAAG,IAAI,4BAAY,CAAC,wBAAsB,CAAC,IAAI,CAAC,CAAC;IA4K1E,CAAC;IA1KC,KAAK,CAAC,SAAc,EAAE,IAAmB;QACvC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC;QAEjC,MAAM,MAAM,GACV,SAAS,YAAY,sBAAa;YAChC,CAAC,CAAC,SAAS,CAAC,SAAS,EAAE;YACvB,CAAC,CAAC,mBAAU,CAAC,qBAAqB,CAAC;QAGvC,IAAI,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,SAAS,YAAY,sBAAa,CAAC,EAAE,CAAC;YAC3D,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QACnD,CAAC;QAGD,IAAI,MAAM,KAAK,mBAAU,CAAC,WAAW,IAAI,SAAS,YAAY,sBAAa,EAAE,CAAC;YAC5E,MAAM,iBAAiB,GAAG,SAAS,CAAC,WAAW,EAAS,CAAC;YAEzD,I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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;IAEO,YAAY,CAAC,IAAS;QAC5B,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YACtC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,eAAe,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;QAC9F,MAAM,SAAS,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;QAE9B,KAAK,MAAM,KAAK,IAAI,eAAe,EAAE,CAAC;YACpC,IAAI,KAAK,IAAI,SAAS,EAAE,CAAC;gBACvB,SAAS,CAAC,KAAK,CAAC,GAAG,YAAY,CAAC;YAClC,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF,CAAA;AA7KY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,cAAK,GAAE;GACK,sBAAsB,CA6KlC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './database';
2
2
  export * from './exception/exception.filter';
3
+ export * from './exception/unified-exception.filter';
3
4
  export * from './generic-repository';
4
5
  export * from './logger';
5
6
  export * from './pipes/custom-validation.pipe';
@@ -10,4 +11,5 @@ export * from './schemas/schema.module';
10
11
  export * from './cluster/index';
11
12
  export * from './decorators/index';
12
13
  export * from './auth/index';
14
+ export * from './sentry/index';
13
15
  export * from './shared.module';
package/dist/index.js CHANGED
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./database"), exports);
18
18
  __exportStar(require("./exception/exception.filter"), exports);
19
+ __exportStar(require("./exception/unified-exception.filter"), exports);
19
20
  __exportStar(require("./generic-repository"), exports);
20
21
  __exportStar(require("./logger"), exports);
21
22
  __exportStar(require("./pipes/custom-validation.pipe"), exports);
@@ -26,5 +27,6 @@ __exportStar(require("./schemas/schema.module"), exports);
26
27
  __exportStar(require("./cluster/index"), exports);
27
28
  __exportStar(require("./decorators/index"), exports);
28
29
  __exportStar(require("./auth/index"), exports);
30
+ __exportStar(require("./sentry/index"), exports);
29
31
  __exportStar(require("./shared.module"), exports);
30
32
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,6CAA2B;AAC3B,+DAA6C;AAC7C,uDAAqC;AAErC,2CAAyB;AAEzB,iEAA+C;AAC/C,kEAA+C;AAC/C,uEAAqD;AAErD,4CAA0B;AAC1B,0DAAwC;AAExC,kDAAgC;AAEhC,qDAAmC;AAEnC,+CAA6B;AAG7B,kDAAgC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,6CAA2B;AAC3B,+DAA6C;AAC7C,uEAAqD;AACrD,uDAAqC;AAErC,2CAAyB;AAEzB,iEAA+C;AAC/C,kEAA+C;AAC/C,uEAAqD;AAErD,4CAA0B;AAC1B,0DAAwC;AAExC,kDAAgC;AAEhC,qDAAmC;AAEnC,+CAA6B;AAE7B,iDAA+B;AAG/B,kDAAgC"}
@@ -2,13 +2,17 @@ import { LoggerService } from '@nestjs/common';
2
2
  export declare class CustomLogger implements LoggerService {
3
3
  private readonly context?;
4
4
  private readonly isProduction;
5
+ private readonly sentryOptions;
5
6
  constructor(context?: string);
7
+ private buildExcludePatterns;
6
8
  private getTimestamp;
7
9
  private formatMessage;
8
10
  private colorize;
11
+ private captureToSentry;
9
12
  log(message: string, context?: string): void;
10
13
  error(message: string, metadata?: any): void;
11
- warn(message: string, context?: string): void;
14
+ warn(message: string, context?: any): void;
12
15
  debug(message: string, context?: string): void;
13
16
  verbose(message: string, context?: string): void;
17
+ errorWithException(message: string, exception: Error, context?: string): void;
14
18
  }
@@ -2,10 +2,25 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CustomLogger = void 0;
4
4
  const colorette_1 = require("colorette");
5
+ const sentry_logger_helper_1 = require("../sentry/sentry-logger.helper");
5
6
  class CustomLogger {
6
7
  constructor(context) {
7
8
  this.context = context;
8
9
  this.isProduction = process.env.NODE_ENV === 'production';
10
+ this.sentryOptions = {
11
+ enabled: process.env.SENTRY_ENABLED?.toLowerCase() !== 'false' && !!process.env.SENTRY_DSN,
12
+ rateLimitPerMinute: parseInt(process.env.SENTRY_LOGGER_RATE_LIMIT || '30', 10),
13
+ excludePatterns: this.buildExcludePatterns(),
14
+ sensitiveFields: ['password', 'token', 'secret', 'key', 'credential'],
15
+ };
16
+ }
17
+ buildExcludePatterns() {
18
+ const patterns = [];
19
+ patterns.push(/health\s*check/i);
20
+ patterns.push(/ping/i);
21
+ patterns.push(/connection\s*established/i);
22
+ patterns.push(/server\s*started/i);
23
+ return patterns;
9
24
  }
10
25
  getTimestamp() {
11
26
  const localeStringOptions = {
@@ -49,6 +64,9 @@ class CustomLogger {
49
64
  return level;
50
65
  }
51
66
  }
67
+ captureToSentry(message, level, context, metadata) {
68
+ sentry_logger_helper_1.SentryLoggerHelper.captureMessage(message, level, context || this.context, metadata, this.sentryOptions);
69
+ }
52
70
  log(message, context) {
53
71
  console.log(this.formatMessage('LOG', message, context));
54
72
  }
@@ -61,9 +79,11 @@ class CustomLogger {
61
79
  else {
62
80
  console.error(baseLog);
63
81
  }
82
+ this.captureToSentry(message, 'error', this.context, metadata);
64
83
  }
65
84
  warn(message, context) {
66
85
  console.warn(this.formatMessage('WARN', message, context));
86
+ this.captureToSentry(message, 'warning', context);
67
87
  }
68
88
  debug(message, context) {
69
89
  console.debug(this.formatMessage('DEBUG', message, context));
@@ -71,6 +91,13 @@ class CustomLogger {
71
91
  verbose(message, context) {
72
92
  console.log(this.formatMessage('VERBOSE', message, context));
73
93
  }
94
+ errorWithException(message, exception, context) {
95
+ const baseLog = this.formatMessage('ERROR', message, context);
96
+ console.error(baseLog);
97
+ console.error((0, colorette_1.red)('Exception:'), exception.message);
98
+ console.error((0, colorette_1.red)('Stack:'), exception.stack);
99
+ sentry_logger_helper_1.SentryLoggerHelper.captureException(exception, message, context || this.context, this.sentryOptions);
100
+ }
74
101
  }
75
102
  exports.CustomLogger = CustomLogger;
76
103
  //# sourceMappingURL=custom.logger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"custom.logger.js","sourceRoot":"","sources":["../../src/logger/custom.logger.ts"],"names":[],"mappings":";;;AACA,yCAAiE;AAEjE,MAAa,YAAY;IAGvB,YAA6B,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;QAC3C,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;IAC5D,CAAC;IAGO,YAAY;QAClB,MAAM,mBAAmB,GAAG;YAC1B,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,SAAS;YACjB,MAAM,EAAE,SAAS;YACjB,GAAG,EAAE,SAAS;YACd,KAAK,EAAE,SAAS;SACjB,CAAC;QACF,OAAO,IAAI,IAAI,EAAE,CAAC,cAAc,CAAC,SAAS,EAAE,mBAAiD,CAAC,CAAC;IACjG,CAAC;IAEO,aAAa,CAAC,KAAa,EAAE,OAAe,EAAE,OAAgB;QACpE,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC,SAAS,CAAC;gBACpB,SAAS,EAAE,IAAI,CAAC,YAAY,EAAE;gBAC9B,GAAG,EAAE,O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,CAAC,KAAK,CAAC,CAAC;QAG9C,yCAAkB,CAAC,gBAAgB,CACjC,SAAS,EACT,OAAO,EACP,OAAO,IAAI,IAAI,CAAC,OAAO,EACvB,IAAI,CAAC,aAAa,CACnB,CAAC;IACJ,CAAC;CACF;AAtID,oCAsIC"}
@@ -0,0 +1,32 @@
1
+ export declare class ExampleServiceWithLogger {
2
+ private readonly logger;
3
+ processUserData(userData: any): Promise<any>;
4
+ handleDatabaseOperation(): Promise<void>;
5
+ handleExternalApiCall(): Promise<{
6
+ data: string;
7
+ }>;
8
+ demonstrateLogLevels(): void;
9
+ private simulateBusinessLogic;
10
+ private simulateDatabaseCall;
11
+ private simulateApiCall;
12
+ }
13
+ export declare class ExampleController {
14
+ private readonly exampleService;
15
+ private readonly logger;
16
+ constructor(exampleService: ExampleServiceWithLogger);
17
+ createUser(userData: any): Promise<any>;
18
+ healthCheck(): {
19
+ status: string;
20
+ timestamp: string;
21
+ };
22
+ testLogs(): {
23
+ message: string;
24
+ };
25
+ }
26
+ export declare class ErrorHandlingExamples {
27
+ private readonly logger;
28
+ simpleErrorHandling(): Promise<void>;
29
+ errorWithMetadata(): Promise<void>;
30
+ exceptionObjectLogging(): Promise<void>;
31
+ businessWarning(): Promise<void>;
32
+ }