@ngn-net/nestjs-telescope 0.3.13 → 0.3.15

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.
@@ -896,7 +896,15 @@
896
896
  const [totalEntries, setTotalEntries] = useState(0);
897
897
  const [perPage, setPerPage] = useState(50);
898
898
 
899
- const prefixPath = window.location.pathname.split('/api')[0].split('/')[1] || 'telescope';
899
+ const prefixPath = (() => {
900
+ const path = window.location.pathname;
901
+ // Detect the telescope base path from the URL
902
+ // e.g. /telescope → 'telescope', /api/telescope → 'api/telescope'
903
+ const segments = path.split('/').filter(Boolean);
904
+ const telescopeIdx = segments.findIndex(s => s === 'telescope');
905
+ if (telescopeIdx === -1) return 'telescope';
906
+ return segments.slice(0, telescopeIdx + 1).join('/');
907
+ })();
900
908
 
901
909
  // Load entries when dependencies change
902
910
  useEffect(() => {
@@ -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.15",
4
+ "builtAt": "2026-06-13T13:33:09.249Z"
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.15",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/ui/index.html CHANGED
@@ -896,7 +896,15 @@
896
896
  const [totalEntries, setTotalEntries] = useState(0);
897
897
  const [perPage, setPerPage] = useState(50);
898
898
 
899
- const prefixPath = window.location.pathname.split('/api')[0].split('/')[1] || 'telescope';
899
+ const prefixPath = (() => {
900
+ const path = window.location.pathname;
901
+ // Detect the telescope base path from the URL
902
+ // e.g. /telescope → 'telescope', /api/telescope → 'api/telescope'
903
+ const segments = path.split('/').filter(Boolean);
904
+ const telescopeIdx = segments.findIndex(s => s === 'telescope');
905
+ if (telescopeIdx === -1) return 'telescope';
906
+ return segments.slice(0, telescopeIdx + 1).join('/');
907
+ })();
900
908
 
901
909
  // Load entries when dependencies change
902
910
  useEffect(() => {