@multiplayer-app/session-recorder-browser 1.2.33 → 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 +133 -98
- package/dist/browser/index.js.map +1 -1
- package/dist/exporters/index.js +1 -1
- package/dist/index.js +133 -98
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +133 -98
- package/dist/index.umd.js.map +1 -1
- package/dist/patch/fetch.js +71 -78
- package/dist/patch/fetch.js.map +1 -1
- package/dist/sessionRecorder.d.ts +7 -0
- package/dist/sessionRecorder.d.ts.map +1 -1
- package/dist/sessionRecorder.js +48 -13
- package/dist/sessionRecorder.js.map +1 -1
- package/dist/sessionWidget/dragManager.d.ts +1 -0
- package/dist/sessionWidget/dragManager.d.ts.map +1 -1
- package/dist/sessionWidget/dragManager.js +9 -0
- package/dist/sessionWidget/dragManager.js.map +1 -1
- package/dist/sessionWidget/index.d.ts +1 -1
- package/dist/sessionWidget/index.d.ts.map +1 -1
- package/dist/sessionWidget/index.js +4 -6
- package/dist/sessionWidget/index.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
|
|
|
@@ -27570,41 +27563,75 @@ class SessionRecorder extends lib0_observable__WEBPACK_IMPORTED_MODULE_14__.Obse
|
|
|
27570
27563
|
* Register session widget event listeners for controlling session actions
|
|
27571
27564
|
*/
|
|
27572
27565
|
_registerWidgetEvents() {
|
|
27573
|
-
this._sessionWidget.on('
|
|
27566
|
+
this._sessionWidget.on('start', () => {
|
|
27574
27567
|
this.error = '';
|
|
27575
|
-
|
|
27576
|
-
|
|
27577
|
-
|
|
27578
|
-
|
|
27579
|
-
|
|
27580
|
-
}
|
|
27568
|
+
this._handleStart();
|
|
27569
|
+
});
|
|
27570
|
+
this._sessionWidget.on('stop', (comment) => {
|
|
27571
|
+
this.error = '';
|
|
27572
|
+
this._handleStop(comment);
|
|
27581
27573
|
});
|
|
27582
27574
|
this._sessionWidget.on('pause', () => {
|
|
27583
27575
|
this.error = '';
|
|
27584
|
-
this.
|
|
27576
|
+
this._handlePause();
|
|
27585
27577
|
});
|
|
27586
27578
|
this._sessionWidget.on('resume', () => {
|
|
27587
27579
|
this.error = '';
|
|
27588
|
-
this.
|
|
27580
|
+
this._handleResume();
|
|
27589
27581
|
});
|
|
27590
27582
|
this._sessionWidget.on('cancel', () => {
|
|
27591
27583
|
this.error = '';
|
|
27592
|
-
this.
|
|
27584
|
+
this._handleCancel();
|
|
27593
27585
|
});
|
|
27594
27586
|
this._sessionWidget.on('continuous-debugging', (enabled) => {
|
|
27595
27587
|
this.error = '';
|
|
27596
27588
|
if (enabled) {
|
|
27597
|
-
this.
|
|
27589
|
+
this._handleContinuousDebugging();
|
|
27598
27590
|
}
|
|
27599
27591
|
else {
|
|
27600
|
-
this.
|
|
27592
|
+
this._handleStop();
|
|
27601
27593
|
}
|
|
27602
27594
|
});
|
|
27603
27595
|
this._sessionWidget.on('save', () => {
|
|
27604
27596
|
this.error = '';
|
|
27605
|
-
this.
|
|
27597
|
+
this._handleSave();
|
|
27606
27598
|
});
|
|
27607
27599
|
}
|
|
27600
|
+
_handleStart() {
|
|
27601
|
+
if (this.sessionState === _types__WEBPACK_IMPORTED_MODULE_3__.SessionState.stopped) {
|
|
27602
|
+
this.start(_multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_11__.SessionType.MANUAL);
|
|
27603
|
+
}
|
|
27604
|
+
}
|
|
27605
|
+
_handleStop(comment) {
|
|
27606
|
+
if (this.sessionState === _types__WEBPACK_IMPORTED_MODULE_3__.SessionState.started || this.sessionState === _types__WEBPACK_IMPORTED_MODULE_3__.SessionState.paused) {
|
|
27607
|
+
this.stop(comment);
|
|
27608
|
+
}
|
|
27609
|
+
}
|
|
27610
|
+
_handlePause() {
|
|
27611
|
+
if (this.sessionState === _types__WEBPACK_IMPORTED_MODULE_3__.SessionState.started) {
|
|
27612
|
+
this.pause();
|
|
27613
|
+
}
|
|
27614
|
+
}
|
|
27615
|
+
_handleResume() {
|
|
27616
|
+
if (this.sessionState === _types__WEBPACK_IMPORTED_MODULE_3__.SessionState.paused) {
|
|
27617
|
+
this.resume();
|
|
27618
|
+
}
|
|
27619
|
+
}
|
|
27620
|
+
_handleCancel() {
|
|
27621
|
+
if (this.sessionState === _types__WEBPACK_IMPORTED_MODULE_3__.SessionState.started || this.sessionState === _types__WEBPACK_IMPORTED_MODULE_3__.SessionState.paused) {
|
|
27622
|
+
this.cancel();
|
|
27623
|
+
}
|
|
27624
|
+
}
|
|
27625
|
+
_handleSave() {
|
|
27626
|
+
if (this.sessionState === _types__WEBPACK_IMPORTED_MODULE_3__.SessionState.started && this.continuousRecording) {
|
|
27627
|
+
this.save();
|
|
27628
|
+
}
|
|
27629
|
+
}
|
|
27630
|
+
_handleContinuousDebugging() {
|
|
27631
|
+
if (this.sessionState === _types__WEBPACK_IMPORTED_MODULE_3__.SessionState.stopped) {
|
|
27632
|
+
this.start(_multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_11__.SessionType.CONTINUOUS);
|
|
27633
|
+
}
|
|
27634
|
+
}
|
|
27608
27635
|
/**
|
|
27609
27636
|
* Register session limit reaching listeners for controlling session end
|
|
27610
27637
|
*/
|
|
@@ -27661,6 +27688,7 @@ class SessionRecorder extends lib0_observable__WEBPACK_IMPORTED_MODULE_14__.Obse
|
|
|
27661
27688
|
}
|
|
27662
27689
|
catch (error) {
|
|
27663
27690
|
this.error = error.message;
|
|
27691
|
+
this.sessionState = _types__WEBPACK_IMPORTED_MODULE_3__.SessionState.stopped;
|
|
27664
27692
|
if (this.continuousRecording) {
|
|
27665
27693
|
this.sessionType = _multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_11__.SessionType.MANUAL;
|
|
27666
27694
|
}
|
|
@@ -28108,6 +28136,7 @@ class DragManager {
|
|
|
28108
28136
|
this.isDragging = false;
|
|
28109
28137
|
this.dragStarted = false;
|
|
28110
28138
|
this.isOnLeftHalfOfScreen = false;
|
|
28139
|
+
this.isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
28111
28140
|
this.recorderButton = recorderButton;
|
|
28112
28141
|
this.recorderPlacement = recorderPlacement;
|
|
28113
28142
|
this.onDragEnd = onDragEnd;
|
|
@@ -28115,10 +28144,14 @@ class DragManager {
|
|
|
28115
28144
|
this.onRecordingButtonClick = onRecordingButtonClick;
|
|
28116
28145
|
}
|
|
28117
28146
|
init() {
|
|
28147
|
+
if (!this.isBrowser)
|
|
28148
|
+
return;
|
|
28118
28149
|
this.loadStoredPosition();
|
|
28119
28150
|
this.setupDragListeners();
|
|
28120
28151
|
}
|
|
28121
28152
|
loadStoredPosition() {
|
|
28153
|
+
if (!this.isBrowser || typeof window === 'undefined' || typeof localStorage === 'undefined')
|
|
28154
|
+
return;
|
|
28122
28155
|
const savedPosition = localStorage.getItem(_constants__WEBPACK_IMPORTED_MODULE_0__.POSITION_STATE_KEY);
|
|
28123
28156
|
if (!savedPosition) {
|
|
28124
28157
|
return;
|
|
@@ -28149,11 +28182,15 @@ class DragManager {
|
|
|
28149
28182
|
});
|
|
28150
28183
|
}
|
|
28151
28184
|
savePosition(r, b) {
|
|
28185
|
+
if (!this.isBrowser || typeof window === 'undefined' || typeof localStorage === 'undefined')
|
|
28186
|
+
return;
|
|
28152
28187
|
const right = (r / window.innerWidth) * 100;
|
|
28153
28188
|
const bottom = (b / window.innerHeight) * 100;
|
|
28154
28189
|
localStorage.setItem(_constants__WEBPACK_IMPORTED_MODULE_0__.POSITION_STATE_KEY, JSON.stringify({ right, bottom }));
|
|
28155
28190
|
}
|
|
28156
28191
|
setupDragListeners() {
|
|
28192
|
+
if (!this.isBrowser || typeof document === 'undefined' || typeof window === 'undefined')
|
|
28193
|
+
return;
|
|
28157
28194
|
this.recorderButton.addEventListener('mousedown', (e) => {
|
|
28158
28195
|
const onMouseUp = () => {
|
|
28159
28196
|
const isDraggable = !this.recorderButton.classList.contains('no-draggable');
|
|
@@ -28264,6 +28301,7 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
|
|
|
28264
28301
|
else {
|
|
28265
28302
|
(_b = this.buttonDraggabilityObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
|
|
28266
28303
|
}
|
|
28304
|
+
this.uiManager.setPopoverLoadingState(newState === _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.LOADING);
|
|
28267
28305
|
this.updateButton(icon, tooltip, excludeClasses, classes);
|
|
28268
28306
|
}
|
|
28269
28307
|
set initialPopoverVisible(v) {
|
|
@@ -28318,7 +28356,6 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
|
|
|
28318
28356
|
else {
|
|
28319
28357
|
this.buttonState = _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.CONTINUOUS_DEBUGGING;
|
|
28320
28358
|
}
|
|
28321
|
-
this.uiManager.setPopoverLoadingState(false);
|
|
28322
28359
|
}
|
|
28323
28360
|
else {
|
|
28324
28361
|
this.buttonState = _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.IDLE;
|
|
@@ -28654,7 +28691,6 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
|
|
|
28654
28691
|
return;
|
|
28655
28692
|
if (this._buttonState === _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.LOADING) {
|
|
28656
28693
|
this.onCancel();
|
|
28657
|
-
this.uiManager.setPopoverLoadingState(false);
|
|
28658
28694
|
}
|
|
28659
28695
|
this.initialPopoverVisible = false;
|
|
28660
28696
|
this.buttonState = this._continuousRecording
|
|
@@ -28763,13 +28799,12 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
|
|
|
28763
28799
|
}
|
|
28764
28800
|
startRecording() {
|
|
28765
28801
|
this.buttonState = _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.LOADING;
|
|
28766
|
-
this.uiManager.setPopoverLoadingState(true);
|
|
28767
28802
|
this.onStart();
|
|
28768
28803
|
}
|
|
28769
28804
|
onStart() {
|
|
28770
28805
|
if (!this.recorderButton)
|
|
28771
28806
|
return;
|
|
28772
|
-
this.emit('
|
|
28807
|
+
this.emit('start', []);
|
|
28773
28808
|
}
|
|
28774
28809
|
onStop() {
|
|
28775
28810
|
if (!this.isBrowser)
|
|
@@ -28781,11 +28816,11 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
|
|
|
28781
28816
|
? this.commentTextarea
|
|
28782
28817
|
: this.submitSessionDialog.querySelector('#mp-recording-comment');
|
|
28783
28818
|
if (commentElement) {
|
|
28784
|
-
this.emit('
|
|
28819
|
+
this.emit('stop', [commentElement.value]);
|
|
28785
28820
|
commentElement.value = '';
|
|
28786
28821
|
return;
|
|
28787
28822
|
}
|
|
28788
|
-
this.emit('
|
|
28823
|
+
this.emit('stop', []);
|
|
28789
28824
|
}
|
|
28790
28825
|
onPause() {
|
|
28791
28826
|
this.emit('pause', []);
|