@multiplayer-app/session-recorder-browser 1.2.9 → 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/dist/browser/index.js +179 -13
- package/dist/browser/index.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.LICENSE.txt +6 -0
- package/dist/index.js.map +1 -1
- package/dist/otel/index.d.ts.map +1 -1
- package/dist/patch/fetch.d.ts.map +1 -0
- package/dist/patch/index.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/browser/index.js
CHANGED
|
@@ -25245,7 +25245,7 @@ const DEFAULT_MAX_HTTP_CAPTURING_PAYLOAD_SIZE = 100000;
|
|
|
25245
25245
|
const SESSION_RESPONSE = 'multiplayer-debug-session-response';
|
|
25246
25246
|
const CONTINUOUS_DEBUGGING_TIMEOUT = 60000; // 1 minutes
|
|
25247
25247
|
const DEBUG_SESSION_MAX_DURATION_SECONDS = 10 * 60 + 30; // TODO: move to shared config otel core
|
|
25248
|
-
const PACKAGE_VERSION_EXPORT = "1.2.
|
|
25248
|
+
const PACKAGE_VERSION_EXPORT = "1.2.10" || 0;
|
|
25249
25249
|
// Regex patterns for OpenTelemetry ignore URLs
|
|
25250
25250
|
const OTEL_IGNORE_URLS = [
|
|
25251
25251
|
// Traces endpoint
|
|
@@ -25952,13 +25952,11 @@ class TracerBrowserSDK {
|
|
|
25952
25952
|
return;
|
|
25953
25953
|
}
|
|
25954
25954
|
// @ts-ignore
|
|
25955
|
-
const
|
|
25956
|
-
|
|
25957
|
-
const responseBody =
|
|
25958
|
-
|
|
25959
|
-
const
|
|
25960
|
-
// @ts-ignore
|
|
25961
|
-
const responseHeaders = xhr.networkRequest.responseHeaders || {};
|
|
25955
|
+
const networkRequest = xhr.networkRequest;
|
|
25956
|
+
const requestBody = networkRequest.requestBody;
|
|
25957
|
+
const responseBody = networkRequest.responseBody;
|
|
25958
|
+
const requestHeaders = networkRequest.requestHeaders || {};
|
|
25959
|
+
const responseHeaders = networkRequest.responseHeaders || {};
|
|
25962
25960
|
const payload = {
|
|
25963
25961
|
requestBody,
|
|
25964
25962
|
responseBody,
|
|
@@ -25988,12 +25986,28 @@ class TracerBrowserSDK {
|
|
|
25988
25986
|
if (!captureBody && !captureHeaders) {
|
|
25989
25987
|
return;
|
|
25990
25988
|
}
|
|
25991
|
-
|
|
25992
|
-
|
|
25993
|
-
const
|
|
25989
|
+
// Try to get data from our fetch wrapper first
|
|
25990
|
+
// @ts-ignore
|
|
25991
|
+
const networkRequest = response === null || response === void 0 ? void 0 : response.networkRequest;
|
|
25992
|
+
let requestBody = null;
|
|
25994
25993
|
let responseBody = null;
|
|
25995
|
-
|
|
25996
|
-
|
|
25994
|
+
let requestHeaders = {};
|
|
25995
|
+
let responseHeaders = {};
|
|
25996
|
+
if (networkRequest) {
|
|
25997
|
+
// Use data captured by our fetch wrapper
|
|
25998
|
+
requestBody = networkRequest.requestBody;
|
|
25999
|
+
responseBody = networkRequest.responseBody;
|
|
26000
|
+
requestHeaders = networkRequest.requestHeaders || {};
|
|
26001
|
+
responseHeaders = networkRequest.responseHeaders || {};
|
|
26002
|
+
}
|
|
26003
|
+
else {
|
|
26004
|
+
// Fallback to original OpenTelemetry approach
|
|
26005
|
+
requestBody = request.body;
|
|
26006
|
+
requestHeaders = (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.headersToObject)(request.headers);
|
|
26007
|
+
responseHeaders = (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.headersToObject)(response instanceof Response ? response.headers : undefined);
|
|
26008
|
+
if (response instanceof Response && response.body) {
|
|
26009
|
+
responseBody = await (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.extractResponseBody)(response);
|
|
26010
|
+
}
|
|
25997
26011
|
}
|
|
25998
26012
|
const payload = {
|
|
25999
26013
|
requestBody,
|
|
@@ -26060,6 +26074,156 @@ class TracerBrowserSDK {
|
|
|
26060
26074
|
}
|
|
26061
26075
|
|
|
26062
26076
|
|
|
26077
|
+
/***/ }),
|
|
26078
|
+
|
|
26079
|
+
/***/ "./src/patch/fetch.ts":
|
|
26080
|
+
/*!****************************!*\
|
|
26081
|
+
!*** ./src/patch/fetch.ts ***!
|
|
26082
|
+
\****************************/
|
|
26083
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
26084
|
+
|
|
26085
|
+
"use strict";
|
|
26086
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26087
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
26088
|
+
/* harmony export */ setMaxCapturingHttpPayloadSize: () => (/* binding */ setMaxCapturingHttpPayloadSize),
|
|
26089
|
+
/* harmony export */ setShouldRecordHttpData: () => (/* binding */ setShouldRecordHttpData)
|
|
26090
|
+
/* harmony export */ });
|
|
26091
|
+
/* harmony import */ var _utils_type_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/type-utils */ "./src/utils/type-utils.ts");
|
|
26092
|
+
/* harmony import */ var _utils_request_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../utils/request-utils */ "./src/utils/request-utils.ts");
|
|
26093
|
+
/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../config */ "./src/config/index.ts");
|
|
26094
|
+
|
|
26095
|
+
|
|
26096
|
+
|
|
26097
|
+
let recordRequestHeaders = true;
|
|
26098
|
+
let recordResponseHeaders = true;
|
|
26099
|
+
const shouldRecordBody = true;
|
|
26100
|
+
let maxCapturingHttpPayloadSize = _config__WEBPACK_IMPORTED_MODULE_2__.DEFAULT_MAX_HTTP_CAPTURING_PAYLOAD_SIZE;
|
|
26101
|
+
const setMaxCapturingHttpPayloadSize = (_maxCapturingHttpPayloadSize) => {
|
|
26102
|
+
maxCapturingHttpPayloadSize = _maxCapturingHttpPayloadSize;
|
|
26103
|
+
};
|
|
26104
|
+
const setShouldRecordHttpData = (shouldRecordBody, shouldRecordHeaders) => {
|
|
26105
|
+
recordRequestHeaders = shouldRecordHeaders;
|
|
26106
|
+
recordResponseHeaders = shouldRecordHeaders;
|
|
26107
|
+
// eslint-disable-next-line
|
|
26108
|
+
shouldRecordBody = shouldRecordBody;
|
|
26109
|
+
};
|
|
26110
|
+
function _tryReadFetchBody({ body, url, }) {
|
|
26111
|
+
if ((0,_utils_type_utils__WEBPACK_IMPORTED_MODULE_0__.isNullish)(body)) {
|
|
26112
|
+
return null;
|
|
26113
|
+
}
|
|
26114
|
+
if ((0,_utils_type_utils__WEBPACK_IMPORTED_MODULE_0__.isString)(body)) {
|
|
26115
|
+
return body;
|
|
26116
|
+
}
|
|
26117
|
+
if ((0,_utils_type_utils__WEBPACK_IMPORTED_MODULE_0__.isDocument)(body)) {
|
|
26118
|
+
return body.textContent;
|
|
26119
|
+
}
|
|
26120
|
+
if ((0,_utils_type_utils__WEBPACK_IMPORTED_MODULE_0__.isFormData)(body)) {
|
|
26121
|
+
return (0,_utils_request_utils__WEBPACK_IMPORTED_MODULE_1__.formDataToQuery)(body);
|
|
26122
|
+
}
|
|
26123
|
+
if ((0,_utils_type_utils__WEBPACK_IMPORTED_MODULE_0__.isObject)(body)) {
|
|
26124
|
+
try {
|
|
26125
|
+
return JSON.stringify(body);
|
|
26126
|
+
}
|
|
26127
|
+
catch (_a) {
|
|
26128
|
+
return '[Fetch] Failed to stringify request object';
|
|
26129
|
+
}
|
|
26130
|
+
}
|
|
26131
|
+
return `[Fetch] Cannot read body of type ${toString.call(body)}`;
|
|
26132
|
+
}
|
|
26133
|
+
async function _tryReadResponseBody(response) {
|
|
26134
|
+
var _a, _b;
|
|
26135
|
+
try {
|
|
26136
|
+
// Clone the response to avoid consuming the original stream
|
|
26137
|
+
const clonedResponse = response.clone();
|
|
26138
|
+
// Try different methods to read the body
|
|
26139
|
+
if ((_a = response.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.includes('application/json')) {
|
|
26140
|
+
const json = await clonedResponse.json();
|
|
26141
|
+
return JSON.stringify(json);
|
|
26142
|
+
}
|
|
26143
|
+
else if ((_b = response.headers.get('content-type')) === null || _b === void 0 ? void 0 : _b.includes('text/')) {
|
|
26144
|
+
return await clonedResponse.text();
|
|
26145
|
+
}
|
|
26146
|
+
else {
|
|
26147
|
+
// For other content types, try text first, fallback to arrayBuffer
|
|
26148
|
+
try {
|
|
26149
|
+
return await clonedResponse.text();
|
|
26150
|
+
}
|
|
26151
|
+
catch (_c) {
|
|
26152
|
+
try {
|
|
26153
|
+
const arrayBuffer = await clonedResponse.arrayBuffer();
|
|
26154
|
+
return `[Fetch] Binary data (${arrayBuffer.byteLength} bytes)`;
|
|
26155
|
+
}
|
|
26156
|
+
catch (_d) {
|
|
26157
|
+
return '[Fetch] Unable to read response body';
|
|
26158
|
+
}
|
|
26159
|
+
}
|
|
26160
|
+
}
|
|
26161
|
+
}
|
|
26162
|
+
catch (error) {
|
|
26163
|
+
return `[Fetch] Error reading response body: ${error instanceof Error ? error.message : 'Unknown error'}`;
|
|
26164
|
+
}
|
|
26165
|
+
}
|
|
26166
|
+
function _headersToObject(headers) {
|
|
26167
|
+
const result = {};
|
|
26168
|
+
headers.forEach((value, key) => {
|
|
26169
|
+
result[key] = value;
|
|
26170
|
+
});
|
|
26171
|
+
return result;
|
|
26172
|
+
}
|
|
26173
|
+
// Store original fetch
|
|
26174
|
+
const originalFetch = window.fetch;
|
|
26175
|
+
// Override fetch
|
|
26176
|
+
window.fetch = async function (input, init) {
|
|
26177
|
+
const networkRequest = {};
|
|
26178
|
+
// Capture request data
|
|
26179
|
+
const request = new Request(input, init);
|
|
26180
|
+
if (recordRequestHeaders) {
|
|
26181
|
+
networkRequest.requestHeaders = _headersToObject(request.headers);
|
|
26182
|
+
}
|
|
26183
|
+
if (shouldRecordBody && request.body) {
|
|
26184
|
+
const requestBody = _tryReadFetchBody({
|
|
26185
|
+
body: request.body,
|
|
26186
|
+
url: request.url
|
|
26187
|
+
});
|
|
26188
|
+
if ((requestBody === null || requestBody === void 0 ? void 0 : requestBody.length) &&
|
|
26189
|
+
new Blob([requestBody]).size <= maxCapturingHttpPayloadSize) {
|
|
26190
|
+
networkRequest.requestBody = requestBody;
|
|
26191
|
+
}
|
|
26192
|
+
}
|
|
26193
|
+
try {
|
|
26194
|
+
// Make the actual fetch request
|
|
26195
|
+
const response = await originalFetch(input, init);
|
|
26196
|
+
// Capture response data
|
|
26197
|
+
if (recordResponseHeaders) {
|
|
26198
|
+
networkRequest.responseHeaders = _headersToObject(response.headers);
|
|
26199
|
+
}
|
|
26200
|
+
if (shouldRecordBody) {
|
|
26201
|
+
const responseBody = await _tryReadResponseBody(response);
|
|
26202
|
+
if ((responseBody === null || responseBody === void 0 ? void 0 : responseBody.length) &&
|
|
26203
|
+
new Blob([responseBody]).size <= maxCapturingHttpPayloadSize) {
|
|
26204
|
+
networkRequest.responseBody = responseBody;
|
|
26205
|
+
}
|
|
26206
|
+
}
|
|
26207
|
+
// Attach network request data to the response for later access
|
|
26208
|
+
// @ts-ignore
|
|
26209
|
+
response.networkRequest = networkRequest;
|
|
26210
|
+
return response;
|
|
26211
|
+
}
|
|
26212
|
+
catch (error) {
|
|
26213
|
+
// Even if the fetch fails, we can still capture the request data
|
|
26214
|
+
// @ts-ignore
|
|
26215
|
+
const errorResponse = new Response(null, { status: 0, statusText: 'Network Error' });
|
|
26216
|
+
// @ts-ignore
|
|
26217
|
+
errorResponse.networkRequest = networkRequest;
|
|
26218
|
+
throw error;
|
|
26219
|
+
}
|
|
26220
|
+
};
|
|
26221
|
+
// Preserve the original fetch function's properties
|
|
26222
|
+
Object.setPrototypeOf(window.fetch, originalFetch);
|
|
26223
|
+
Object.defineProperty(window.fetch, 'name', { value: 'fetch' });
|
|
26224
|
+
Object.defineProperty(window.fetch, 'length', { value: originalFetch.length });
|
|
26225
|
+
|
|
26226
|
+
|
|
26063
26227
|
/***/ }),
|
|
26064
26228
|
|
|
26065
26229
|
/***/ "./src/patch/index.ts":
|
|
@@ -26071,6 +26235,8 @@ class TracerBrowserSDK {
|
|
|
26071
26235
|
"use strict";
|
|
26072
26236
|
__webpack_require__.r(__webpack_exports__);
|
|
26073
26237
|
/* harmony import */ var _xhr__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./xhr */ "./src/patch/xhr.ts");
|
|
26238
|
+
/* harmony import */ var _fetch__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fetch */ "./src/patch/fetch.ts");
|
|
26239
|
+
|
|
26074
26240
|
|
|
26075
26241
|
|
|
26076
26242
|
|