@ngn-net/nestjs-telescope 0.3.13 → 0.3.14

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.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@ngn-net/nestjs-telescope",
3
- "version": "0.3.13",
4
- "builtAt": "2026-06-13T11:26:28.718Z"
3
+ "version": "0.3.14",
4
+ "builtAt": "2026-06-13T11:29:51.036Z"
5
5
  }
@@ -69,35 +69,72 @@ try {
69
69
  return result;
70
70
  };
71
71
  }
72
- // Patch subscribe for incoming
73
- const originalSubscribe = AmqpConnection.prototype.subscribe;
74
- if (originalSubscribe) {
75
- AmqpConnection.prototype.subscribe = async function (queue, handler, options) {
76
- const wrappedHandler = (msg) => {
77
- if (msg && msg.content && telescopeRef) {
72
+ // Patch setupSubscriberChannel for incoming (subscribe handlers)
73
+ const origSetupSubscriber = AmqpConnection.prototype.setupSubscriberChannel;
74
+ if (origSetupSubscriber) {
75
+ AmqpConnection.prototype.setupSubscriberChannel = async function (handler, msgOptions, channel, originalHandlerName) {
76
+ const queue = msgOptions?.queue || '';
77
+ const exchange = msgOptions?.exchange || '';
78
+ const routingKey = msgOptions?.routingKey || '';
79
+ const wrappedHandler = async (msg, rawMsg, headers) => {
80
+ if (rawMsg && rawMsg.content && telescopeRef) {
78
81
  let parsed;
79
82
  try {
80
- parsed = JSON.parse(msg.content.toString());
83
+ parsed = JSON.parse(rawMsg.content.toString());
81
84
  }
82
85
  catch {
83
- parsed = msg.content.toString();
86
+ parsed = rawMsg.content.toString();
84
87
  }
85
88
  telescopeRef.record({
86
89
  type: entry_type_enum_1.EntryType.RABBITMQ,
87
90
  content: {
88
91
  direction: 'incoming',
89
92
  queue,
90
- exchange: msg.fields?.exchange || '',
91
- routingKey: msg.fields?.routingKey || queue,
93
+ exchange: rawMsg.fields?.exchange || exchange,
94
+ routingKey: rawMsg.fields?.routingKey || routingKey,
92
95
  message: sanitizeMessage(parsed),
93
- deliveryTag: msg.fields?.deliveryTag,
96
+ deliveryTag: rawMsg.fields?.deliveryTag,
97
+ handler: originalHandlerName,
94
98
  timestamp: new Date().toISOString(),
95
99
  },
96
100
  }).catch(() => { });
97
101
  }
98
- return handler(msg);
102
+ return handler(msg, rawMsg, headers);
99
103
  };
100
- return originalSubscribe.call(this, queue, wrappedHandler, options);
104
+ return origSetupSubscriber.call(this, wrappedHandler, msgOptions, channel, originalHandlerName);
105
+ };
106
+ }
107
+ // Patch setupBatchSubscriberChannel for incoming (batch subscribe handlers)
108
+ const origSetupBatch = AmqpConnection.prototype.setupBatchSubscriberChannel;
109
+ if (origSetupBatch) {
110
+ AmqpConnection.prototype.setupBatchSubscriberChannel = async function (handler, msgOptions, channel) {
111
+ const queue = msgOptions?.queue || '';
112
+ const wrappedHandler = async (msgs, rawMsgs, headers) => {
113
+ if (telescopeRef && rawMsgs && rawMsgs.length > 0) {
114
+ const firstMsg = rawMsgs[0];
115
+ let parsed;
116
+ try {
117
+ parsed = JSON.parse(firstMsg.content.toString());
118
+ }
119
+ catch {
120
+ parsed = firstMsg.content.toString();
121
+ }
122
+ telescopeRef.record({
123
+ type: entry_type_enum_1.EntryType.RABBITMQ,
124
+ content: {
125
+ direction: 'incoming',
126
+ queue,
127
+ exchange: firstMsg.fields?.exchange || '',
128
+ routingKey: firstMsg.fields?.routingKey || queue,
129
+ message: sanitizeMessage(parsed),
130
+ batchSize: msgs.length,
131
+ timestamp: new Date().toISOString(),
132
+ },
133
+ }).catch(() => { });
134
+ }
135
+ return handler(msgs, rawMsgs, headers);
136
+ };
137
+ return origSetupBatch.call(this, wrappedHandler, msgOptions, channel);
101
138
  };
102
139
  }
103
140
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngn-net/nestjs-telescope",
3
- "version": "0.3.13",
3
+ "version": "0.3.14",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },