@multiplayer-app/session-recorder-browser 1.2.34 → 1.2.35
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/browser/index.js +72 -79
- package/dist/browser/index.js.map +1 -1
- package/dist/exporters/index.js +1 -1
- package/dist/index.js +72 -79
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +72 -79
- package/dist/index.umd.js.map +1 -1
- package/dist/patch/fetch.js +71 -78
- package/dist/patch/fetch.js.map +1 -1
- package/package.json +2 -2
package/dist/browser/index.js
CHANGED
|
@@ -25094,7 +25094,7 @@ const DEFAULT_MAX_HTTP_CAPTURING_PAYLOAD_SIZE = 100000;
|
|
|
25094
25094
|
const SESSION_RESPONSE = 'multiplayer-debug-session-response';
|
|
25095
25095
|
const CONTINUOUS_DEBUGGING_TIMEOUT = 60000; // 1 minutes
|
|
25096
25096
|
const DEBUG_SESSION_MAX_DURATION_SECONDS = 10 * 60 + 30; // TODO: move to shared config otel core
|
|
25097
|
-
const PACKAGE_VERSION_EXPORT = "1.2.
|
|
25097
|
+
const PACKAGE_VERSION_EXPORT = "1.2.35" || 0;
|
|
25098
25098
|
// Regex patterns for OpenTelemetry ignore URLs
|
|
25099
25099
|
const OTEL_IGNORE_URLS = [
|
|
25100
25100
|
// Traces endpoint
|
|
@@ -26370,91 +26370,84 @@ function _headersInitToObject(headersInit) {
|
|
|
26370
26370
|
return result;
|
|
26371
26371
|
}
|
|
26372
26372
|
if (typeof window !== 'undefined' && typeof window.fetch !== 'undefined') {
|
|
26373
|
-
//
|
|
26374
|
-
|
|
26375
|
-
|
|
26376
|
-
|
|
26377
|
-
|
|
26378
|
-
|
|
26379
|
-
|
|
26380
|
-
|
|
26381
|
-
|
|
26382
|
-
const
|
|
26383
|
-
//
|
|
26384
|
-
|
|
26385
|
-
|
|
26386
|
-
|
|
26387
|
-
|
|
26388
|
-
|
|
26389
|
-
|
|
26390
|
-
|
|
26391
|
-
|
|
26392
|
-
|
|
26393
|
-
|
|
26394
|
-
|
|
26395
|
-
|
|
26396
|
-
networkRequest.requestHeaders = _headersToObject(requestForMetadata.headers);
|
|
26397
|
-
}
|
|
26398
|
-
else if (inputIsRequest) {
|
|
26399
|
-
networkRequest.requestHeaders = _headersToObject(input.headers);
|
|
26400
|
-
}
|
|
26401
|
-
else {
|
|
26402
|
-
networkRequest.requestHeaders = _headersInitToObject(init === null || init === void 0 ? void 0 : init.headers);
|
|
26403
|
-
}
|
|
26404
|
-
}
|
|
26405
|
-
if (_configs__WEBPACK_IMPORTED_MODULE_2__.configs.shouldRecordBody) {
|
|
26406
|
-
// Prefer reading from the safely constructed Request; else fallback to init.body
|
|
26407
|
-
const urlStr = inputIsRequest
|
|
26408
|
-
? input.url
|
|
26409
|
-
: (typeof input === 'string' || input instanceof URL ? String(input) : '');
|
|
26410
|
-
const candidateBody = requestForMetadata
|
|
26411
|
-
? requestForMetadata.body
|
|
26412
|
-
: (inputIsRequest ? init === null || init === void 0 ? void 0 : init.body : init === null || init === void 0 ? void 0 : init.body);
|
|
26413
|
-
if (!(0,_utils_type_utils__WEBPACK_IMPORTED_MODULE_0__.isNullish)(candidateBody)) {
|
|
26414
|
-
const requestBody = _tryReadFetchBody({
|
|
26415
|
-
body: candidateBody,
|
|
26416
|
-
url: urlStr,
|
|
26417
|
-
});
|
|
26418
|
-
if ((requestBody === null || requestBody === void 0 ? void 0 : requestBody.length) &&
|
|
26419
|
-
new Blob([requestBody]).size <= _configs__WEBPACK_IMPORTED_MODULE_2__.configs.maxCapturingHttpPayloadSize) {
|
|
26420
|
-
networkRequest.requestBody = requestBody;
|
|
26373
|
+
// Idempotency guard: avoid double-patching
|
|
26374
|
+
// @ts-ignore
|
|
26375
|
+
if (window.fetch.__mp_session_recorder_patched__) {
|
|
26376
|
+
// Already patched; do nothing
|
|
26377
|
+
}
|
|
26378
|
+
else {
|
|
26379
|
+
// @ts-ignore
|
|
26380
|
+
window.fetch.__mp_session_recorder_patched__ = true;
|
|
26381
|
+
// Store original fetch
|
|
26382
|
+
const originalFetch = window.fetch;
|
|
26383
|
+
// Override fetch
|
|
26384
|
+
window.fetch = async function (input,
|
|
26385
|
+
// eslint-disable-next-line
|
|
26386
|
+
init) {
|
|
26387
|
+
const networkRequest = {};
|
|
26388
|
+
// Capture request data
|
|
26389
|
+
const inputIsRequest = typeof Request !== 'undefined' && input instanceof Request;
|
|
26390
|
+
if (_configs__WEBPACK_IMPORTED_MODULE_2__.configs.recordRequestHeaders) {
|
|
26391
|
+
if (inputIsRequest) {
|
|
26392
|
+
networkRequest.requestHeaders = _headersToObject(input.headers);
|
|
26393
|
+
}
|
|
26394
|
+
else {
|
|
26395
|
+
networkRequest.requestHeaders = _headersInitToObject(init === null || init === void 0 ? void 0 : init.headers);
|
|
26421
26396
|
}
|
|
26422
|
-
}
|
|
26423
|
-
}
|
|
26424
|
-
try {
|
|
26425
|
-
// Make the actual fetch request
|
|
26426
|
-
const response = await originalFetch(input, init);
|
|
26427
|
-
// Capture response data
|
|
26428
|
-
if (_configs__WEBPACK_IMPORTED_MODULE_2__.configs.recordResponseHeaders) {
|
|
26429
|
-
networkRequest.responseHeaders = _headersToObject(response.headers);
|
|
26430
26397
|
}
|
|
26431
26398
|
if (_configs__WEBPACK_IMPORTED_MODULE_2__.configs.shouldRecordBody) {
|
|
26432
|
-
const
|
|
26433
|
-
|
|
26434
|
-
|
|
26435
|
-
|
|
26399
|
+
const urlStr = inputIsRequest
|
|
26400
|
+
? input.url
|
|
26401
|
+
: (typeof input === 'string' || input instanceof URL ? String(input) : '');
|
|
26402
|
+
// Only attempt to read the body from init (safe); avoid constructing/cloning Requests
|
|
26403
|
+
// If the caller passed a Request as input, we do not attempt to read its body here
|
|
26404
|
+
const candidateBody = init === null || init === void 0 ? void 0 : init.body;
|
|
26405
|
+
if (!(0,_utils_type_utils__WEBPACK_IMPORTED_MODULE_0__.isNullish)(candidateBody)) {
|
|
26406
|
+
const requestBody = _tryReadFetchBody({
|
|
26407
|
+
body: candidateBody,
|
|
26408
|
+
url: urlStr,
|
|
26409
|
+
});
|
|
26410
|
+
if ((requestBody === null || requestBody === void 0 ? void 0 : requestBody.length) &&
|
|
26411
|
+
new Blob([requestBody]).size <= _configs__WEBPACK_IMPORTED_MODULE_2__.configs.maxCapturingHttpPayloadSize) {
|
|
26412
|
+
networkRequest.requestBody = requestBody;
|
|
26413
|
+
}
|
|
26436
26414
|
}
|
|
26437
26415
|
}
|
|
26438
|
-
|
|
26439
|
-
|
|
26440
|
-
|
|
26441
|
-
|
|
26442
|
-
|
|
26443
|
-
|
|
26444
|
-
|
|
26445
|
-
|
|
26446
|
-
|
|
26447
|
-
|
|
26416
|
+
try {
|
|
26417
|
+
// Make the actual fetch request
|
|
26418
|
+
const response = await originalFetch(input, init);
|
|
26419
|
+
// Capture response data
|
|
26420
|
+
if (_configs__WEBPACK_IMPORTED_MODULE_2__.configs.recordResponseHeaders) {
|
|
26421
|
+
networkRequest.responseHeaders = _headersToObject(response.headers);
|
|
26422
|
+
}
|
|
26423
|
+
if (_configs__WEBPACK_IMPORTED_MODULE_2__.configs.shouldRecordBody) {
|
|
26424
|
+
const responseBody = await _tryReadResponseBody(response);
|
|
26425
|
+
if ((responseBody === null || responseBody === void 0 ? void 0 : responseBody.length) &&
|
|
26426
|
+
new Blob([responseBody]).size <= _configs__WEBPACK_IMPORTED_MODULE_2__.configs.maxCapturingHttpPayloadSize) {
|
|
26427
|
+
networkRequest.responseBody = responseBody;
|
|
26428
|
+
}
|
|
26429
|
+
}
|
|
26430
|
+
// Attach network request data to the response for later access
|
|
26448
26431
|
// @ts-ignore
|
|
26449
|
-
|
|
26432
|
+
response.networkRequest = networkRequest;
|
|
26433
|
+
return response;
|
|
26450
26434
|
}
|
|
26451
|
-
|
|
26452
|
-
|
|
26453
|
-
|
|
26454
|
-
|
|
26455
|
-
|
|
26456
|
-
|
|
26457
|
-
|
|
26435
|
+
catch (error) {
|
|
26436
|
+
// Even if the fetch fails, we can still capture the request data
|
|
26437
|
+
// Attach captured request data to the thrown error for downstream handling
|
|
26438
|
+
// @ts-ignore
|
|
26439
|
+
if (error && typeof error === 'object') {
|
|
26440
|
+
// @ts-ignore
|
|
26441
|
+
error.networkRequest = networkRequest;
|
|
26442
|
+
}
|
|
26443
|
+
throw error;
|
|
26444
|
+
}
|
|
26445
|
+
};
|
|
26446
|
+
// Preserve the original fetch function's properties
|
|
26447
|
+
Object.setPrototypeOf(window.fetch, originalFetch);
|
|
26448
|
+
Object.defineProperty(window.fetch, 'name', { value: 'fetch' });
|
|
26449
|
+
Object.defineProperty(window.fetch, 'length', { value: originalFetch.length });
|
|
26450
|
+
}
|
|
26458
26451
|
}
|
|
26459
26452
|
|
|
26460
26453
|
|