@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/index.umd.js
CHANGED
|
@@ -24317,7 +24317,7 @@ const DEFAULT_MAX_HTTP_CAPTURING_PAYLOAD_SIZE = 100000;
|
|
|
24317
24317
|
const SESSION_RESPONSE = 'multiplayer-debug-session-response';
|
|
24318
24318
|
const CONTINUOUS_DEBUGGING_TIMEOUT = 60000; // 1 minutes
|
|
24319
24319
|
const DEBUG_SESSION_MAX_DURATION_SECONDS = 10 * 60 + 30; // TODO: move to shared config otel core
|
|
24320
|
-
const PACKAGE_VERSION_EXPORT = "1.2.
|
|
24320
|
+
const PACKAGE_VERSION_EXPORT = "1.2.36" || 0;
|
|
24321
24321
|
// Regex patterns for OpenTelemetry ignore URLs
|
|
24322
24322
|
const OTEL_IGNORE_URLS = [
|
|
24323
24323
|
// Traces endpoint
|
|
@@ -24947,6 +24947,7 @@ class NavigationRecorder {
|
|
|
24947
24947
|
"use strict";
|
|
24948
24948
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
24949
24949
|
/* harmony export */ extractResponseBody: () => (/* binding */ extractResponseBody),
|
|
24950
|
+
/* harmony export */ getElementTextContent: () => (/* binding */ getElementTextContent),
|
|
24950
24951
|
/* harmony export */ getExporterEndpoint: () => (/* binding */ getExporterEndpoint),
|
|
24951
24952
|
/* harmony export */ headersToObject: () => (/* binding */ headersToObject),
|
|
24952
24953
|
/* harmony export */ processHttpPayload: () => (/* binding */ processHttpPayload)
|
|
@@ -25153,6 +25154,16 @@ const getExporterEndpoint = (exporterEndpoint) => {
|
|
|
25153
25154
|
const trimmedExporterEndpoint = new URL(exporterEndpoint).origin;
|
|
25154
25155
|
return `${trimmedExporterEndpoint}/v1/traces`;
|
|
25155
25156
|
};
|
|
25157
|
+
const getElementTextContent = (element) => {
|
|
25158
|
+
const getInnerText = (element) => {
|
|
25159
|
+
const slicedText = element.innerText.slice(0, 50);
|
|
25160
|
+
if (slicedText.length < element.innerText.length) {
|
|
25161
|
+
return `${slicedText}...`;
|
|
25162
|
+
}
|
|
25163
|
+
return slicedText;
|
|
25164
|
+
};
|
|
25165
|
+
return String(element.textContent || element.ariaLabel || getInnerText(element) || '').trim();
|
|
25166
|
+
};
|
|
25156
25167
|
|
|
25157
25168
|
|
|
25158
25169
|
/***/ }),
|
|
@@ -25194,7 +25205,6 @@ const getExporterEndpoint = (exporterEndpoint) => {
|
|
|
25194
25205
|
|
|
25195
25206
|
class TracerBrowserSDK {
|
|
25196
25207
|
constructor() {
|
|
25197
|
-
this.allowedElements = new Set(['A', 'BUTTON']);
|
|
25198
25208
|
this.sessionId = '';
|
|
25199
25209
|
this.globalErrorListenersRegistered = false;
|
|
25200
25210
|
}
|
|
@@ -25324,11 +25334,10 @@ class TracerBrowserSDK {
|
|
|
25324
25334
|
if (span['parentSpanContext']) {
|
|
25325
25335
|
return true;
|
|
25326
25336
|
}
|
|
25327
|
-
|
|
25328
|
-
|
|
25329
|
-
|
|
25330
|
-
}
|
|
25331
|
-
span.setAttribute('target.innerText', textContent);
|
|
25337
|
+
span.setAttribute('target.innerText', (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.getElementTextContent)(element));
|
|
25338
|
+
Array.from(element.attributes).forEach(attribute => {
|
|
25339
|
+
span.setAttribute(`target.attribute.${attribute.name}`, attribute.value);
|
|
25340
|
+
});
|
|
25332
25341
|
return false;
|
|
25333
25342
|
},
|
|
25334
25343
|
},
|
|
@@ -25564,91 +25573,84 @@ function _headersInitToObject(headersInit) {
|
|
|
25564
25573
|
return result;
|
|
25565
25574
|
}
|
|
25566
25575
|
if (typeof window !== 'undefined' && typeof window.fetch !== 'undefined') {
|
|
25567
|
-
//
|
|
25568
|
-
|
|
25569
|
-
|
|
25570
|
-
|
|
25571
|
-
|
|
25572
|
-
|
|
25573
|
-
|
|
25574
|
-
|
|
25575
|
-
|
|
25576
|
-
const
|
|
25577
|
-
//
|
|
25578
|
-
|
|
25579
|
-
|
|
25580
|
-
|
|
25581
|
-
|
|
25582
|
-
|
|
25583
|
-
|
|
25584
|
-
|
|
25585
|
-
|
|
25586
|
-
|
|
25587
|
-
|
|
25588
|
-
|
|
25589
|
-
|
|
25590
|
-
networkRequest.requestHeaders = _headersToObject(requestForMetadata.headers);
|
|
25591
|
-
}
|
|
25592
|
-
else if (inputIsRequest) {
|
|
25593
|
-
networkRequest.requestHeaders = _headersToObject(input.headers);
|
|
25594
|
-
}
|
|
25595
|
-
else {
|
|
25596
|
-
networkRequest.requestHeaders = _headersInitToObject(init === null || init === void 0 ? void 0 : init.headers);
|
|
25597
|
-
}
|
|
25598
|
-
}
|
|
25599
|
-
if (_configs__WEBPACK_IMPORTED_MODULE_2__.configs.shouldRecordBody) {
|
|
25600
|
-
// Prefer reading from the safely constructed Request; else fallback to init.body
|
|
25601
|
-
const urlStr = inputIsRequest
|
|
25602
|
-
? input.url
|
|
25603
|
-
: (typeof input === 'string' || input instanceof URL ? String(input) : '');
|
|
25604
|
-
const candidateBody = requestForMetadata
|
|
25605
|
-
? requestForMetadata.body
|
|
25606
|
-
: (inputIsRequest ? init === null || init === void 0 ? void 0 : init.body : init === null || init === void 0 ? void 0 : init.body);
|
|
25607
|
-
if (!(0,_utils_type_utils__WEBPACK_IMPORTED_MODULE_0__.isNullish)(candidateBody)) {
|
|
25608
|
-
const requestBody = _tryReadFetchBody({
|
|
25609
|
-
body: candidateBody,
|
|
25610
|
-
url: urlStr,
|
|
25611
|
-
});
|
|
25612
|
-
if ((requestBody === null || requestBody === void 0 ? void 0 : requestBody.length) &&
|
|
25613
|
-
new Blob([requestBody]).size <= _configs__WEBPACK_IMPORTED_MODULE_2__.configs.maxCapturingHttpPayloadSize) {
|
|
25614
|
-
networkRequest.requestBody = requestBody;
|
|
25576
|
+
// Idempotency guard: avoid double-patching
|
|
25577
|
+
// @ts-ignore
|
|
25578
|
+
if (window.fetch.__mp_session_recorder_patched__) {
|
|
25579
|
+
// Already patched; do nothing
|
|
25580
|
+
}
|
|
25581
|
+
else {
|
|
25582
|
+
// @ts-ignore
|
|
25583
|
+
window.fetch.__mp_session_recorder_patched__ = true;
|
|
25584
|
+
// Store original fetch
|
|
25585
|
+
const originalFetch = window.fetch;
|
|
25586
|
+
// Override fetch
|
|
25587
|
+
window.fetch = async function (input,
|
|
25588
|
+
// eslint-disable-next-line
|
|
25589
|
+
init) {
|
|
25590
|
+
const networkRequest = {};
|
|
25591
|
+
// Capture request data
|
|
25592
|
+
const inputIsRequest = typeof Request !== 'undefined' && input instanceof Request;
|
|
25593
|
+
if (_configs__WEBPACK_IMPORTED_MODULE_2__.configs.recordRequestHeaders) {
|
|
25594
|
+
if (inputIsRequest) {
|
|
25595
|
+
networkRequest.requestHeaders = _headersToObject(input.headers);
|
|
25596
|
+
}
|
|
25597
|
+
else {
|
|
25598
|
+
networkRequest.requestHeaders = _headersInitToObject(init === null || init === void 0 ? void 0 : init.headers);
|
|
25615
25599
|
}
|
|
25616
|
-
}
|
|
25617
|
-
}
|
|
25618
|
-
try {
|
|
25619
|
-
// Make the actual fetch request
|
|
25620
|
-
const response = await originalFetch(input, init);
|
|
25621
|
-
// Capture response data
|
|
25622
|
-
if (_configs__WEBPACK_IMPORTED_MODULE_2__.configs.recordResponseHeaders) {
|
|
25623
|
-
networkRequest.responseHeaders = _headersToObject(response.headers);
|
|
25624
25600
|
}
|
|
25625
25601
|
if (_configs__WEBPACK_IMPORTED_MODULE_2__.configs.shouldRecordBody) {
|
|
25626
|
-
const
|
|
25627
|
-
|
|
25628
|
-
|
|
25629
|
-
|
|
25602
|
+
const urlStr = inputIsRequest
|
|
25603
|
+
? input.url
|
|
25604
|
+
: (typeof input === 'string' || input instanceof URL ? String(input) : '');
|
|
25605
|
+
// Only attempt to read the body from init (safe); avoid constructing/cloning Requests
|
|
25606
|
+
// If the caller passed a Request as input, we do not attempt to read its body here
|
|
25607
|
+
const candidateBody = init === null || init === void 0 ? void 0 : init.body;
|
|
25608
|
+
if (!(0,_utils_type_utils__WEBPACK_IMPORTED_MODULE_0__.isNullish)(candidateBody)) {
|
|
25609
|
+
const requestBody = _tryReadFetchBody({
|
|
25610
|
+
body: candidateBody,
|
|
25611
|
+
url: urlStr,
|
|
25612
|
+
});
|
|
25613
|
+
if ((requestBody === null || requestBody === void 0 ? void 0 : requestBody.length) &&
|
|
25614
|
+
new Blob([requestBody]).size <= _configs__WEBPACK_IMPORTED_MODULE_2__.configs.maxCapturingHttpPayloadSize) {
|
|
25615
|
+
networkRequest.requestBody = requestBody;
|
|
25616
|
+
}
|
|
25630
25617
|
}
|
|
25631
25618
|
}
|
|
25632
|
-
|
|
25633
|
-
|
|
25634
|
-
|
|
25635
|
-
|
|
25636
|
-
|
|
25637
|
-
|
|
25638
|
-
|
|
25639
|
-
|
|
25640
|
-
|
|
25641
|
-
|
|
25619
|
+
try {
|
|
25620
|
+
// Make the actual fetch request
|
|
25621
|
+
const response = await originalFetch(input, init);
|
|
25622
|
+
// Capture response data
|
|
25623
|
+
if (_configs__WEBPACK_IMPORTED_MODULE_2__.configs.recordResponseHeaders) {
|
|
25624
|
+
networkRequest.responseHeaders = _headersToObject(response.headers);
|
|
25625
|
+
}
|
|
25626
|
+
if (_configs__WEBPACK_IMPORTED_MODULE_2__.configs.shouldRecordBody) {
|
|
25627
|
+
const responseBody = await _tryReadResponseBody(response);
|
|
25628
|
+
if ((responseBody === null || responseBody === void 0 ? void 0 : responseBody.length) &&
|
|
25629
|
+
new Blob([responseBody]).size <= _configs__WEBPACK_IMPORTED_MODULE_2__.configs.maxCapturingHttpPayloadSize) {
|
|
25630
|
+
networkRequest.responseBody = responseBody;
|
|
25631
|
+
}
|
|
25632
|
+
}
|
|
25633
|
+
// Attach network request data to the response for later access
|
|
25642
25634
|
// @ts-ignore
|
|
25643
|
-
|
|
25635
|
+
response.networkRequest = networkRequest;
|
|
25636
|
+
return response;
|
|
25644
25637
|
}
|
|
25645
|
-
|
|
25646
|
-
|
|
25647
|
-
|
|
25648
|
-
|
|
25649
|
-
|
|
25650
|
-
|
|
25651
|
-
|
|
25638
|
+
catch (error) {
|
|
25639
|
+
// Even if the fetch fails, we can still capture the request data
|
|
25640
|
+
// Attach captured request data to the thrown error for downstream handling
|
|
25641
|
+
// @ts-ignore
|
|
25642
|
+
if (error && typeof error === 'object') {
|
|
25643
|
+
// @ts-ignore
|
|
25644
|
+
error.networkRequest = networkRequest;
|
|
25645
|
+
}
|
|
25646
|
+
throw error;
|
|
25647
|
+
}
|
|
25648
|
+
};
|
|
25649
|
+
// Preserve the original fetch function's properties
|
|
25650
|
+
Object.setPrototypeOf(window.fetch, originalFetch);
|
|
25651
|
+
Object.defineProperty(window.fetch, 'name', { value: 'fetch' });
|
|
25652
|
+
Object.defineProperty(window.fetch, 'length', { value: originalFetch.length });
|
|
25653
|
+
}
|
|
25652
25654
|
}
|
|
25653
25655
|
|
|
25654
25656
|
|