@multiplayer-app/session-recorder-browser 1.2.29 → 1.2.30
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/README.md +0 -60
- package/dist/browser/index.js +154 -120
- package/dist/browser/index.js.map +1 -1
- package/dist/exporters/index.js +1 -1
- package/dist/exporters/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +154 -120
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +154 -120
- package/dist/index.umd.js.map +1 -1
- package/dist/patch/fetch.js +79 -77
- package/dist/patch/fetch.js.map +1 -1
- package/dist/sessionRecorder.d.ts +2 -2
- package/dist/sessionRecorder.d.ts.map +1 -1
- package/dist/sessionRecorder.js +10 -5
- package/dist/sessionRecorder.js.map +1 -1
- package/dist/sessionWidget/index.d.ts +12 -11
- package/dist/sessionWidget/index.d.ts.map +1 -1
- package/dist/sessionWidget/index.js +27 -27
- package/dist/sessionWidget/index.js.map +1 -1
- package/dist/types/sessionRecorder.d.ts +1 -1
- package/dist/types/sessionRecorder.d.ts.map +1 -1
- package/dist/utils/storage.d.ts.map +1 -1
- package/dist/utils/storage.js +14 -4
- package/dist/utils/storage.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { SessionRecorder } from './sessionRecorder';
|
|
|
4
4
|
export * from './types';
|
|
5
5
|
export * from './navigation';
|
|
6
6
|
export * from '@multiplayer-app/session-recorder-common';
|
|
7
|
-
declare
|
|
7
|
+
declare let SessionRecorderInstance: SessionRecorder;
|
|
8
8
|
export { recorderEventBus };
|
|
9
9
|
export default SessionRecorderInstance;
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,CAAA;AAEhB,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,cAAc,SAAS,CAAA;AACvB,cAAc,cAAc,CAAA;AAC5B,cAAc,0CAA0C,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,CAAA;AAEhB,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,cAAc,SAAS,CAAA;AACvB,cAAc,cAAc,CAAA;AAC5B,cAAc,0CAA0C,CAAA;AASxD,QAAA,IAAI,uBAAuB,EAAE,eAAe,CAAA;AAoB5C,OAAO,EAAE,gBAAgB,EAAE,CAAA;AAE3B,eAAe,uBAAuB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -24143,7 +24143,7 @@ const DEFAULT_MAX_HTTP_CAPTURING_PAYLOAD_SIZE = 100000;
|
|
|
24143
24143
|
const SESSION_RESPONSE = 'multiplayer-debug-session-response';
|
|
24144
24144
|
const CONTINUOUS_DEBUGGING_TIMEOUT = 60000; // 1 minutes
|
|
24145
24145
|
const DEBUG_SESSION_MAX_DURATION_SECONDS = 10 * 60 + 30; // TODO: move to shared config otel core
|
|
24146
|
-
const PACKAGE_VERSION_EXPORT = "1.2.
|
|
24146
|
+
const PACKAGE_VERSION_EXPORT = "1.2.30" || 0;
|
|
24147
24147
|
// Regex patterns for OpenTelemetry ignore URLs
|
|
24148
24148
|
const OTEL_IGNORE_URLS = [
|
|
24149
24149
|
// Traces endpoint
|
|
@@ -25375,91 +25375,93 @@ function _headersInitToObject(headersInit) {
|
|
|
25375
25375
|
}
|
|
25376
25376
|
return result;
|
|
25377
25377
|
}
|
|
25378
|
-
|
|
25379
|
-
|
|
25380
|
-
|
|
25381
|
-
|
|
25382
|
-
|
|
25383
|
-
|
|
25384
|
-
|
|
25385
|
-
|
|
25386
|
-
|
|
25387
|
-
|
|
25388
|
-
|
|
25389
|
-
|
|
25390
|
-
|
|
25391
|
-
|
|
25392
|
-
|
|
25393
|
-
|
|
25394
|
-
|
|
25395
|
-
|
|
25396
|
-
|
|
25397
|
-
|
|
25398
|
-
}
|
|
25399
|
-
if (_configs__WEBPACK_IMPORTED_MODULE_2__.configs.recordRequestHeaders) {
|
|
25400
|
-
if (requestForMetadata) {
|
|
25401
|
-
networkRequest.requestHeaders = _headersToObject(requestForMetadata.headers);
|
|
25402
|
-
}
|
|
25403
|
-
else if (inputIsRequest) {
|
|
25404
|
-
networkRequest.requestHeaders = _headersToObject(input.headers);
|
|
25405
|
-
}
|
|
25406
|
-
else {
|
|
25407
|
-
networkRequest.requestHeaders = _headersInitToObject(init === null || init === void 0 ? void 0 : init.headers);
|
|
25408
|
-
}
|
|
25409
|
-
}
|
|
25410
|
-
if (_configs__WEBPACK_IMPORTED_MODULE_2__.configs.shouldRecordBody) {
|
|
25411
|
-
// Prefer reading from the safely constructed Request; else fallback to init.body
|
|
25412
|
-
const urlStr = inputIsRequest
|
|
25413
|
-
? input.url
|
|
25414
|
-
: (typeof input === 'string' || input instanceof URL ? String(input) : '');
|
|
25415
|
-
const candidateBody = requestForMetadata
|
|
25416
|
-
? requestForMetadata.body
|
|
25417
|
-
: (inputIsRequest ? init === null || init === void 0 ? void 0 : init.body : init === null || init === void 0 ? void 0 : init.body);
|
|
25418
|
-
if (!(0,_utils_type_utils__WEBPACK_IMPORTED_MODULE_0__.isNullish)(candidateBody)) {
|
|
25419
|
-
const requestBody = _tryReadFetchBody({
|
|
25420
|
-
body: candidateBody,
|
|
25421
|
-
url: urlStr,
|
|
25422
|
-
});
|
|
25423
|
-
if ((requestBody === null || requestBody === void 0 ? void 0 : requestBody.length) &&
|
|
25424
|
-
new Blob([requestBody]).size <= _configs__WEBPACK_IMPORTED_MODULE_2__.configs.maxCapturingHttpPayloadSize) {
|
|
25425
|
-
networkRequest.requestBody = requestBody;
|
|
25378
|
+
if (typeof window !== 'undefined' && typeof window.fetch !== 'undefined') {
|
|
25379
|
+
// Store original fetch
|
|
25380
|
+
const originalFetch = window.fetch;
|
|
25381
|
+
// Override fetch
|
|
25382
|
+
window.fetch = async function (input,
|
|
25383
|
+
// eslint-disable-next-line
|
|
25384
|
+
init) {
|
|
25385
|
+
const networkRequest = {};
|
|
25386
|
+
// Capture request data
|
|
25387
|
+
const inputIsRequest = typeof Request !== 'undefined' && input instanceof Request;
|
|
25388
|
+
const safeToConstructRequest = !inputIsRequest || !input.bodyUsed;
|
|
25389
|
+
// Only construct a new Request when it's safe (i.e., body not already used)
|
|
25390
|
+
let requestForMetadata = null;
|
|
25391
|
+
if (safeToConstructRequest) {
|
|
25392
|
+
try {
|
|
25393
|
+
requestForMetadata = new Request(input, init);
|
|
25394
|
+
}
|
|
25395
|
+
catch (_a) {
|
|
25396
|
+
// If construction fails for any reason, fall back to using available data
|
|
25397
|
+
requestForMetadata = null;
|
|
25426
25398
|
}
|
|
25427
25399
|
}
|
|
25428
|
-
|
|
25429
|
-
|
|
25430
|
-
|
|
25431
|
-
|
|
25432
|
-
|
|
25433
|
-
|
|
25434
|
-
|
|
25400
|
+
if (_configs__WEBPACK_IMPORTED_MODULE_2__.configs.recordRequestHeaders) {
|
|
25401
|
+
if (requestForMetadata) {
|
|
25402
|
+
networkRequest.requestHeaders = _headersToObject(requestForMetadata.headers);
|
|
25403
|
+
}
|
|
25404
|
+
else if (inputIsRequest) {
|
|
25405
|
+
networkRequest.requestHeaders = _headersToObject(input.headers);
|
|
25406
|
+
}
|
|
25407
|
+
else {
|
|
25408
|
+
networkRequest.requestHeaders = _headersInitToObject(init === null || init === void 0 ? void 0 : init.headers);
|
|
25409
|
+
}
|
|
25435
25410
|
}
|
|
25436
25411
|
if (_configs__WEBPACK_IMPORTED_MODULE_2__.configs.shouldRecordBody) {
|
|
25437
|
-
|
|
25438
|
-
|
|
25439
|
-
|
|
25440
|
-
|
|
25412
|
+
// Prefer reading from the safely constructed Request; else fallback to init.body
|
|
25413
|
+
const urlStr = inputIsRequest
|
|
25414
|
+
? input.url
|
|
25415
|
+
: (typeof input === 'string' || input instanceof URL ? String(input) : '');
|
|
25416
|
+
const candidateBody = requestForMetadata
|
|
25417
|
+
? requestForMetadata.body
|
|
25418
|
+
: (inputIsRequest ? init === null || init === void 0 ? void 0 : init.body : init === null || init === void 0 ? void 0 : init.body);
|
|
25419
|
+
if (!(0,_utils_type_utils__WEBPACK_IMPORTED_MODULE_0__.isNullish)(candidateBody)) {
|
|
25420
|
+
const requestBody = _tryReadFetchBody({
|
|
25421
|
+
body: candidateBody,
|
|
25422
|
+
url: urlStr,
|
|
25423
|
+
});
|
|
25424
|
+
if ((requestBody === null || requestBody === void 0 ? void 0 : requestBody.length) &&
|
|
25425
|
+
new Blob([requestBody]).size <= _configs__WEBPACK_IMPORTED_MODULE_2__.configs.maxCapturingHttpPayloadSize) {
|
|
25426
|
+
networkRequest.requestBody = requestBody;
|
|
25427
|
+
}
|
|
25441
25428
|
}
|
|
25442
25429
|
}
|
|
25443
|
-
|
|
25444
|
-
|
|
25445
|
-
|
|
25446
|
-
|
|
25447
|
-
|
|
25448
|
-
|
|
25449
|
-
|
|
25450
|
-
|
|
25451
|
-
|
|
25452
|
-
|
|
25430
|
+
try {
|
|
25431
|
+
// Make the actual fetch request
|
|
25432
|
+
const response = await originalFetch(input, init);
|
|
25433
|
+
// Capture response data
|
|
25434
|
+
if (_configs__WEBPACK_IMPORTED_MODULE_2__.configs.recordResponseHeaders) {
|
|
25435
|
+
networkRequest.responseHeaders = _headersToObject(response.headers);
|
|
25436
|
+
}
|
|
25437
|
+
if (_configs__WEBPACK_IMPORTED_MODULE_2__.configs.shouldRecordBody) {
|
|
25438
|
+
const responseBody = await _tryReadResponseBody(response);
|
|
25439
|
+
if ((responseBody === null || responseBody === void 0 ? void 0 : responseBody.length) &&
|
|
25440
|
+
new Blob([responseBody]).size <= _configs__WEBPACK_IMPORTED_MODULE_2__.configs.maxCapturingHttpPayloadSize) {
|
|
25441
|
+
networkRequest.responseBody = responseBody;
|
|
25442
|
+
}
|
|
25443
|
+
}
|
|
25444
|
+
// Attach network request data to the response for later access
|
|
25453
25445
|
// @ts-ignore
|
|
25454
|
-
|
|
25446
|
+
response.networkRequest = networkRequest;
|
|
25447
|
+
return response;
|
|
25455
25448
|
}
|
|
25456
|
-
|
|
25457
|
-
|
|
25458
|
-
|
|
25459
|
-
//
|
|
25460
|
-
|
|
25461
|
-
|
|
25462
|
-
|
|
25449
|
+
catch (error) {
|
|
25450
|
+
// Even if the fetch fails, we can still capture the request data
|
|
25451
|
+
// Attach captured request data to the thrown error for downstream handling
|
|
25452
|
+
// @ts-ignore
|
|
25453
|
+
if (error && typeof error === 'object') {
|
|
25454
|
+
// @ts-ignore
|
|
25455
|
+
error.networkRequest = networkRequest;
|
|
25456
|
+
}
|
|
25457
|
+
throw error;
|
|
25458
|
+
}
|
|
25459
|
+
};
|
|
25460
|
+
// Preserve the original fetch function's properties
|
|
25461
|
+
Object.setPrototypeOf(window.fetch, originalFetch);
|
|
25462
|
+
Object.defineProperty(window.fetch, 'name', { value: 'fetch' });
|
|
25463
|
+
Object.defineProperty(window.fetch, 'length', { value: originalFetch.length });
|
|
25464
|
+
}
|
|
25463
25465
|
|
|
25464
25466
|
|
|
25465
25467
|
/***/ }),
|
|
@@ -26278,7 +26280,7 @@ class SessionRecorder extends lib0_observable__WEBPACK_IMPORTED_MODULE_14__.Obse
|
|
|
26278
26280
|
*
|
|
26279
26281
|
* This element is used to control the start/stop recording functionality in the session widget UI.
|
|
26280
26282
|
*
|
|
26281
|
-
* @returns {HTMLButtonElement} The recorder button element from the session widget.
|
|
26283
|
+
* @returns {HTMLButtonElement | null} The recorder button element from the session widget.
|
|
26282
26284
|
*/
|
|
26283
26285
|
get sessionWidgetButtonElement() {
|
|
26284
26286
|
return this._sessionWidget.recorderButton;
|
|
@@ -26306,10 +26308,12 @@ class SessionRecorder extends lib0_observable__WEBPACK_IMPORTED_MODULE_14__.Obse
|
|
|
26306
26308
|
* Error message getter and setter
|
|
26307
26309
|
*/
|
|
26308
26310
|
this._error = '';
|
|
26309
|
-
|
|
26310
|
-
const
|
|
26311
|
-
const
|
|
26312
|
-
const
|
|
26311
|
+
// Safety: avoid accessing storage in SSR/non-browser environments
|
|
26312
|
+
const isBrowser = typeof window !== 'undefined';
|
|
26313
|
+
const sessionLocal = isBrowser ? (0,_utils__WEBPACK_IMPORTED_MODULE_2__.getStoredItem)(_config__WEBPACK_IMPORTED_MODULE_4__.SESSION_PROP_NAME, true) : null;
|
|
26314
|
+
const sessionIdLocal = isBrowser ? (0,_utils__WEBPACK_IMPORTED_MODULE_2__.getStoredItem)(_config__WEBPACK_IMPORTED_MODULE_4__.SESSION_ID_PROP_NAME) : null;
|
|
26315
|
+
const sessionStateLocal = isBrowser ? (0,_utils__WEBPACK_IMPORTED_MODULE_2__.getStoredItem)(_config__WEBPACK_IMPORTED_MODULE_4__.SESSION_STATE_PROP_NAME) : null;
|
|
26316
|
+
const sessionTypeLocal = isBrowser ? (0,_utils__WEBPACK_IMPORTED_MODULE_2__.getStoredItem)(_config__WEBPACK_IMPORTED_MODULE_4__.SESSION_TYPE_PROP_NAME) : null;
|
|
26313
26317
|
if ((0,_utils__WEBPACK_IMPORTED_MODULE_2__.isSessionActive)(sessionLocal, sessionTypeLocal)) {
|
|
26314
26318
|
this.session = sessionLocal;
|
|
26315
26319
|
this.sessionId = sessionIdLocal;
|
|
@@ -26332,6 +26336,9 @@ class SessionRecorder extends lib0_observable__WEBPACK_IMPORTED_MODULE_14__.Obse
|
|
|
26332
26336
|
* @param configs - custom configurations for session debugger
|
|
26333
26337
|
*/
|
|
26334
26338
|
init(configs) {
|
|
26339
|
+
if (typeof window === 'undefined') {
|
|
26340
|
+
return;
|
|
26341
|
+
}
|
|
26335
26342
|
this._configs = (0,_config__WEBPACK_IMPORTED_MODULE_4__.getSessionRecorderConfig)({ ...this._configs, ...configs });
|
|
26336
26343
|
this._isInitialized = true;
|
|
26337
26344
|
this._checkOperation('init');
|
|
@@ -27302,13 +27309,13 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
|
|
|
27302
27309
|
this._isStarted = false;
|
|
27303
27310
|
this._isPaused = false;
|
|
27304
27311
|
this._isInitialized = false;
|
|
27305
|
-
this._recorderPlacement = '';
|
|
27306
27312
|
this._error = '';
|
|
27307
|
-
this.
|
|
27313
|
+
this._recorderPlacement = '';
|
|
27308
27314
|
this._finalPopoverVisible = false;
|
|
27309
|
-
this.
|
|
27315
|
+
this._initialPopoverVisible = false;
|
|
27310
27316
|
this._continuousRecording = false;
|
|
27311
27317
|
this._showContinuousRecording = true;
|
|
27318
|
+
this._buttonState = _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.IDLE;
|
|
27312
27319
|
this._widgetTextOverrides = _config__WEBPACK_IMPORTED_MODULE_4__.DEFAULT_WIDGET_TEXT_CONFIG;
|
|
27313
27320
|
this.commentTextarea = null;
|
|
27314
27321
|
this.dragManager = null;
|
|
@@ -27334,21 +27341,6 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
|
|
|
27334
27341
|
}
|
|
27335
27342
|
}
|
|
27336
27343
|
};
|
|
27337
|
-
this.recorderButton = document.createElement('button');
|
|
27338
|
-
this.initialPopover = document.createElement('div');
|
|
27339
|
-
this.finalPopover = document.createElement('div');
|
|
27340
|
-
this.overlay = document.createElement('div');
|
|
27341
|
-
this.toast = document.createElement('div');
|
|
27342
|
-
this.submitSessionDialog = document.createElement('div');
|
|
27343
|
-
this.uiManager = new _UIManager__WEBPACK_IMPORTED_MODULE_5__.UIManager(this.recorderButton, this.initialPopover, this.finalPopover, this.overlay, this.submitSessionDialog, this.toast, _config__WEBPACK_IMPORTED_MODULE_4__.DEFAULT_WIDGET_TEXT_CONFIG, true);
|
|
27344
|
-
this.uiManager.setRecorderButtonProps();
|
|
27345
|
-
this.uiManager.setInitialPopoverProps();
|
|
27346
|
-
this.uiManager.setFinalPopoverProps();
|
|
27347
|
-
this.uiManager.setOverlayProps();
|
|
27348
|
-
this.uiManager.setSubmitSessionDialogProps();
|
|
27349
|
-
this.uiManager.setToastProps();
|
|
27350
|
-
this.commentTextarea = this.finalPopover.querySelector('.mp-session-debugger-popover-textarea');
|
|
27351
|
-
this.observeButtonDraggableMode();
|
|
27352
27344
|
}
|
|
27353
27345
|
updateState(state, continuousRecording) {
|
|
27354
27346
|
this._continuousRecording = continuousRecording;
|
|
@@ -27419,9 +27411,32 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
|
|
|
27419
27411
|
}
|
|
27420
27412
|
});
|
|
27421
27413
|
}
|
|
27414
|
+
initUiManager() {
|
|
27415
|
+
this.recorderButton = document.createElement('button');
|
|
27416
|
+
this.initialPopover = document.createElement('div');
|
|
27417
|
+
this.finalPopover = document.createElement('div');
|
|
27418
|
+
this.overlay = document.createElement('div');
|
|
27419
|
+
this.toast = document.createElement('div');
|
|
27420
|
+
this.submitSessionDialog = document.createElement('div');
|
|
27421
|
+
// Recreate UIManager with proper config
|
|
27422
|
+
this.uiManager = new _UIManager__WEBPACK_IMPORTED_MODULE_5__.UIManager(this.recorderButton, this.initialPopover, this.finalPopover, this.overlay, this.submitSessionDialog, this.toast, this._widgetTextOverrides, this._showContinuousRecording);
|
|
27423
|
+
// Re-initialize templates with new config
|
|
27424
|
+
this.uiManager.setRecorderButtonProps();
|
|
27425
|
+
this.uiManager.setInitialPopoverProps();
|
|
27426
|
+
this.uiManager.setFinalPopoverProps();
|
|
27427
|
+
this.uiManager.setOverlayProps();
|
|
27428
|
+
this.uiManager.setSubmitSessionDialogProps();
|
|
27429
|
+
this.uiManager.setToastProps();
|
|
27430
|
+
this.commentTextarea = this.finalPopover.querySelector('.mp-session-debugger-popover-textarea');
|
|
27431
|
+
this.observeButtonDraggableMode();
|
|
27432
|
+
}
|
|
27422
27433
|
init(options) {
|
|
27423
27434
|
if (this._isInitialized)
|
|
27424
27435
|
return;
|
|
27436
|
+
// Safety guard: avoid DOM access in SSR/non-browser environments
|
|
27437
|
+
if (typeof document === 'undefined') {
|
|
27438
|
+
return;
|
|
27439
|
+
}
|
|
27425
27440
|
this._isInitialized = true;
|
|
27426
27441
|
this.showRecorderButton = options.showWidget;
|
|
27427
27442
|
this._showContinuousRecording = options.showContinuousRecording;
|
|
@@ -27429,15 +27444,7 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
|
|
|
27429
27444
|
...this._widgetTextOverrides,
|
|
27430
27445
|
...options.widgetTextOverrides,
|
|
27431
27446
|
};
|
|
27432
|
-
|
|
27433
|
-
this.uiManager = new _UIManager__WEBPACK_IMPORTED_MODULE_5__.UIManager(this.recorderButton, this.initialPopover, this.finalPopover, this.overlay, this.submitSessionDialog, this.toast, this._widgetTextOverrides, this._showContinuousRecording);
|
|
27434
|
-
// Re-initialize templates with new config
|
|
27435
|
-
this.uiManager.setRecorderButtonProps();
|
|
27436
|
-
this.uiManager.setInitialPopoverProps();
|
|
27437
|
-
this.uiManager.setFinalPopoverProps();
|
|
27438
|
-
this.uiManager.setOverlayProps();
|
|
27439
|
-
this.uiManager.setSubmitSessionDialogProps();
|
|
27440
|
-
this.uiManager.setToastProps();
|
|
27447
|
+
this.initUiManager();
|
|
27441
27448
|
const elements = [this.toast];
|
|
27442
27449
|
if (options.showWidget) {
|
|
27443
27450
|
elements.push(this.recorderButton, this.initialPopover, this.finalPopover, this.submitSessionDialog);
|
|
@@ -28500,20 +28507,30 @@ const isConsoleEvent = (event) => {
|
|
|
28500
28507
|
/**
|
|
28501
28508
|
* LocalStorage utility functions
|
|
28502
28509
|
*/
|
|
28510
|
+
const hasLocalStorage = typeof window !== 'undefined' && !!window.localStorage;
|
|
28503
28511
|
const getStoredItem = (key, parse) => {
|
|
28504
|
-
|
|
28512
|
+
if (!hasLocalStorage) {
|
|
28513
|
+
return parse ? null : null;
|
|
28514
|
+
}
|
|
28515
|
+
const item = window.localStorage.getItem(key);
|
|
28505
28516
|
return parse ? (item ? JSON.parse(item) : null) : item;
|
|
28506
28517
|
};
|
|
28507
28518
|
const setStoredItem = (key, value) => {
|
|
28519
|
+
if (!hasLocalStorage) {
|
|
28520
|
+
return;
|
|
28521
|
+
}
|
|
28508
28522
|
if (value === null || value === undefined) {
|
|
28509
|
-
localStorage
|
|
28523
|
+
window.localStorage.removeItem(key);
|
|
28510
28524
|
}
|
|
28511
28525
|
else {
|
|
28512
|
-
localStorage
|
|
28526
|
+
window.localStorage.setItem(key, typeof value === 'string' ? value : JSON.stringify(value));
|
|
28513
28527
|
}
|
|
28514
28528
|
};
|
|
28515
28529
|
const removeStoredItem = (key) => {
|
|
28516
|
-
|
|
28530
|
+
if (!hasLocalStorage) {
|
|
28531
|
+
return;
|
|
28532
|
+
}
|
|
28533
|
+
window.localStorage.removeItem(key);
|
|
28517
28534
|
};
|
|
28518
28535
|
|
|
28519
28536
|
|
|
@@ -47996,12 +48013,29 @@ var __webpack_exports__ = {};
|
|
|
47996
48013
|
|
|
47997
48014
|
|
|
47998
48015
|
|
|
47999
|
-
|
|
48000
|
-
|
|
48001
|
-
|
|
48002
|
-
|
|
48003
|
-
|
|
48004
|
-
(
|
|
48016
|
+
// Create or reuse a single global instance, but be safe in non-browser environments
|
|
48017
|
+
const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
48018
|
+
// Prefer globalThis when available; fall back to window in browsers
|
|
48019
|
+
const globalObj = typeof globalThis !== 'undefined'
|
|
48020
|
+
? globalThis
|
|
48021
|
+
: (isBrowser ? window : {});
|
|
48022
|
+
let SessionRecorderInstance;
|
|
48023
|
+
if (isBrowser) {
|
|
48024
|
+
// Reuse existing instance if already injected (e.g., by an extension)
|
|
48025
|
+
const existing = globalObj['SessionRecorder'];
|
|
48026
|
+
SessionRecorderInstance = existing !== null && existing !== void 0 ? existing : new _sessionRecorder__WEBPACK_IMPORTED_MODULE_3__.SessionRecorder();
|
|
48027
|
+
// Attach to the global object for reuse across bundles/loads
|
|
48028
|
+
globalObj['SessionRecorder'] = SessionRecorderInstance;
|
|
48029
|
+
globalObj['__SESSION_RECORDER_LOADED'] = true;
|
|
48030
|
+
// Ensure listeners are set up only once
|
|
48031
|
+
if (!globalObj['__SESSION_RECORDER_LISTENERS_SETUP__']) {
|
|
48032
|
+
(0,_listeners__WEBPACK_IMPORTED_MODULE_1__.setupListeners)(SessionRecorderInstance);
|
|
48033
|
+
globalObj['__SESSION_RECORDER_LISTENERS_SETUP__'] = true;
|
|
48034
|
+
}
|
|
48035
|
+
}
|
|
48036
|
+
else {
|
|
48037
|
+
// SSR / non-DOM environments: create an instance but don't touch globals or listeners
|
|
48038
|
+
SessionRecorderInstance = new _sessionRecorder__WEBPACK_IMPORTED_MODULE_3__.SessionRecorder();
|
|
48005
48039
|
}
|
|
48006
48040
|
|
|
48007
48041
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (SessionRecorderInstance);
|