@echoteam/signoz-react 1.2.4 → 1.2.6
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/index.esm.js +52 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15662,6 +15662,20 @@ function addWebSocketLogging(config) {
|
|
|
15662
15662
|
const originalSend = ws.send;
|
|
15663
15663
|
ws.send = function (data) {
|
|
15664
15664
|
if (config.logWebSocketMessages) {
|
|
15665
|
+
// Skip logging if data is just a number
|
|
15666
|
+
let shouldLog = true;
|
|
15667
|
+
if (typeof data === 'string') {
|
|
15668
|
+
// Check if string is just a number
|
|
15669
|
+
if (/^\d+$/.test(data.trim())) {
|
|
15670
|
+
shouldLog = false;
|
|
15671
|
+
}
|
|
15672
|
+
}
|
|
15673
|
+
else if (typeof data === 'number') {
|
|
15674
|
+
shouldLog = false;
|
|
15675
|
+
}
|
|
15676
|
+
if (!shouldLog) {
|
|
15677
|
+
return originalSend.call(ws, data);
|
|
15678
|
+
}
|
|
15665
15679
|
const messageSpan = tracer.startSpan('WebSocket Send');
|
|
15666
15680
|
const sendStartTime = performance.now();
|
|
15667
15681
|
messageSpan.setAttribute('websocket.url', wsUrl);
|
|
@@ -15672,6 +15686,7 @@ function addWebSocketLogging(config) {
|
|
|
15672
15686
|
if (typeof data === 'string') {
|
|
15673
15687
|
const truncatedData = truncateBody(data, config.maxBodyLogSize);
|
|
15674
15688
|
messageSpan.setAttribute('websocket.message', truncatedData);
|
|
15689
|
+
messageSpan.setAttribute('http.request.body', truncatedData); // Add for consistency with HTTP requests
|
|
15675
15690
|
// Try to parse JSON and extract message if exists
|
|
15676
15691
|
try {
|
|
15677
15692
|
const jsonData = JSON.parse(data);
|
|
@@ -15689,6 +15704,16 @@ function addWebSocketLogging(config) {
|
|
|
15689
15704
|
console.log(`[SignOz] WebSocket Send to ${wsUrl} from page ${pagePath}:`, truncatedData);
|
|
15690
15705
|
}
|
|
15691
15706
|
}
|
|
15707
|
+
else if (typeof data === 'number' || typeof data === 'boolean') {
|
|
15708
|
+
// Handle primitive types
|
|
15709
|
+
const dataStr = String(data);
|
|
15710
|
+
messageSpan.setAttribute('websocket.message', dataStr);
|
|
15711
|
+
messageSpan.setAttribute('http.request.body', dataStr);
|
|
15712
|
+
messageSpan.setAttribute('websocket.message.type', typeof data);
|
|
15713
|
+
if (config.enableConsoleLog) {
|
|
15714
|
+
console.log(`[SignOz] WebSocket Send to ${wsUrl} from page ${pagePath}:`, dataStr);
|
|
15715
|
+
}
|
|
15716
|
+
}
|
|
15692
15717
|
else {
|
|
15693
15718
|
messageSpan.setAttribute('websocket.message', '[Binary Data]');
|
|
15694
15719
|
messageSpan.setAttribute('websocket.message.type', 'binary');
|
|
@@ -15707,6 +15732,23 @@ function addWebSocketLogging(config) {
|
|
|
15707
15732
|
const originalOnMessage = ws.onmessage;
|
|
15708
15733
|
ws.addEventListener('message', function (event) {
|
|
15709
15734
|
if (config.logWebSocketMessages) {
|
|
15735
|
+
// Skip logging if data is just a number
|
|
15736
|
+
let shouldLog = true;
|
|
15737
|
+
if (typeof event.data === 'string') {
|
|
15738
|
+
// Check if string is just a number
|
|
15739
|
+
if (/^\d+$/.test(event.data.trim())) {
|
|
15740
|
+
shouldLog = false;
|
|
15741
|
+
}
|
|
15742
|
+
}
|
|
15743
|
+
else if (typeof event.data === 'number') {
|
|
15744
|
+
shouldLog = false;
|
|
15745
|
+
}
|
|
15746
|
+
if (!shouldLog) {
|
|
15747
|
+
if (originalOnMessage) {
|
|
15748
|
+
originalOnMessage.call(ws, event);
|
|
15749
|
+
}
|
|
15750
|
+
return;
|
|
15751
|
+
}
|
|
15710
15752
|
const messageSpan = tracer.startSpan('WebSocket Receive');
|
|
15711
15753
|
messageSpan.setAttribute('websocket.url', wsUrl);
|
|
15712
15754
|
messageSpan.setAttribute('websocket.direction', 'receive');
|
|
@@ -15735,6 +15777,16 @@ function addWebSocketLogging(config) {
|
|
|
15735
15777
|
console.log(`[SignOz] WebSocket Receive from ${wsUrl} on page ${pagePath}:`, truncatedData);
|
|
15736
15778
|
}
|
|
15737
15779
|
}
|
|
15780
|
+
else if (typeof event.data === 'number' || typeof event.data === 'boolean') {
|
|
15781
|
+
// Handle primitive types
|
|
15782
|
+
const dataStr = String(event.data);
|
|
15783
|
+
messageSpan.setAttribute('websocket.message', dataStr);
|
|
15784
|
+
messageSpan.setAttribute('response.data', dataStr);
|
|
15785
|
+
messageSpan.setAttribute('websocket.message.type', typeof event.data);
|
|
15786
|
+
if (config.enableConsoleLog) {
|
|
15787
|
+
console.log(`[SignOz] WebSocket Receive from ${wsUrl} on page ${pagePath}:`, dataStr);
|
|
15788
|
+
}
|
|
15789
|
+
}
|
|
15738
15790
|
else {
|
|
15739
15791
|
messageSpan.setAttribute('websocket.message', '[Binary Data]');
|
|
15740
15792
|
messageSpan.setAttribute('websocket.message.type', 'binary');
|