@multiplayer-app/session-recorder-browser 1.2.34 → 1.2.36
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 +87 -85
- package/dist/browser/index.js.map +1 -1
- package/dist/exporters/index.js +1 -1
- package/dist/index.js +87 -85
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +87 -85
- package/dist/index.umd.js.map +1 -1
- package/dist/otel/helpers.d.ts +1 -0
- package/dist/otel/helpers.d.ts.map +1 -1
- package/dist/otel/helpers.js +10 -0
- package/dist/otel/helpers.js.map +1 -1
- package/dist/otel/index.d.ts +0 -1
- package/dist/otel/index.d.ts.map +1 -1
- package/dist/otel/index.js +5 -7
- package/dist/otel/index.js.map +1 -1
- package/dist/patch/fetch.js +71 -78
- package/dist/patch/fetch.js.map +1 -1
- package/package.json +4 -4
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.36" || 0;
|
|
25098
25098
|
// Regex patterns for OpenTelemetry ignore URLs
|
|
25099
25099
|
const OTEL_IGNORE_URLS = [
|
|
25100
25100
|
// Traces endpoint
|
|
@@ -25748,6 +25748,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
25748
25748
|
__webpack_require__.r(__webpack_exports__);
|
|
25749
25749
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
25750
25750
|
/* harmony export */ extractResponseBody: () => (/* binding */ extractResponseBody),
|
|
25751
|
+
/* harmony export */ getElementTextContent: () => (/* binding */ getElementTextContent),
|
|
25751
25752
|
/* harmony export */ getExporterEndpoint: () => (/* binding */ getExporterEndpoint),
|
|
25752
25753
|
/* harmony export */ headersToObject: () => (/* binding */ headersToObject),
|
|
25753
25754
|
/* harmony export */ processBody: () => (/* binding */ processBody),
|
|
@@ -25956,6 +25957,16 @@ const getExporterEndpoint = (exporterEndpoint) => {
|
|
|
25956
25957
|
const trimmedExporterEndpoint = new URL(exporterEndpoint).origin;
|
|
25957
25958
|
return `${trimmedExporterEndpoint}/v1/traces`;
|
|
25958
25959
|
};
|
|
25960
|
+
const getElementTextContent = (element) => {
|
|
25961
|
+
const getInnerText = (element) => {
|
|
25962
|
+
const slicedText = element.innerText.slice(0, 50);
|
|
25963
|
+
if (slicedText.length < element.innerText.length) {
|
|
25964
|
+
return `${slicedText}...`;
|
|
25965
|
+
}
|
|
25966
|
+
return slicedText;
|
|
25967
|
+
};
|
|
25968
|
+
return String(element.textContent || element.ariaLabel || getInnerText(element) || '').trim();
|
|
25969
|
+
};
|
|
25959
25970
|
|
|
25960
25971
|
|
|
25961
25972
|
/***/ }),
|
|
@@ -25998,7 +26009,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
25998
26009
|
|
|
25999
26010
|
class TracerBrowserSDK {
|
|
26000
26011
|
constructor() {
|
|
26001
|
-
this.allowedElements = new Set(['A', 'BUTTON']);
|
|
26002
26012
|
this.sessionId = '';
|
|
26003
26013
|
this.globalErrorListenersRegistered = false;
|
|
26004
26014
|
}
|
|
@@ -26128,11 +26138,10 @@ class TracerBrowserSDK {
|
|
|
26128
26138
|
if (span['parentSpanContext']) {
|
|
26129
26139
|
return true;
|
|
26130
26140
|
}
|
|
26131
|
-
|
|
26132
|
-
|
|
26133
|
-
|
|
26134
|
-
}
|
|
26135
|
-
span.setAttribute('target.innerText', textContent);
|
|
26141
|
+
span.setAttribute('target.innerText', (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.getElementTextContent)(element));
|
|
26142
|
+
Array.from(element.attributes).forEach(attribute => {
|
|
26143
|
+
span.setAttribute(`target.attribute.${attribute.name}`, attribute.value);
|
|
26144
|
+
});
|
|
26136
26145
|
return false;
|
|
26137
26146
|
},
|
|
26138
26147
|
},
|
|
@@ -26370,91 +26379,84 @@ function _headersInitToObject(headersInit) {
|
|
|
26370
26379
|
return result;
|
|
26371
26380
|
}
|
|
26372
26381
|
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;
|
|
26382
|
+
// Idempotency guard: avoid double-patching
|
|
26383
|
+
// @ts-ignore
|
|
26384
|
+
if (window.fetch.__mp_session_recorder_patched__) {
|
|
26385
|
+
// Already patched; do nothing
|
|
26386
|
+
}
|
|
26387
|
+
else {
|
|
26388
|
+
// @ts-ignore
|
|
26389
|
+
window.fetch.__mp_session_recorder_patched__ = true;
|
|
26390
|
+
// Store original fetch
|
|
26391
|
+
const originalFetch = window.fetch;
|
|
26392
|
+
// Override fetch
|
|
26393
|
+
window.fetch = async function (input,
|
|
26394
|
+
// eslint-disable-next-line
|
|
26395
|
+
init) {
|
|
26396
|
+
const networkRequest = {};
|
|
26397
|
+
// Capture request data
|
|
26398
|
+
const inputIsRequest = typeof Request !== 'undefined' && input instanceof Request;
|
|
26399
|
+
if (_configs__WEBPACK_IMPORTED_MODULE_2__.configs.recordRequestHeaders) {
|
|
26400
|
+
if (inputIsRequest) {
|
|
26401
|
+
networkRequest.requestHeaders = _headersToObject(input.headers);
|
|
26402
|
+
}
|
|
26403
|
+
else {
|
|
26404
|
+
networkRequest.requestHeaders = _headersInitToObject(init === null || init === void 0 ? void 0 : init.headers);
|
|
26421
26405
|
}
|
|
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
26406
|
}
|
|
26431
26407
|
if (_configs__WEBPACK_IMPORTED_MODULE_2__.configs.shouldRecordBody) {
|
|
26432
|
-
const
|
|
26433
|
-
|
|
26434
|
-
|
|
26435
|
-
|
|
26408
|
+
const urlStr = inputIsRequest
|
|
26409
|
+
? input.url
|
|
26410
|
+
: (typeof input === 'string' || input instanceof URL ? String(input) : '');
|
|
26411
|
+
// Only attempt to read the body from init (safe); avoid constructing/cloning Requests
|
|
26412
|
+
// If the caller passed a Request as input, we do not attempt to read its body here
|
|
26413
|
+
const candidateBody = init === null || init === void 0 ? void 0 : init.body;
|
|
26414
|
+
if (!(0,_utils_type_utils__WEBPACK_IMPORTED_MODULE_0__.isNullish)(candidateBody)) {
|
|
26415
|
+
const requestBody = _tryReadFetchBody({
|
|
26416
|
+
body: candidateBody,
|
|
26417
|
+
url: urlStr,
|
|
26418
|
+
});
|
|
26419
|
+
if ((requestBody === null || requestBody === void 0 ? void 0 : requestBody.length) &&
|
|
26420
|
+
new Blob([requestBody]).size <= _configs__WEBPACK_IMPORTED_MODULE_2__.configs.maxCapturingHttpPayloadSize) {
|
|
26421
|
+
networkRequest.requestBody = requestBody;
|
|
26422
|
+
}
|
|
26436
26423
|
}
|
|
26437
26424
|
}
|
|
26438
|
-
|
|
26439
|
-
|
|
26440
|
-
|
|
26441
|
-
|
|
26442
|
-
|
|
26443
|
-
|
|
26444
|
-
|
|
26445
|
-
|
|
26446
|
-
|
|
26447
|
-
|
|
26425
|
+
try {
|
|
26426
|
+
// Make the actual fetch request
|
|
26427
|
+
const response = await originalFetch(input, init);
|
|
26428
|
+
// Capture response data
|
|
26429
|
+
if (_configs__WEBPACK_IMPORTED_MODULE_2__.configs.recordResponseHeaders) {
|
|
26430
|
+
networkRequest.responseHeaders = _headersToObject(response.headers);
|
|
26431
|
+
}
|
|
26432
|
+
if (_configs__WEBPACK_IMPORTED_MODULE_2__.configs.shouldRecordBody) {
|
|
26433
|
+
const responseBody = await _tryReadResponseBody(response);
|
|
26434
|
+
if ((responseBody === null || responseBody === void 0 ? void 0 : responseBody.length) &&
|
|
26435
|
+
new Blob([responseBody]).size <= _configs__WEBPACK_IMPORTED_MODULE_2__.configs.maxCapturingHttpPayloadSize) {
|
|
26436
|
+
networkRequest.responseBody = responseBody;
|
|
26437
|
+
}
|
|
26438
|
+
}
|
|
26439
|
+
// Attach network request data to the response for later access
|
|
26448
26440
|
// @ts-ignore
|
|
26449
|
-
|
|
26441
|
+
response.networkRequest = networkRequest;
|
|
26442
|
+
return response;
|
|
26450
26443
|
}
|
|
26451
|
-
|
|
26452
|
-
|
|
26453
|
-
|
|
26454
|
-
|
|
26455
|
-
|
|
26456
|
-
|
|
26457
|
-
|
|
26444
|
+
catch (error) {
|
|
26445
|
+
// Even if the fetch fails, we can still capture the request data
|
|
26446
|
+
// Attach captured request data to the thrown error for downstream handling
|
|
26447
|
+
// @ts-ignore
|
|
26448
|
+
if (error && typeof error === 'object') {
|
|
26449
|
+
// @ts-ignore
|
|
26450
|
+
error.networkRequest = networkRequest;
|
|
26451
|
+
}
|
|
26452
|
+
throw error;
|
|
26453
|
+
}
|
|
26454
|
+
};
|
|
26455
|
+
// Preserve the original fetch function's properties
|
|
26456
|
+
Object.setPrototypeOf(window.fetch, originalFetch);
|
|
26457
|
+
Object.defineProperty(window.fetch, 'name', { value: 'fetch' });
|
|
26458
|
+
Object.defineProperty(window.fetch, 'length', { value: originalFetch.length });
|
|
26459
|
+
}
|
|
26458
26460
|
}
|
|
26459
26461
|
|
|
26460
26462
|
|