@campxdev/server-shared 2.1.39 → 2.1.40

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 (74) hide show
  1. package/dist/common/filters/unhandled-exception.filter.d.ts +12 -0
  2. package/dist/common/filters/unhandled-exception.filter.d.ts.map +1 -0
  3. package/dist/common/filters/unhandled-exception.filter.js +46 -0
  4. package/dist/common/filters/unhandled-exception.filter.js.map +1 -0
  5. package/dist/common/guards/guard.d.ts +0 -2
  6. package/dist/common/guards/guard.d.ts.map +1 -1
  7. package/dist/common/guards/guard.js +1 -6
  8. package/dist/common/guards/guard.js.map +1 -1
  9. package/dist/common/index.d.ts +1 -0
  10. package/dist/common/index.d.ts.map +1 -1
  11. package/dist/common/index.js +1 -0
  12. package/dist/common/index.js.map +1 -1
  13. package/dist/common/interceptors/request.interceptor.d.ts +0 -2
  14. package/dist/common/interceptors/request.interceptor.d.ts.map +1 -1
  15. package/dist/common/interceptors/request.interceptor.js +0 -20
  16. package/dist/common/interceptors/request.interceptor.js.map +1 -1
  17. package/dist/common/interfaces/context.interface.d.ts +0 -1
  18. package/dist/common/interfaces/context.interface.d.ts.map +1 -1
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +1 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/microsoft/services/teams-meetings-graph.service.d.ts.map +1 -1
  24. package/dist/microsoft/services/teams-meetings-graph.service.js +1 -0
  25. package/dist/microsoft/services/teams-meetings-graph.service.js.map +1 -1
  26. package/dist/modules-handler/types/exams.types.d.ts +0 -2
  27. package/dist/modules-handler/types/exams.types.d.ts.map +1 -1
  28. package/dist/observability/index.d.ts +5 -0
  29. package/dist/observability/index.d.ts.map +1 -0
  30. package/dist/{sentry → observability}/index.js +4 -5
  31. package/dist/observability/index.js.map +1 -0
  32. package/dist/observability/telemetry.module.d.ts +4 -0
  33. package/dist/observability/telemetry.module.d.ts.map +1 -0
  34. package/dist/observability/telemetry.module.js +33 -0
  35. package/dist/observability/telemetry.module.js.map +1 -0
  36. package/dist/observability/telemetry.service.d.ts +10 -0
  37. package/dist/observability/telemetry.service.d.ts.map +1 -0
  38. package/dist/{sentry/sentry.service.js → observability/telemetry.service.js} +26 -45
  39. package/dist/observability/telemetry.service.js.map +1 -0
  40. package/dist/observability/traced.decorator.d.ts +6 -0
  41. package/dist/observability/traced.decorator.d.ts.map +1 -0
  42. package/dist/observability/traced.decorator.js +51 -0
  43. package/dist/observability/traced.decorator.js.map +1 -0
  44. package/dist/observability/tracing.interceptor.d.ts +14 -0
  45. package/dist/observability/tracing.interceptor.d.ts.map +1 -0
  46. package/dist/observability/tracing.interceptor.js +119 -0
  47. package/dist/observability/tracing.interceptor.js.map +1 -0
  48. package/dist/otel-sdk.d.ts +10 -0
  49. package/dist/otel-sdk.d.ts.map +1 -0
  50. package/dist/otel-sdk.js +154 -0
  51. package/dist/otel-sdk.js.map +1 -0
  52. package/package.json +1 -1
  53. package/dist/sentry/index.d.ts +0 -6
  54. package/dist/sentry/index.d.ts.map +0 -1
  55. package/dist/sentry/index.js.map +0 -1
  56. package/dist/sentry/sentry-http.filter.d.ts +0 -6
  57. package/dist/sentry/sentry-http.filter.d.ts.map +0 -1
  58. package/dist/sentry/sentry-http.filter.js +0 -89
  59. package/dist/sentry/sentry-http.filter.js.map +0 -1
  60. package/dist/sentry/sentry-rpc.filter.d.ts +0 -5
  61. package/dist/sentry/sentry-rpc.filter.d.ts.map +0 -1
  62. package/dist/sentry/sentry-rpc.filter.js +0 -79
  63. package/dist/sentry/sentry-rpc.filter.js.map +0 -1
  64. package/dist/sentry/sentry-sqs.util.d.ts +0 -8
  65. package/dist/sentry/sentry-sqs.util.d.ts.map +0 -1
  66. package/dist/sentry/sentry-sqs.util.js +0 -67
  67. package/dist/sentry/sentry-sqs.util.js.map +0 -1
  68. package/dist/sentry/sentry.module.d.ts +0 -21
  69. package/dist/sentry/sentry.module.d.ts.map +0 -1
  70. package/dist/sentry/sentry.module.js +0 -103
  71. package/dist/sentry/sentry.module.js.map +0 -1
  72. package/dist/sentry/sentry.service.d.ts +0 -21
  73. package/dist/sentry/sentry.service.d.ts.map +0 -1
  74. package/dist/sentry/sentry.service.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry.service.js","sourceRoot":"","sources":["../../src/observability/telemetry.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAqE;AAErE;;GAEG;AAEI,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IACV,MAAM,GAAG,IAAI,eAAM,CAAC,kBAAgB,CAAC,IAAI,CAAC,CAAC;IAE5D,0DAA0D;IAC1D,KAAK,CAAC,eAAe;QACnB,IAAI,CAAC;YACH,+DAA+D;YAC/D,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,kDAAO,aAAa,IAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;gBAC3D,OAAO,EAAE,IAAI;aACd,CAAC,CAAC,CAAC;YACJ,IAAI,CAAC,OAAO;gBAAE,OAAO;YAErB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;YACtD,yDAAyD;YACzD,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAC;YACzB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;QACzD,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,8BAA8B,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;CACF,CAAA;AApBY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;GACA,gBAAgB,CAoB5B"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Method decorator to wrap methods in an OpenTelemetry Span.
3
+ * Captures duration, parameters, and errors automatically.
4
+ */
5
+ export declare function Traced(spanName?: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
6
+ //# sourceMappingURL=traced.decorator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"traced.decorator.d.ts","sourceRoot":"","sources":["../../src/observability/traced.decorator.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,IACrB,QAAQ,GAAG,EAAE,aAAa,MAAM,EAAE,YAAY,kBAAkB,wBA4ClF"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Traced = Traced;
4
+ const api_1 = require("@opentelemetry/api");
5
+ /**
6
+ * Method decorator to wrap methods in an OpenTelemetry Span.
7
+ * Captures duration, parameters, and errors automatically.
8
+ */
9
+ function Traced(spanName) {
10
+ return function (target, propertyKey, descriptor) {
11
+ /** Keep reference to the original method */
12
+ const originalMethod = descriptor.value;
13
+ /** Initialize tracer with service metadata */
14
+ const tracer = api_1.trace.getTracer(process.env.OTEL_SERVICE_NAME || 'service', process.env.OTEL_SERVICE_VERSION || '1.0.0');
15
+ /** Override descriptor with traced logic */
16
+ descriptor.value = async function (...args) {
17
+ /** Use provided name or default to Class.Method */
18
+ const name = spanName || `${target.constructor.name}.${propertyKey}`;
19
+ /** Start an internal span for the method execution */
20
+ return tracer.startActiveSpan(name, { kind: api_1.SpanKind.INTERNAL }, async (span) => {
21
+ try {
22
+ /** Tag span with class and function details */
23
+ span.setAttributes({
24
+ 'code.class': target.constructor.name,
25
+ 'code.function': propertyKey,
26
+ });
27
+ /** Execute the original logic */
28
+ const result = await originalMethod.apply(this, args);
29
+ /** Mark span status as OK on success */
30
+ span.setStatus({ code: api_1.SpanStatusCode.OK });
31
+ return result;
32
+ }
33
+ catch (error) {
34
+ /** Record the exception and set error status on failure */
35
+ span.recordException(error);
36
+ span.setStatus({
37
+ code: api_1.SpanStatusCode.ERROR,
38
+ message: error.message,
39
+ });
40
+ throw error;
41
+ }
42
+ finally {
43
+ /** Ensure span is ended in all cases */
44
+ span.end();
45
+ }
46
+ });
47
+ };
48
+ return descriptor;
49
+ };
50
+ }
51
+ //# sourceMappingURL=traced.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"traced.decorator.js","sourceRoot":"","sources":["../../src/observability/traced.decorator.ts"],"names":[],"mappings":";;AAMA,wBA6CC;AAnDD,4CAAqE;AAErE;;;GAGG;AACH,SAAgB,MAAM,CAAC,QAAiB;IACtC,OAAO,UAAU,MAAW,EAAE,WAAmB,EAAE,UAA8B;QAC/E,4CAA4C;QAC5C,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC;QACxC,8CAA8C;QAC9C,MAAM,MAAM,GAAG,WAAK,CAAC,SAAS,CAC5B,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,SAAS,EAC1C,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,OAAO,CAC5C,CAAC;QAEF,4CAA4C;QAC5C,UAAU,CAAC,KAAK,GAAG,KAAK,WAAW,GAAG,IAAW;YAC/C,mDAAmD;YACnD,MAAM,IAAI,GAAG,QAAQ,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,IAAI,WAAW,EAAE,CAAC;YAErE,sDAAsD;YACtD,OAAO,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,cAAQ,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;gBAC9E,IAAI,CAAC;oBACH,+CAA+C;oBAC/C,IAAI,CAAC,aAAa,CAAC;wBACjB,YAAY,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI;wBACrC,eAAe,EAAE,WAAW;qBAC7B,CAAC,CAAC;oBACH,iCAAiC;oBACjC,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;oBACtD,wCAAwC;oBACxC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,oBAAc,CAAC,EAAE,EAAE,CAAC,CAAC;oBAC5C,OAAO,MAAM,CAAC;gBAChB,CAAC;gBAAC,OAAO,KAAU,EAAE,CAAC;oBACpB,2DAA2D;oBAC3D,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;oBAC5B,IAAI,CAAC,SAAS,CAAC;wBACb,IAAI,EAAE,oBAAc,CAAC,KAAK;wBAC1B,OAAO,EAAE,KAAK,CAAC,OAAO;qBACvB,CAAC,CAAC;oBACH,MAAM,KAAK,CAAC;gBACd,CAAC;wBAAS,CAAC;oBACT,wCAAwC;oBACxC,IAAI,CAAC,GAAG,EAAE,CAAC;gBACb,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { CallHandler, ExecutionContext, NestInterceptor } from '@nestjs/common';
2
+ import { Observable } from 'rxjs';
3
+ /**
4
+ * Interceptor to automatically create spans for NestJS handlers.
5
+ */
6
+ export declare class TracingInterceptor implements NestInterceptor {
7
+ /** Initialize the tracer with service metadata */
8
+ private readonly tracer;
9
+ /** Initialize a meter for tracking request metrics */
10
+ private readonly meter;
11
+ private readonly requestCounter;
12
+ intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
13
+ }
14
+ //# sourceMappingURL=tracing.interceptor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracing.interceptor.d.ts","sourceRoot":"","sources":["../../src/observability/tracing.interceptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAc,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAE5F,OAAO,EAAE,UAAU,EAAc,MAAM,MAAM,CAAC;AAM9C;;GAEG;AACH,qBACa,kBAAmB,YAAW,eAAe;IACxD,kDAAkD;IAClD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAGrB;IAEF,sDAAsD;IACtD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA2C;IACjE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAE5B;IAEH,SAAS,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,WAAW,GAAG,UAAU,CAAC,GAAG,CAAC;CA0FzE"}
@@ -0,0 +1,119 @@
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.TracingInterceptor = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const api_1 = require("@opentelemetry/api");
12
+ const rxjs_1 = require("rxjs");
13
+ const operators_1 = require("rxjs/operators");
14
+ const request_store_1 = require("../request-store");
15
+ const tenant_context_1 = require("../request-store/contexts/tenant-context");
16
+ const user_context_1 = require("../request-store/contexts/user-context");
17
+ /**
18
+ * Interceptor to automatically create spans for NestJS handlers.
19
+ */
20
+ let TracingInterceptor = class TracingInterceptor {
21
+ /** Initialize the tracer with service metadata */
22
+ tracer = api_1.trace.getTracer(process.env.OTEL_SERVICE_NAME || 'service', process.env.OTEL_SERVICE_VERSION || '1.0.0');
23
+ /** Initialize a meter for tracking request metrics */
24
+ meter = api_1.metrics.getMeter('campx-observability');
25
+ requestCounter = this.meter.createCounter('app.request.count', {
26
+ description: 'Total number of incoming requests',
27
+ });
28
+ intercept(context, next) {
29
+ /** Increment the request counter for metrics proof */
30
+ this.requestCounter.add(1, {
31
+ 'service.name': process.env.OTEL_SERVICE_NAME || 'unknown',
32
+ 'context.type': context.getType(),
33
+ });
34
+ /** Extract target class and method for span naming */
35
+ const target = context.getClass().name;
36
+ const method = context.getHandler().name;
37
+ const spanName = `${target}.${method}`;
38
+ return new rxjs_1.Observable((observer) => {
39
+ /** Start an active span for the current execution context */
40
+ this.tracer.startActiveSpan(spanName, (span) => {
41
+ /** Inject the current traceId and spanId into RequestStore for log correlation */
42
+ const spanContext = span.spanContext();
43
+ if (spanContext) {
44
+ try {
45
+ (0, request_store_1.set)('traceId', spanContext.traceId);
46
+ (0, request_store_1.set)('spanId', spanContext.spanId);
47
+ }
48
+ catch (e) {
49
+ /** Handle case where RequestStore is not yet initialized */
50
+ }
51
+ }
52
+ const type = context.getType();
53
+ /** Base attributes for all protocols */
54
+ span.setAttributes({
55
+ 'code.class': target,
56
+ 'code.function': method,
57
+ 'context.type': type,
58
+ });
59
+ /** HTTP-specific attributes */
60
+ if (type === 'http') {
61
+ const req = context.switchToHttp().getRequest();
62
+ span.setAttributes({
63
+ 'http.method': req.method ?? 'UNKNOWN',
64
+ 'http.url': req.url ?? 'UNKNOWN',
65
+ 'http.route': req.route?.path ?? req.url ?? 'UNKNOWN',
66
+ });
67
+ }
68
+ /** RabbitMQ-specific attributes */
69
+ if (type === 'rpc') {
70
+ span.setAttributes({
71
+ 'messaging.system': 'rabbitmq',
72
+ 'messaging.destination': method,
73
+ 'messaging.operation': 'process',
74
+ });
75
+ }
76
+ /** Handle the request stream and capture status/errors */
77
+ const subscription = next
78
+ .handle()
79
+ .pipe(
80
+ /** Set success status and enrich span with tenant/user context */
81
+ (0, operators_1.tap)(() => {
82
+ span.setStatus({ code: api_1.SpanStatusCode.OK });
83
+ /** Read after RequestInterceptor has populated the store */
84
+ try {
85
+ const user = (0, user_context_1.getUserData)();
86
+ const tenant = (0, tenant_context_1.getTenantDetailsIfExists)();
87
+ if (user?.userId)
88
+ span.setAttribute('app.user_id', String(user.userId));
89
+ if (user?.id)
90
+ span.setAttribute('app.user_db_id', String(user.id));
91
+ if (tenant?.id)
92
+ span.setAttribute('app.tenant_id', tenant.id);
93
+ }
94
+ catch (_) { }
95
+ }),
96
+ /** Record exception and set error status on failure */
97
+ (0, operators_1.catchError)((err) => {
98
+ span.recordException(err);
99
+ span.setStatus({
100
+ code: api_1.SpanStatusCode.ERROR,
101
+ message: err.message,
102
+ });
103
+ return (0, rxjs_1.throwError)(() => err);
104
+ }),
105
+ /** Ensure span is closed after execution finishes */
106
+ (0, operators_1.finalize)(() => {
107
+ span.end();
108
+ }))
109
+ .subscribe(observer);
110
+ return () => subscription.unsubscribe();
111
+ });
112
+ });
113
+ }
114
+ };
115
+ exports.TracingInterceptor = TracingInterceptor;
116
+ exports.TracingInterceptor = TracingInterceptor = __decorate([
117
+ (0, common_1.Injectable)()
118
+ ], TracingInterceptor);
119
+ //# sourceMappingURL=tracing.interceptor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracing.interceptor.js","sourceRoot":"","sources":["../../src/observability/tracing.interceptor.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4F;AAC5F,4CAAoE;AACpE,+BAA8C;AAC9C,8CAA2D;AAC3D,oDAAuC;AACvC,6EAAoF;AACpF,yEAAqE;AAErE;;GAEG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC7B,kDAAkD;IACjC,MAAM,GAAG,WAAK,CAAC,SAAS,CACvC,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,SAAS,EAC1C,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,OAAO,CAC5C,CAAC;IAEF,sDAAsD;IACrC,KAAK,GAAG,aAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC;IAChD,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,mBAAmB,EAAE;QAC9E,WAAW,EAAE,mCAAmC;KACjD,CAAC,CAAC;IAEH,SAAS,CAAC,OAAyB,EAAE,IAAiB;QACpD,sDAAsD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AAuD;gBACvD,IAAA,sBAAU,EAAC,CAAC,GAAG,EAAE,EAAE;oBACjB,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;oBAC1B,IAAI,CAAC,SAAS,CAAC;wBACb,IAAI,EAAE,oBAAc,CAAC,KAAK;wBAC1B,OAAO,EAAE,GAAG,CAAC,OAAO;qBACrB,CAAC,CAAC;oBACH,OAAO,IAAA,iBAAU,EAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;gBAC/B,CAAC,CAAC;gBACF,qDAAqD;gBACrD,IAAA,oBAAQ,EAAC,GAAG,EAAE;oBACZ,IAAI,CAAC,GAAG,EAAE,CAAC;gBACb,CAAC,CAAC,CACH;qBACA,SAAS,CAAC,QAAQ,CAAC,CAAC;gBAEvB,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC;YAC1C,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAvGY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;GACA,kBAAkB,CAuG9B"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Wrapper to handle lazy initialization of the SDK.
3
+ * This ensures variables from Secrets Manager/env are available.
4
+ */
5
+ export declare const otelSDK: {
6
+ start: () => Promise<void>;
7
+ shutdown: () => Promise<void>;
8
+ };
9
+ export default otelSDK;
10
+ //# sourceMappingURL=otel-sdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otel-sdk.d.ts","sourceRoot":"","sources":["../src/otel-sdk.ts"],"names":[],"mappings":"AAuCA;;;GAGG;AACH,eAAO,MAAM,OAAO;;;CAyFnB,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.otelSDK = void 0;
37
+ const auto_instrumentations_node_1 = require("@opentelemetry/auto-instrumentations-node");
38
+ const exporter_trace_otlp_http_1 = require("@opentelemetry/exporter-trace-otlp-http");
39
+ const exporter_metrics_otlp_http_1 = require("@opentelemetry/exporter-metrics-otlp-http");
40
+ const resources_1 = require("@opentelemetry/resources");
41
+ const sdk_node_1 = require("@opentelemetry/sdk-node");
42
+ const sdk_trace_node_1 = require("@opentelemetry/sdk-trace-node");
43
+ const sdk_metrics_1 = require("@opentelemetry/sdk-metrics");
44
+ const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
45
+ const api_1 = require("@opentelemetry/api");
46
+ const fs = __importStar(require("fs"));
47
+ const path = __importStar(require("path"));
48
+ /**
49
+ * Isolated OpenTelemetry SDK initialization.
50
+ * ⚠️ DO NOT import this from index.ts or any barrel file.
51
+ */
52
+ /** Helper to get service name from package.json if env is missing */
53
+ const getServiceName = () => {
54
+ if (process.env.OTEL_SERVICE_NAME)
55
+ return process.env.OTEL_SERVICE_NAME;
56
+ try {
57
+ const pkgPath = path.join(process.cwd(), 'package.json');
58
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
59
+ return pkg.name || 'unknown-service';
60
+ }
61
+ catch {
62
+ return 'unknown-service';
63
+ }
64
+ };
65
+ /** Set internal OTel logger to WARN to see critical connection issues */
66
+ api_1.diag.setLogger(new api_1.DiagConsoleLogger(), api_1.DiagLogLevel.WARN);
67
+ let sdk = null;
68
+ /**
69
+ * Wrapper to handle lazy initialization of the SDK.
70
+ * This ensures variables from Secrets Manager/env are available.
71
+ */
72
+ exports.otelSDK = {
73
+ start: async () => {
74
+ /** Master switch: if not enabled, do absolutely nothing */
75
+ if (process.env.OTEL_ENABLED !== 'true')
76
+ return;
77
+ if (sdk)
78
+ return;
79
+ const isProduction = process.env.NODE_ENV === 'production';
80
+ /** Use OTLP only if a key is provided */
81
+ const useOtlp = !!process.env.SIGNOZ_INGESTION_KEY;
82
+ const samplingRatio = parseFloat(process.env.OTEL_SAMPLING_RATIO ?? (isProduction ? '0.1' : '1.0'));
83
+ const baseEndpoint = process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'https://ingest.in2.signoz.cloud:443';
84
+ /** Clean base URL by removing any /v1/traces suffix if accidentally provided */
85
+ const cleanBaseUrl = baseEndpoint.replace(/\/v1\/traces\/?$/, '').replace(/\/$/, '');
86
+ const commonHeaders = {
87
+ 'signoz-ingestion-key': process.env.SIGNOZ_INGESTION_KEY,
88
+ ...(process.env.OTEL_EXPORTER_OTLP_HEADERS ? JSON.parse(process.env.OTEL_EXPORTER_OTLP_HEADERS) : {}),
89
+ };
90
+ /** Configure Trace Exporter */
91
+ const traceExporter = useOtlp
92
+ ? new exporter_trace_otlp_http_1.OTLPTraceExporter({
93
+ url: `${cleanBaseUrl}/v1/traces`,
94
+ headers: commonHeaders,
95
+ })
96
+ : new sdk_trace_node_1.ConsoleSpanExporter();
97
+ /** Configure Metric Reader if OTLP is enabled */
98
+ const metricReader = useOtlp
99
+ ? new sdk_metrics_1.PeriodicExportingMetricReader({
100
+ exporter: new exporter_metrics_otlp_http_1.OTLPMetricExporter({
101
+ url: `${cleanBaseUrl}/v1/metrics`,
102
+ headers: commonHeaders,
103
+ }),
104
+ exportIntervalMillis: 60000,
105
+ })
106
+ : undefined;
107
+ const serviceName = getServiceName();
108
+ sdk = new sdk_node_1.NodeSDK({
109
+ resource: (0, resources_1.resourceFromAttributes)({
110
+ [semantic_conventions_1.ATTR_SERVICE_NAME]: serviceName,
111
+ [semantic_conventions_1.ATTR_SERVICE_VERSION]: process.env.OTEL_SERVICE_VERSION || '1.0.0',
112
+ 'deployment.environment': process.env.NODE_ENV || 'development',
113
+ }),
114
+ traceExporter,
115
+ sampler: new sdk_trace_node_1.ParentBasedSampler({
116
+ root: new sdk_trace_node_1.TraceIdRatioBasedSampler(samplingRatio),
117
+ }),
118
+ spanProcessors: [
119
+ new sdk_trace_node_1.BatchSpanProcessor(traceExporter, {
120
+ maxExportBatchSize: useOtlp ? 200 : 50,
121
+ scheduledDelayMillis: useOtlp ? 2000 : 500,
122
+ exportTimeoutMillis: useOtlp ? 5000 : 2000,
123
+ maxQueueSize: useOtlp ? 2048 : 512,
124
+ }),
125
+ ],
126
+ metricReader,
127
+ instrumentations: [
128
+ (0, auto_instrumentations_node_1.getNodeAutoInstrumentations)({
129
+ '@opentelemetry/instrumentation-fs': { enabled: false },
130
+ '@opentelemetry/instrumentation-dns': { enabled: false },
131
+ '@opentelemetry/instrumentation-net': { enabled: false },
132
+ '@opentelemetry/instrumentation-express': { enabled: false },
133
+ '@opentelemetry/instrumentation-nestjs-core': { enabled: false },
134
+ '@opentelemetry/instrumentation-mongoose': { enabled: true },
135
+ '@opentelemetry/instrumentation-mysql2': { enabled: true },
136
+ '@opentelemetry/instrumentation-http': {
137
+ enabled: true,
138
+ ignoreIncomingRequestHook: (req) => ['/health', '/metrics', '/favicon.ico'].some((p) => req.url?.includes(p)),
139
+ },
140
+ }),
141
+ ],
142
+ });
143
+ sdk.start();
144
+ console.log(`[OTel] Observability started for ${serviceName} (Target: ${useOtlp ? 'SigNoz' : 'Console'})`);
145
+ },
146
+ shutdown: async () => {
147
+ if (sdk) {
148
+ await sdk.shutdown();
149
+ sdk = null;
150
+ }
151
+ },
152
+ };
153
+ exports.default = exports.otelSDK;
154
+ //# sourceMappingURL=otel-sdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otel-sdk.js","sourceRoot":"","sources":["../src/otel-sdk.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0FAAwF;AACxF,sFAA4E;AAC5E,0FAA+E;AAC/E,wDAAkE;AAClE,sDAAkD;AAClD,kEAKuC;AACvC,4DAA2E;AAC3E,8EAA8F;AAC9F,4CAA2F;AAC3F,uCAAyB;AACzB,2CAA6B;AAE7B;;;GAGG;AAEH,qEAAqE;AACrE,MAAM,cAAc,GAAG,GAAG,EAAE;IAC1B,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB;QAAE,OAAO,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;IACxE,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;QACzD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;QACzD,OAAO,GAAG,CAAC,IAAI,IAAI,iBAAiB,CAAC;IACvC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,iBAAiB,CAAC;IAC3B,CAAC;AACH,CAAC,CAAC;AAEF,yEAAyE;AACzE,UAAI,CAAC,SAAS,CAAC,IAA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oCAAoC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;oBACxD,oCAAoC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;oBACxD,wCAAwC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;oBAC5D,4CAA4C,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;oBAChE,yCAAyC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;oBAC5D,uCAAuC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;oBAC1D,qCAAqC,EAAE;wBACrC,OAAO,EAAE,IAAI;wBACb,yBAAyB,EAAE,CAAC,GAAQ,EAAE,EAAE,CACtC,CAAC,SAAS,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;qBAC5E;iBACF,CAAC;aACH;SACF,CAAC,CAAC;QAEH,GAAG,CAAC,KAAK,EAAE,CAAC;QACZ,OAAO,CAAC,GAAG,CACT,oCAAoC,WAAW,aAAa,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,GAAG,CAC9F,CAAC;IACJ,CAAC;IACD,QAAQ,EAAE,KAAK,IAAI,EAAE;QACnB,IAAI,GAAG,EAAE,CAAC;YACR,MAAM,GAAG,CAAC,QAAQ,EAAE,CAAC;YACrB,GAAG,GAAG,IAAI,CAAC;QACb,CAAC;IACH,CAAC;CACF,CAAC;AAEF,kBAAe,eAAO,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@campxdev/server-shared",
3
- "version": "2.1.39",
3
+ "version": "2.1.40",
4
4
  "description": "Campx server shared files",
5
5
  "main": "dist/index.js",
6
6
  "license": "MIT",
@@ -1,6 +0,0 @@
1
- export * from './sentry.module';
2
- export * from './sentry.service';
3
- export * from './sentry-http.filter';
4
- export * from './sentry-rpc.filter';
5
- export * from './sentry-sqs.util';
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sentry/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sentry/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,mDAAiC;AACjC,uDAAqC;AACrC,sDAAoC;AACpC,oDAAkC"}
@@ -1,6 +0,0 @@
1
- import { ArgumentsHost, ExceptionFilter } from '@nestjs/common';
2
- import { Response } from 'express';
3
- export declare class SentryHttpFilter implements ExceptionFilter {
4
- catch(exception: any, host: ArgumentsHost): Response<any, Record<string, any>>;
5
- }
6
- //# sourceMappingURL=sentry-http.filter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sentry-http.filter.d.ts","sourceRoot":"","sources":["../../src/sentry/sentry-http.filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAS,eAAe,EAA6B,MAAM,gBAAgB,CAAC;AAElG,OAAO,EAAW,QAAQ,EAAE,MAAM,SAAS,CAAC;AAI5C,qBACa,gBAAiB,YAAW,eAAe;IACtD,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,aAAa;CA4C1C"}
@@ -1,89 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
- 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;
22
- return c > 3 && r && Object.defineProperty(target, key, r), r;
23
- };
24
- var __importStar = (this && this.__importStar) || (function () {
25
- var ownKeys = function(o) {
26
- ownKeys = Object.getOwnPropertyNames || function (o) {
27
- var ar = [];
28
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
- return ar;
30
- };
31
- return ownKeys(o);
32
- };
33
- return function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
- })();
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.SentryHttpFilter = void 0;
43
- const common_1 = require("@nestjs/common");
44
- const Sentry = __importStar(require("@sentry/nestjs"));
45
- const tenant_context_1 = require("../request-store/contexts/tenant-context");
46
- const user_context_1 = require("../request-store/contexts/user-context");
47
- let SentryHttpFilter = class SentryHttpFilter {
48
- catch(exception, host) {
49
- const ctx = host.switchToHttp();
50
- const response = ctx.getResponse();
51
- const request = ctx.getRequest();
52
- const status = exception instanceof common_1.HttpException ? exception.getStatus() : common_1.HttpStatus.INTERNAL_SERVER_ERROR;
53
- /** Only capture 500 errors or actual non-HTTP exceptions in Sentry by default,
54
- * or everything if you want 4xx as well.
55
- */
56
- Sentry.withScope((scope) => {
57
- const user = (0, user_context_1.getUserData)();
58
- const tenant = (0, tenant_context_1.getTenantDetailsIfExists)();
59
- if (user) {
60
- scope.setUser({
61
- id: String(user.userId || user.id),
62
- email: user.email,
63
- username: user.fullName || user.username,
64
- });
65
- scope.setTag('user_db_id', String(user.id));
66
- }
67
- if (tenant) {
68
- scope.setTag('tenant_id', tenant.id);
69
- scope.setTag('tenant_name', tenant.name);
70
- }
71
- scope.setTag('http.method', request.method);
72
- scope.setTag('http.url', request.url);
73
- Sentry.captureException(exception);
74
- });
75
- /** Re-throw or send response as Nest would */
76
- if (exception instanceof common_1.HttpException) {
77
- return response.status(status).json(exception.getResponse());
78
- }
79
- return response.status(common_1.HttpStatus.INTERNAL_SERVER_ERROR).json({
80
- statusCode: common_1.HttpStatus.INTERNAL_SERVER_ERROR,
81
- message: exception.message || 'Internal server error',
82
- });
83
- }
84
- };
85
- exports.SentryHttpFilter = SentryHttpFilter;
86
- exports.SentryHttpFilter = SentryHttpFilter = __decorate([
87
- (0, common_1.Catch)()
88
- ], SentryHttpFilter);
89
- //# sourceMappingURL=sentry-http.filter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sentry-http.filter.js","sourceRoot":"","sources":["../../src/sentry/sentry-http.filter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAkG;AAClG,uDAAyC;AAEzC,6EAAoF;AACpF,yEAAqE;AAG9D,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAC3B,KAAK,CAAC,SAAc,EAAE,IAAmB;QACvC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAY,CAAC;QAC7C,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAW,CAAC;QAE1C,MAA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,CAAC;QAED,OAAO,QAAQ,CAAC,MAAM,CAAC,mBAAU,CAAC,qBAAqB,CAAC,CAAC,IAAI,CAAC;YAC5D,UAAU,EAAE,mBAAU,CAAC,qBAAqB;YAC5C,OAAO,EAAE,SAAS,CAAC,OAAO,IAAI,uBAAuB;SACtD,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AA7CY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,cAAK,GAAE;GACK,gBAAgB,CA6C5B"}
@@ -1,5 +0,0 @@
1
- import { ArgumentsHost, ExceptionFilter } from '@nestjs/common';
2
- export declare class SentryRpcFilter implements ExceptionFilter {
3
- catch(exception: any, host: ArgumentsHost): import("rxjs").Observable<never>;
4
- }
5
- //# sourceMappingURL=sentry-rpc.filter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sentry-rpc.filter.d.ts","sourceRoot":"","sources":["../../src/sentry/sentry-rpc.filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAS,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAOvE,qBACa,eAAgB,YAAW,eAAe;IACrD,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,aAAa;CA6B1C"}
@@ -1,79 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
- 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;
22
- return c > 3 && r && Object.defineProperty(target, key, r), r;
23
- };
24
- var __importStar = (this && this.__importStar) || (function () {
25
- var ownKeys = function(o) {
26
- ownKeys = Object.getOwnPropertyNames || function (o) {
27
- var ar = [];
28
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
- return ar;
30
- };
31
- return ownKeys(o);
32
- };
33
- return function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
- })();
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.SentryRpcFilter = void 0;
43
- const common_1 = require("@nestjs/common");
44
- const microservices_1 = require("@nestjs/microservices");
45
- const Sentry = __importStar(require("@sentry/nestjs"));
46
- const rxjs_1 = require("rxjs");
47
- const tenant_context_1 = require("../request-store/contexts/tenant-context");
48
- const user_context_1 = require("../request-store/contexts/user-context");
49
- let SentryRpcFilter = class SentryRpcFilter {
50
- catch(exception, host) {
51
- /** Report to Sentry with context */
52
- Sentry.withScope((scope) => {
53
- const user = (0, user_context_1.getUserData)();
54
- const tenant = (0, tenant_context_1.getTenantDetailsIfExists)();
55
- if (user) {
56
- scope.setUser({
57
- id: String(user.userId || user.id),
58
- email: user.email,
59
- });
60
- scope.setTag('user_db_id', String(user.id));
61
- }
62
- if (tenant) {
63
- scope.setTag('tenant_id', tenant.id);
64
- }
65
- scope.setTag('transport', 'microservice');
66
- Sentry.captureException(exception);
67
- });
68
- /** Convert non-RPC exceptions to RpcException for proper RabbitMQ propagation */
69
- if (!(exception instanceof microservices_1.RpcException)) {
70
- return (0, rxjs_1.throwError)(() => new microservices_1.RpcException(exception.message || 'Microservice Exception'));
71
- }
72
- return (0, rxjs_1.throwError)(() => exception);
73
- }
74
- };
75
- exports.SentryRpcFilter = SentryRpcFilter;
76
- exports.SentryRpcFilter = SentryRpcFilter = __decorate([
77
- (0, common_1.Catch)()
78
- ], SentryRpcFilter);
79
- //# sourceMappingURL=sentry-rpc.filter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sentry-rpc.filter.js","sourceRoot":"","sources":["../../src/sentry/sentry-rpc.filter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAuE;AACvE,yDAAqD;AACrD,uDAAyC;AACzC,+BAAkC;AAClC,6EAAoF;AACpF,yEAAqE;AAG9D,IAAM,eAAe,GAArB,MAAM,eAAe;IAC1B,KAAK,CAAC,SAAc,EAAE,IAAmB;QACvC,oCAAoC;QACpC,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;YACzB,MAAM,IAAI,GAAG,IAAA,0BAAW,GAAE,CAAC;YAC3B,MAAM,MAAM,GAAG,IAAA,yCAAwB,GAAE,CAAC;YAE1C,IAAI,IAAI,EAAE,CAAC;gBACT,KAAK,CAAC,OAAO,CAAC;oBACZ,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,EAAE,CAAC;oBAClC,KAAK,EAAE,IAAI,CAAC,KAAK;iBAClB,CAAC,CAAC;gBACH,KAAK,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;YAC9C,CAAC;YAED,IAAI,MAAM,EAAE,CAAC;gBACX,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;YACvC,CAAC;YAED,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;YAC1C,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;QAEH,iFAAiF;QACjF,IAAI,CAAC,CAAC,SAAS,YAAY,4BAAY,CAAC,EAAE,CAAC;YACzC,OAAO,IAAA,iBAAU,EAAC,GAAG,EAAE,CAAC,IAAI,4BAAY,CAAC,SAAS,CAAC,OAAO,IAAI,wBAAwB,CAAC,CAAC,CAAC;QAC3F,CAAC;QAED,OAAO,IAAA,iBAAU,EAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC;CACF,CAAA;AA9BY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,cAAK,GAAE;GACK,eAAe,CA8B3B"}
@@ -1,8 +0,0 @@
1
- /**
2
- * Utility to wrap SQS message handlers with Sentry error capture.
3
- * @param queueName - The name of the SQS queue.
4
- * @param handler - The message processing logic.
5
- * @returns A wrapped handler.
6
- */
7
- export declare function withSentrySqs(queueName: string, handler: (...args: any[]) => Promise<any>): (...args: any[]) => Promise<any>;
8
- //# sourceMappingURL=sentry-sqs.util.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sentry-sqs.util.d.ts","sourceRoot":"","sources":["../../src/sentry/sentry-sqs.util.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,IAC1E,GAAG,MAAM,GAAG,EAAE,kBAuB7B"}