@echoteam/signoz-react 1.2.7 → 1.2.10
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/TROUBLESHOOTING.md +76 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +166 -38
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +166 -38
- package/dist/index.js.map +1 -1
- package/dist/types/tracing.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15369,7 +15369,8 @@ function addFetchLogging(config) {
|
|
|
15369
15369
|
if (contentLength) {
|
|
15370
15370
|
span.setAttribute('http.response_content_length', parseInt(contentLength));
|
|
15371
15371
|
}
|
|
15372
|
-
|
|
15372
|
+
// Log response body for both success and error responses
|
|
15373
|
+
if (config.logResponseBody) {
|
|
15373
15374
|
const clonedResponse = response.clone();
|
|
15374
15375
|
try {
|
|
15375
15376
|
const responseData = await clonedResponse.text();
|
|
@@ -15385,12 +15386,27 @@ function addFetchLogging(config) {
|
|
|
15385
15386
|
if (jsonData.message) {
|
|
15386
15387
|
span.setAttribute('response.message', jsonData.message);
|
|
15387
15388
|
}
|
|
15389
|
+
// Also log error details if present
|
|
15390
|
+
if (jsonData.errors) {
|
|
15391
|
+
span.setAttribute('response.errors', JSON.stringify(jsonData.errors));
|
|
15392
|
+
}
|
|
15393
|
+
if (jsonData.status !== undefined) {
|
|
15394
|
+
span.setAttribute('response.status', jsonData.status);
|
|
15395
|
+
}
|
|
15396
|
+
if (jsonData.status_code !== undefined) {
|
|
15397
|
+
span.setAttribute('response.status_code', jsonData.status_code);
|
|
15398
|
+
}
|
|
15388
15399
|
}
|
|
15389
15400
|
catch (e) {
|
|
15390
15401
|
// Not JSON or no message field, ignore
|
|
15391
15402
|
}
|
|
15392
15403
|
if (config.enableConsoleLog) {
|
|
15393
|
-
|
|
15404
|
+
if (response.ok) {
|
|
15405
|
+
console.log(`[SignOz] ${method} Response from ${url} (${response.status}) on page ${pagePath} [${Math.round(duration)}ms]:`, truncatedData);
|
|
15406
|
+
}
|
|
15407
|
+
else {
|
|
15408
|
+
console.error(`[SignOz] ${method} Error Response from ${url} (${response.status}) on page ${pagePath} [${Math.round(duration)}ms]:`, truncatedData);
|
|
15409
|
+
}
|
|
15394
15410
|
}
|
|
15395
15411
|
}
|
|
15396
15412
|
catch (e) {
|
|
@@ -15400,7 +15416,7 @@ function addFetchLogging(config) {
|
|
|
15400
15416
|
}
|
|
15401
15417
|
}
|
|
15402
15418
|
else if (!response.ok && config.enableConsoleLog) {
|
|
15403
|
-
console.
|
|
15419
|
+
console.error(`[SignOz] ${method} Request to ${url} from page ${pagePath} - Status: ${response.status} [${Math.round(duration)}ms]`);
|
|
15404
15420
|
}
|
|
15405
15421
|
span.setStatus({ code: SpanStatusCode.OK });
|
|
15406
15422
|
return response;
|
|
@@ -15471,31 +15487,66 @@ function addXHRLogging(config) {
|
|
|
15471
15487
|
if (contentLength) {
|
|
15472
15488
|
span.setAttribute('http.response_content_length', parseInt(contentLength));
|
|
15473
15489
|
}
|
|
15474
|
-
// Log response body
|
|
15475
|
-
if (config.logResponseBody
|
|
15476
|
-
const responseData = xhr.responseText;
|
|
15477
|
-
const truncatedData = truncateBody(responseData, config.maxBodyLogSize);
|
|
15478
|
-
span.setAttribute('response.data', truncatedData);
|
|
15479
|
-
// If content-length header is not available, calculate from response data
|
|
15480
|
-
if (!contentLength) {
|
|
15481
|
-
span.setAttribute('http.response_content_length', responseData.length);
|
|
15482
|
-
}
|
|
15483
|
-
// Try to parse JSON and extract message if exists
|
|
15490
|
+
// Log response body for both success and error responses
|
|
15491
|
+
if (config.logResponseBody) {
|
|
15484
15492
|
try {
|
|
15485
|
-
|
|
15486
|
-
if (
|
|
15487
|
-
|
|
15493
|
+
// Only read responseText if responseType allows it
|
|
15494
|
+
if (xhr.responseType === '' || xhr.responseType === 'text') {
|
|
15495
|
+
const responseData = xhr.responseText;
|
|
15496
|
+
const truncatedData = truncateBody(responseData, config.maxBodyLogSize);
|
|
15497
|
+
span.setAttribute('response.data', truncatedData);
|
|
15498
|
+
// If content-length header is not available, calculate from response data
|
|
15499
|
+
if (!contentLength) {
|
|
15500
|
+
span.setAttribute('http.response_content_length', responseData.length);
|
|
15501
|
+
}
|
|
15502
|
+
// Try to parse JSON and extract message if exists
|
|
15503
|
+
try {
|
|
15504
|
+
const jsonData = JSON.parse(responseData);
|
|
15505
|
+
if (jsonData.message) {
|
|
15506
|
+
span.setAttribute('response.message', jsonData.message);
|
|
15507
|
+
}
|
|
15508
|
+
// Also log error details if present
|
|
15509
|
+
if (jsonData.errors) {
|
|
15510
|
+
span.setAttribute('response.errors', JSON.stringify(jsonData.errors));
|
|
15511
|
+
}
|
|
15512
|
+
if (jsonData.status !== undefined) {
|
|
15513
|
+
span.setAttribute('response.status', jsonData.status);
|
|
15514
|
+
}
|
|
15515
|
+
if (jsonData.status_code !== undefined) {
|
|
15516
|
+
span.setAttribute('response.status_code', jsonData.status_code);
|
|
15517
|
+
}
|
|
15518
|
+
}
|
|
15519
|
+
catch (e) {
|
|
15520
|
+
// Not JSON or no message field, ignore
|
|
15521
|
+
}
|
|
15522
|
+
if (config.enableConsoleLog) {
|
|
15523
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
15524
|
+
console.log(`[SignOz] ${method} Response from ${url} (${xhr.status}) on page ${pagePath} [${Math.round(duration)}ms]:`, truncatedData);
|
|
15525
|
+
}
|
|
15526
|
+
else {
|
|
15527
|
+
console.error(`[SignOz] ${method} Error Response from ${url} (${xhr.status}) on page ${pagePath} [${Math.round(duration)}ms]:`, truncatedData);
|
|
15528
|
+
}
|
|
15529
|
+
}
|
|
15530
|
+
}
|
|
15531
|
+
else {
|
|
15532
|
+
// For other response types (blob, arraybuffer, etc), just log the type
|
|
15533
|
+
span.setAttribute('response.data', `[${xhr.responseType} data]`);
|
|
15534
|
+
span.setAttribute('response.type', xhr.responseType);
|
|
15535
|
+
if (config.enableConsoleLog) {
|
|
15536
|
+
console.log(`[SignOz] ${method} Response from ${url} (${xhr.status}) on page ${pagePath} [${Math.round(duration)}ms]: [${xhr.responseType} data]`);
|
|
15537
|
+
}
|
|
15488
15538
|
}
|
|
15489
15539
|
}
|
|
15490
15540
|
catch (e) {
|
|
15491
|
-
//
|
|
15492
|
-
|
|
15493
|
-
|
|
15494
|
-
|
|
15541
|
+
// If there's an error reading response, log it
|
|
15542
|
+
span.setAttribute('response.data', '[Error reading response]');
|
|
15543
|
+
if (config.enableConsoleLog) {
|
|
15544
|
+
console.warn(`[SignOz] Failed to read response from ${url}:`, e);
|
|
15545
|
+
}
|
|
15495
15546
|
}
|
|
15496
15547
|
}
|
|
15497
15548
|
else if (xhr.status >= 300 && config.enableConsoleLog) {
|
|
15498
|
-
console.
|
|
15549
|
+
console.error(`[SignOz] ${method} Request to ${url} from page ${pagePath} - Status: ${xhr.status} [${Math.round(duration)}ms]`);
|
|
15499
15550
|
}
|
|
15500
15551
|
span.setStatus({ code: SpanStatusCode.OK });
|
|
15501
15552
|
span.end();
|
|
@@ -15528,9 +15579,15 @@ function addErrorTracking(enableConsoleLog = false) {
|
|
|
15528
15579
|
span.setAttribute('error.filename', event.filename || 'unknown');
|
|
15529
15580
|
span.setAttribute('error.lineno', event.lineno || 0);
|
|
15530
15581
|
span.setAttribute('error.colno', event.colno || 0);
|
|
15582
|
+
// Add page context
|
|
15583
|
+
span.setAttribute('page.url', window.location.href);
|
|
15584
|
+
span.setAttribute('page.pathname', window.location.pathname);
|
|
15585
|
+
span.setAttribute('page.search', window.location.search);
|
|
15586
|
+
span.setAttribute('page.hash', window.location.hash);
|
|
15531
15587
|
if (event.error) {
|
|
15532
15588
|
span.recordException(event.error);
|
|
15533
15589
|
span.setAttribute('error.stack', event.error.stack || '');
|
|
15590
|
+
span.setAttribute('error.name', event.error.name || 'Error');
|
|
15534
15591
|
}
|
|
15535
15592
|
span.setStatus({ code: SpanStatusCode.ERROR, message: event.message });
|
|
15536
15593
|
if (enableConsoleLog) {
|
|
@@ -15539,28 +15596,102 @@ function addErrorTracking(enableConsoleLog = false) {
|
|
|
15539
15596
|
filename: event.filename,
|
|
15540
15597
|
lineno: event.lineno,
|
|
15541
15598
|
colno: event.colno,
|
|
15542
|
-
stack: (_a = event.error) === null || _a === void 0 ? void 0 : _a.stack
|
|
15599
|
+
stack: (_a = event.error) === null || _a === void 0 ? void 0 : _a.stack,
|
|
15600
|
+
page: window.location.pathname
|
|
15543
15601
|
});
|
|
15544
15602
|
}
|
|
15545
15603
|
span.end();
|
|
15546
|
-
});
|
|
15604
|
+
}, true); // Use capture phase to catch errors early
|
|
15547
15605
|
// Track unhandled promise rejections
|
|
15548
15606
|
window.addEventListener('unhandledrejection', (event) => {
|
|
15607
|
+
// Suppress BatchSpanProcessor timeout errors to avoid noise
|
|
15608
|
+
const reason = String(event.reason);
|
|
15609
|
+
if (reason.includes('Timeout') && reason.includes('BatchSpanProcessor')) {
|
|
15610
|
+
if (enableConsoleLog) {
|
|
15611
|
+
console.warn('[SignOz] Span export timeout (this is usually safe to ignore):', event.reason);
|
|
15612
|
+
}
|
|
15613
|
+
event.preventDefault(); // Prevent the error from being logged
|
|
15614
|
+
return;
|
|
15615
|
+
}
|
|
15549
15616
|
const tracer = trace.getTracer('error-tracker');
|
|
15550
15617
|
const span = tracer.startSpan('Unhandled Promise Rejection');
|
|
15551
15618
|
span.setAttribute('error.type', 'unhandled_rejection');
|
|
15552
15619
|
span.setAttribute('error.reason', String(event.reason));
|
|
15620
|
+
// Add page context
|
|
15621
|
+
span.setAttribute('page.url', window.location.href);
|
|
15622
|
+
span.setAttribute('page.pathname', window.location.pathname);
|
|
15623
|
+
span.setAttribute('page.search', window.location.search);
|
|
15624
|
+
span.setAttribute('page.hash', window.location.hash);
|
|
15553
15625
|
if (event.reason instanceof Error) {
|
|
15554
15626
|
span.recordException(event.reason);
|
|
15555
15627
|
span.setAttribute('error.message', event.reason.message);
|
|
15556
15628
|
span.setAttribute('error.stack', event.reason.stack || '');
|
|
15629
|
+
span.setAttribute('error.name', event.reason.name || 'Error');
|
|
15557
15630
|
}
|
|
15558
15631
|
span.setStatus({ code: SpanStatusCode.ERROR, message: String(event.reason) });
|
|
15559
15632
|
if (enableConsoleLog) {
|
|
15560
|
-
console.error('[SignOz] Unhandled Promise Rejection:', event.reason);
|
|
15633
|
+
console.error('[SignOz] Unhandled Promise Rejection:', event.reason, 'on page', window.location.pathname);
|
|
15561
15634
|
}
|
|
15562
15635
|
span.end();
|
|
15563
15636
|
});
|
|
15637
|
+
// Track Zone.js errors (for Angular/React with zone.js)
|
|
15638
|
+
if (typeof Zone !== 'undefined' && Zone.current) {
|
|
15639
|
+
const currentZone = Zone.current;
|
|
15640
|
+
const originalHandleError = currentZone.handleError;
|
|
15641
|
+
if (originalHandleError) {
|
|
15642
|
+
currentZone.handleError = function (error) {
|
|
15643
|
+
const tracer = trace.getTracer('error-tracker');
|
|
15644
|
+
const span = tracer.startSpan('Zone.js Error');
|
|
15645
|
+
span.setAttribute('error.type', 'zone_error');
|
|
15646
|
+
span.setAttribute('error.message', error.message || String(error));
|
|
15647
|
+
span.setAttribute('error.name', error.name || 'Error');
|
|
15648
|
+
// Add page context
|
|
15649
|
+
span.setAttribute('page.url', window.location.href);
|
|
15650
|
+
span.setAttribute('page.pathname', window.location.pathname);
|
|
15651
|
+
span.setAttribute('page.search', window.location.search);
|
|
15652
|
+
span.setAttribute('page.hash', window.location.hash);
|
|
15653
|
+
if (error.stack) {
|
|
15654
|
+
span.setAttribute('error.stack', error.stack);
|
|
15655
|
+
}
|
|
15656
|
+
span.recordException(error);
|
|
15657
|
+
span.setStatus({ code: SpanStatusCode.ERROR, message: error.message || String(error) });
|
|
15658
|
+
if (enableConsoleLog) {
|
|
15659
|
+
console.error('[SignOz] Zone.js Error:', error, 'on page', window.location.pathname);
|
|
15660
|
+
}
|
|
15661
|
+
span.end();
|
|
15662
|
+
// Call original handler
|
|
15663
|
+
return originalHandleError.call(currentZone, error);
|
|
15664
|
+
};
|
|
15665
|
+
}
|
|
15666
|
+
}
|
|
15667
|
+
// Override console.error to catch React errors
|
|
15668
|
+
const originalConsoleError = console.error;
|
|
15669
|
+
console.error = function (...args) {
|
|
15670
|
+
// Check if this is a React error
|
|
15671
|
+
const errorMessage = args.map(arg => String(arg)).join(' ');
|
|
15672
|
+
if (errorMessage.includes('React') || errorMessage.includes('TypeError') || errorMessage.includes('Uncaught')) {
|
|
15673
|
+
const tracer = trace.getTracer('error-tracker');
|
|
15674
|
+
const span = tracer.startSpan('Console Error');
|
|
15675
|
+
span.setAttribute('error.type', 'console_error');
|
|
15676
|
+
span.setAttribute('error.message', errorMessage);
|
|
15677
|
+
// Add page context
|
|
15678
|
+
span.setAttribute('page.url', window.location.href);
|
|
15679
|
+
span.setAttribute('page.pathname', window.location.pathname);
|
|
15680
|
+
span.setAttribute('page.search', window.location.search);
|
|
15681
|
+
span.setAttribute('page.hash', window.location.hash);
|
|
15682
|
+
// Try to extract stack trace
|
|
15683
|
+
const errorObj = args.find(arg => arg instanceof Error);
|
|
15684
|
+
if (errorObj) {
|
|
15685
|
+
span.recordException(errorObj);
|
|
15686
|
+
span.setAttribute('error.stack', errorObj.stack || '');
|
|
15687
|
+
span.setAttribute('error.name', errorObj.name || 'Error');
|
|
15688
|
+
}
|
|
15689
|
+
span.setStatus({ code: SpanStatusCode.ERROR, message: errorMessage });
|
|
15690
|
+
span.end();
|
|
15691
|
+
}
|
|
15692
|
+
// Call original console.error
|
|
15693
|
+
return originalConsoleError.apply(console, args);
|
|
15694
|
+
};
|
|
15564
15695
|
}
|
|
15565
15696
|
// Fungsi untuk menambahkan navigation tracking
|
|
15566
15697
|
function addNavigationTracking(enableConsoleLog = false) {
|
|
@@ -15882,7 +16013,8 @@ function initializeSignOzTracing(config) {
|
|
|
15882
16013
|
batchSpanProcessorConfig: (config === null || config === void 0 ? void 0 : config.batchSpanProcessorConfig) || {
|
|
15883
16014
|
maxQueueSize: 100,
|
|
15884
16015
|
scheduledDelayMillis: 5000,
|
|
15885
|
-
exportTimeoutMillis:
|
|
16016
|
+
exportTimeoutMillis: 60000, // Increased to 60 seconds
|
|
16017
|
+
maxExportBatchSize: 50 // Smaller batches to avoid timeouts
|
|
15886
16018
|
},
|
|
15887
16019
|
allowedOrigins: (config === null || config === void 0 ? void 0 : config.allowedOrigins) || parseAllowedOrigins(getConfigValue('REACT_APP_SIGNOZ_ALLOWED_ORIGINS')),
|
|
15888
16020
|
enableRequestLogging: (config === null || config === void 0 ? void 0 : config.enableRequestLogging) !== undefined ? config.enableRequestLogging : (getConfigValue('REACT_APP_SIGNOZ_ENABLE_REQUEST_LOGGING') === 'true' || true),
|
|
@@ -15913,7 +16045,8 @@ function initializeSignOzTracing(config) {
|
|
|
15913
16045
|
// Set up the OTLP trace exporter
|
|
15914
16046
|
const exporter = new OTLPTraceExporter({
|
|
15915
16047
|
url: effectiveConfig.url,
|
|
15916
|
-
headers: effectiveConfig.headers
|
|
16048
|
+
headers: effectiveConfig.headers,
|
|
16049
|
+
timeoutMillis: 60000 // Set exporter timeout to 60 seconds
|
|
15917
16050
|
});
|
|
15918
16051
|
// Set up the span processor with configuration
|
|
15919
16052
|
const processor = new BatchSpanProcessor(exporter, {
|
|
@@ -16123,17 +16256,6 @@ function hasArrayChanged() {
|
|
|
16123
16256
|
}
|
|
16124
16257
|
|
|
16125
16258
|
const DefaultErrorFallback = ({ error, resetErrorBoundary }) => {
|
|
16126
|
-
const serviceName = window.REACT_APP_SIGNOZ_SERVICE_NAME || 'react-app';
|
|
16127
|
-
const tracer = trace.getTracer(serviceName);
|
|
16128
|
-
const span = tracer.startSpan(serviceName + ".error");
|
|
16129
|
-
React2.useEffect(() => {
|
|
16130
|
-
span.setAttribute('error.message', error.message);
|
|
16131
|
-
span.setAttribute('error.stack', JSON.stringify(error.stack));
|
|
16132
|
-
span.setAttribute('error.name', error.name);
|
|
16133
|
-
span.recordException(error);
|
|
16134
|
-
span.setStatus({ code: SpanStatusCode.ERROR, message: error.message });
|
|
16135
|
-
span.end();
|
|
16136
|
-
}, [error, span]);
|
|
16137
16259
|
return (jsxRuntime.jsxs("div", { role: "alert", className: "error-boundary-fallback", children: [jsxRuntime.jsx("h1", { children: "Oops!" }), jsxRuntime.jsx("p", { children: "Terjadi kesalahan yang tidak terduga." }), jsxRuntime.jsx("p", { children: jsxRuntime.jsx("i", { children: error.statusText || error.message }) }), jsxRuntime.jsx("button", { onClick: resetErrorBoundary, children: "Coba lagi" })] }));
|
|
16138
16260
|
};
|
|
16139
16261
|
const ErrorBoundary = ({ children, fallback: FallbackComponent, onError, onReset, showResetButton = true, resetButtonText = "Coba lagi", fallbackClassName = "", }) => {
|
|
@@ -16142,10 +16264,16 @@ const ErrorBoundary = ({ children, fallback: FallbackComponent, onError, onReset
|
|
|
16142
16264
|
const serviceName = window.REACT_APP_SIGNOZ_SERVICE_NAME || 'react-app';
|
|
16143
16265
|
const tracer = trace.getTracer(serviceName);
|
|
16144
16266
|
const span = tracer.startSpan(serviceName + ".error");
|
|
16267
|
+
span.setAttribute('error.type', 'react_error_boundary');
|
|
16145
16268
|
span.setAttribute('error.message', error.message);
|
|
16146
|
-
span.setAttribute('error.stack',
|
|
16269
|
+
span.setAttribute('error.stack', error.stack || '');
|
|
16147
16270
|
span.setAttribute('error.name', error.name);
|
|
16148
16271
|
span.setAttribute('error.componentStack', errorInfo.componentStack || '');
|
|
16272
|
+
// Add page context
|
|
16273
|
+
span.setAttribute('page.url', window.location.href);
|
|
16274
|
+
span.setAttribute('page.pathname', window.location.pathname);
|
|
16275
|
+
span.setAttribute('page.search', window.location.search);
|
|
16276
|
+
span.setAttribute('page.hash', window.location.hash);
|
|
16149
16277
|
span.recordException(error);
|
|
16150
16278
|
span.setStatus({ code: SpanStatusCode.ERROR, message: error.message });
|
|
16151
16279
|
span.end();
|