@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.esm.js
CHANGED
|
@@ -15642,6 +15642,20 @@ function addWebSocketLogging(config) {
|
|
|
15642
15642
|
const originalSend = ws.send;
|
|
15643
15643
|
ws.send = function (data) {
|
|
15644
15644
|
if (config.logWebSocketMessages) {
|
|
15645
|
+
// Skip logging if data is just a number
|
|
15646
|
+
let shouldLog = true;
|
|
15647
|
+
if (typeof data === 'string') {
|
|
15648
|
+
// Check if string is just a number
|
|
15649
|
+
if (/^\d+$/.test(data.trim())) {
|
|
15650
|
+
shouldLog = false;
|
|
15651
|
+
}
|
|
15652
|
+
}
|
|
15653
|
+
else if (typeof data === 'number') {
|
|
15654
|
+
shouldLog = false;
|
|
15655
|
+
}
|
|
15656
|
+
if (!shouldLog) {
|
|
15657
|
+
return originalSend.call(ws, data);
|
|
15658
|
+
}
|
|
15645
15659
|
const messageSpan = tracer.startSpan('WebSocket Send');
|
|
15646
15660
|
const sendStartTime = performance.now();
|
|
15647
15661
|
messageSpan.setAttribute('websocket.url', wsUrl);
|
|
@@ -15652,6 +15666,7 @@ function addWebSocketLogging(config) {
|
|
|
15652
15666
|
if (typeof data === 'string') {
|
|
15653
15667
|
const truncatedData = truncateBody(data, config.maxBodyLogSize);
|
|
15654
15668
|
messageSpan.setAttribute('websocket.message', truncatedData);
|
|
15669
|
+
messageSpan.setAttribute('http.request.body', truncatedData); // Add for consistency with HTTP requests
|
|
15655
15670
|
// Try to parse JSON and extract message if exists
|
|
15656
15671
|
try {
|
|
15657
15672
|
const jsonData = JSON.parse(data);
|
|
@@ -15669,6 +15684,16 @@ function addWebSocketLogging(config) {
|
|
|
15669
15684
|
console.log(`[SignOz] WebSocket Send to ${wsUrl} from page ${pagePath}:`, truncatedData);
|
|
15670
15685
|
}
|
|
15671
15686
|
}
|
|
15687
|
+
else if (typeof data === 'number' || typeof data === 'boolean') {
|
|
15688
|
+
// Handle primitive types
|
|
15689
|
+
const dataStr = String(data);
|
|
15690
|
+
messageSpan.setAttribute('websocket.message', dataStr);
|
|
15691
|
+
messageSpan.setAttribute('http.request.body', dataStr);
|
|
15692
|
+
messageSpan.setAttribute('websocket.message.type', typeof data);
|
|
15693
|
+
if (config.enableConsoleLog) {
|
|
15694
|
+
console.log(`[SignOz] WebSocket Send to ${wsUrl} from page ${pagePath}:`, dataStr);
|
|
15695
|
+
}
|
|
15696
|
+
}
|
|
15672
15697
|
else {
|
|
15673
15698
|
messageSpan.setAttribute('websocket.message', '[Binary Data]');
|
|
15674
15699
|
messageSpan.setAttribute('websocket.message.type', 'binary');
|
|
@@ -15687,6 +15712,23 @@ function addWebSocketLogging(config) {
|
|
|
15687
15712
|
const originalOnMessage = ws.onmessage;
|
|
15688
15713
|
ws.addEventListener('message', function (event) {
|
|
15689
15714
|
if (config.logWebSocketMessages) {
|
|
15715
|
+
// Skip logging if data is just a number
|
|
15716
|
+
let shouldLog = true;
|
|
15717
|
+
if (typeof event.data === 'string') {
|
|
15718
|
+
// Check if string is just a number
|
|
15719
|
+
if (/^\d+$/.test(event.data.trim())) {
|
|
15720
|
+
shouldLog = false;
|
|
15721
|
+
}
|
|
15722
|
+
}
|
|
15723
|
+
else if (typeof event.data === 'number') {
|
|
15724
|
+
shouldLog = false;
|
|
15725
|
+
}
|
|
15726
|
+
if (!shouldLog) {
|
|
15727
|
+
if (originalOnMessage) {
|
|
15728
|
+
originalOnMessage.call(ws, event);
|
|
15729
|
+
}
|
|
15730
|
+
return;
|
|
15731
|
+
}
|
|
15690
15732
|
const messageSpan = tracer.startSpan('WebSocket Receive');
|
|
15691
15733
|
messageSpan.setAttribute('websocket.url', wsUrl);
|
|
15692
15734
|
messageSpan.setAttribute('websocket.direction', 'receive');
|
|
@@ -15715,6 +15757,16 @@ function addWebSocketLogging(config) {
|
|
|
15715
15757
|
console.log(`[SignOz] WebSocket Receive from ${wsUrl} on page ${pagePath}:`, truncatedData);
|
|
15716
15758
|
}
|
|
15717
15759
|
}
|
|
15760
|
+
else if (typeof event.data === 'number' || typeof event.data === 'boolean') {
|
|
15761
|
+
// Handle primitive types
|
|
15762
|
+
const dataStr = String(event.data);
|
|
15763
|
+
messageSpan.setAttribute('websocket.message', dataStr);
|
|
15764
|
+
messageSpan.setAttribute('response.data', dataStr);
|
|
15765
|
+
messageSpan.setAttribute('websocket.message.type', typeof event.data);
|
|
15766
|
+
if (config.enableConsoleLog) {
|
|
15767
|
+
console.log(`[SignOz] WebSocket Receive from ${wsUrl} on page ${pagePath}:`, dataStr);
|
|
15768
|
+
}
|
|
15769
|
+
}
|
|
15718
15770
|
else {
|
|
15719
15771
|
messageSpan.setAttribute('websocket.message', '[Binary Data]');
|
|
15720
15772
|
messageSpan.setAttribute('websocket.message.type', 'binary');
|