@multiplayer-app/session-recorder-browser 1.2.32 → 1.2.33

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.
@@ -9978,7 +9978,7 @@ const DEFAULT_MAX_HTTP_CAPTURING_PAYLOAD_SIZE = 100000;
9978
9978
  const SESSION_RESPONSE = 'multiplayer-debug-session-response';
9979
9979
  const CONTINUOUS_DEBUGGING_TIMEOUT = 60000; // 1 minutes
9980
9980
  const DEBUG_SESSION_MAX_DURATION_SECONDS = 10 * 60 + 30; // TODO: move to shared config otel core
9981
- const PACKAGE_VERSION_EXPORT = "1.2.32" || 0;
9981
+ const PACKAGE_VERSION_EXPORT = "1.2.33" || 0;
9982
9982
  // Regex patterns for OpenTelemetry ignore URLs
9983
9983
  const OTEL_IGNORE_URLS = [
9984
9984
  // Traces endpoint
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.32" || 0;
24146
+ const PACKAGE_VERSION_EXPORT = "1.2.33" || 0;
24147
24147
  // Regex patterns for OpenTelemetry ignore URLs
24148
24148
  const OTEL_IGNORE_URLS = [
24149
24149
  // Traces endpoint
@@ -27230,29 +27230,36 @@ class DragManager {
27230
27230
 
27231
27231
  class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observable {
27232
27232
  set buttonState(newState) {
27233
+ var _a, _b;
27233
27234
  this._buttonState = newState;
27235
+ if (!this.isBrowser)
27236
+ return;
27234
27237
  const { icon, tooltip, classes, excludeClasses } = _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.buttonStates[newState];
27235
27238
  if (newState === _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.CANCEL) {
27236
- this.buttonDraggabilityObserver.observe(this.recorderButton, {
27239
+ (_a = this.buttonDraggabilityObserver) === null || _a === void 0 ? void 0 : _a.observe(this.recorderButton, {
27237
27240
  attributes: true,
27238
27241
  attributeOldValue: true,
27239
27242
  attributeFilter: ['class'],
27240
27243
  });
27241
27244
  }
27242
27245
  else {
27243
- this.buttonDraggabilityObserver.disconnect();
27246
+ (_b = this.buttonDraggabilityObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
27244
27247
  }
27245
27248
  this.updateButton(icon, tooltip, excludeClasses, classes);
27246
27249
  }
27247
27250
  set initialPopoverVisible(v) {
27248
27251
  var _a;
27249
27252
  this._initialPopoverVisible = v;
27250
- (_a = this.initialPopover) === null || _a === void 0 ? void 0 : _a.classList.toggle('hidden', !v);
27253
+ if (this.isBrowser) {
27254
+ (_a = this.initialPopover) === null || _a === void 0 ? void 0 : _a.classList.toggle('hidden', !v);
27255
+ }
27251
27256
  }
27252
27257
  set finalPopoverVisible(v) {
27253
27258
  var _a;
27254
27259
  this._finalPopoverVisible = v;
27255
- (_a = this.finalPopover) === null || _a === void 0 ? void 0 : _a.classList.toggle('hidden', !v);
27260
+ if (this.isBrowser) {
27261
+ (_a = this.finalPopover) === null || _a === void 0 ? void 0 : _a.classList.toggle('hidden', !v);
27262
+ }
27256
27263
  }
27257
27264
  get error() {
27258
27265
  return this._error;
@@ -27271,6 +27278,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27271
27278
  }
27272
27279
  set isStarted(v) {
27273
27280
  this._isStarted = v;
27281
+ if (!this.isBrowser)
27282
+ return;
27274
27283
  if (!this.showRecorderButton && v && !this._continuousRecording) {
27275
27284
  this.overlay.classList.remove('hidden');
27276
27285
  this.makeOverlayDraggable();
@@ -27298,6 +27307,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27298
27307
  }
27299
27308
  set isPaused(v) {
27300
27309
  this._isPaused = v;
27310
+ if (!this.isBrowser)
27311
+ return;
27301
27312
  if (this._isInitialized && !this.showRecorderButton && v && !this._continuousRecording) {
27302
27313
  this.overlay.classList.add('hidden');
27303
27314
  this.submitSessionDialog.classList.remove('hidden');
@@ -27341,6 +27352,18 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27341
27352
  }
27342
27353
  }
27343
27354
  };
27355
+ this.isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
27356
+ if (!this.isBrowser) {
27357
+ // Create dummy elements for SSR to prevent crashes
27358
+ this.recorderButton = {};
27359
+ this.initialPopover = {};
27360
+ this.finalPopover = {};
27361
+ this.overlay = {};
27362
+ this.toast = {};
27363
+ this.submitSessionDialog = {};
27364
+ this.uiManager = {};
27365
+ return;
27366
+ }
27344
27367
  this.recorderButton = document.createElement('button');
27345
27368
  this.initialPopover = document.createElement('div');
27346
27369
  this.finalPopover = document.createElement('div');
@@ -27379,6 +27402,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27379
27402
  }
27380
27403
  }
27381
27404
  updateContinuousRecordingState(checked, disabled = false) {
27405
+ if (!this.isBrowser)
27406
+ return;
27382
27407
  const toggleCheckbox = this.initialPopover.querySelector('#mp-session-debugger-continuous-debugging-checkbox');
27383
27408
  if (toggleCheckbox) {
27384
27409
  toggleCheckbox.checked = checked;
@@ -27386,6 +27411,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27386
27411
  }
27387
27412
  }
27388
27413
  updateSaveContinuousDebugSessionState(state) {
27414
+ if (!this.isBrowser)
27415
+ return;
27389
27416
  const saveButton = this.initialPopover.querySelector('#mp-save-continuous-debug-session');
27390
27417
  if (saveButton) {
27391
27418
  const { textContent, disabled } = _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.continuousRecordingSaveButtonStates[state];
@@ -27399,15 +27426,21 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27399
27426
  * @param duration - Duration in milliseconds to show the toast (default: 10000ms)
27400
27427
  */
27401
27428
  showToast(config, duration = 10000) {
27429
+ if (!this.isBrowser)
27430
+ return;
27402
27431
  this.uiManager.showToast(config, duration);
27403
27432
  }
27404
27433
  /**
27405
27434
  * Hides the currently displayed toast message
27406
27435
  */
27407
27436
  hideToast() {
27437
+ if (!this.isBrowser)
27438
+ return;
27408
27439
  this.uiManager.hideToast();
27409
27440
  }
27410
27441
  observeButtonDraggableMode() {
27442
+ if (!this.isBrowser)
27443
+ return;
27411
27444
  this.buttonDraggabilityObserver = new MutationObserver((mutationsList) => {
27412
27445
  for (const mutation of mutationsList) {
27413
27446
  if (mutation.type === 'attributes' &&
@@ -27429,6 +27462,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27429
27462
  init(options) {
27430
27463
  if (this._isInitialized)
27431
27464
  return;
27465
+ if (!this.isBrowser)
27466
+ return;
27432
27467
  this._isInitialized = true;
27433
27468
  this.showRecorderButton = options.showWidget;
27434
27469
  this._showContinuousRecording = options.showContinuousRecording;
@@ -27468,6 +27503,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27468
27503
  this.addEventListeners();
27469
27504
  }
27470
27505
  appendElements(elements) {
27506
+ if (!this.isBrowser || typeof document === 'undefined')
27507
+ return;
27471
27508
  const rootWrapper = document.createElement('mp-root');
27472
27509
  rootWrapper.classList.add('mp-root-wrapper');
27473
27510
  rootWrapper.setAttribute('data-rr-ignore', 'true');
@@ -27475,6 +27512,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27475
27512
  document.body.appendChild(rootWrapper);
27476
27513
  }
27477
27514
  addRecorderDragFunctionality() {
27515
+ if (!this.isBrowser)
27516
+ return;
27478
27517
  this.dragManager = new _dragManager__WEBPACK_IMPORTED_MODULE_2__.DragManager(this.recorderButton, this._recorderPlacement, () => {
27479
27518
  if (this._isPaused) {
27480
27519
  this.finalPopoverVisible = true;
@@ -27483,6 +27522,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27483
27522
  this.dragManager.init();
27484
27523
  }
27485
27524
  updatePopoverPosition() {
27525
+ if (!this.isBrowser || typeof window === 'undefined')
27526
+ return;
27486
27527
  const { top, right, bottom, left } = this.recorderButton.getBoundingClientRect();
27487
27528
  const isDraggable = !this.recorderButton.classList.contains('no-draggable');
27488
27529
  const POPOVER_HEIGHT = this._isStarted ? 400 : 300;
@@ -27519,6 +27560,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27519
27560
  });
27520
27561
  }
27521
27562
  addEventListeners() {
27563
+ if (!this.isBrowser)
27564
+ return;
27522
27565
  const events = [];
27523
27566
  if (this.showRecorderButton) {
27524
27567
  events.push({
@@ -27576,14 +27619,20 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27576
27619
  });
27577
27620
  }
27578
27621
  handleStopRecording() {
27622
+ if (!this.isBrowser)
27623
+ return;
27579
27624
  this.onStop();
27580
27625
  this.handleUIReseting();
27581
27626
  }
27582
27627
  handleUIReseting() {
27628
+ if (!this.isBrowser)
27629
+ return;
27583
27630
  this.finalPopoverVisible = false;
27584
27631
  this.resetRecordingButton();
27585
27632
  }
27586
27633
  handleCloseInitialPopover() {
27634
+ if (!this.isBrowser)
27635
+ return;
27587
27636
  if (this._buttonState === _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.LOADING) {
27588
27637
  this.onCancel();
27589
27638
  this.uiManager.setPopoverLoadingState(false);
@@ -27592,18 +27641,26 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27592
27641
  this.buttonState = this._continuousRecording
27593
27642
  ? _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.CONTINUOUS_DEBUGGING
27594
27643
  : _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.IDLE;
27595
- document.removeEventListener('click', this.handleClickOutside);
27644
+ if (typeof document !== 'undefined') {
27645
+ document.removeEventListener('click', this.handleClickOutside);
27646
+ }
27596
27647
  }
27597
27648
  handleCloseFinalPopover() {
27598
27649
  this.onResume();
27599
27650
  }
27600
27651
  onRequestError() {
27652
+ if (!this.isBrowser)
27653
+ return;
27601
27654
  this.initialPopoverVisible = false;
27602
27655
  this.finalPopoverVisible = false;
27603
27656
  this.buttonState = _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.IDLE;
27604
- document.removeEventListener('click', this.handleClickOutside);
27657
+ if (typeof document !== 'undefined') {
27658
+ document.removeEventListener('click', this.handleClickOutside);
27659
+ }
27605
27660
  }
27606
27661
  handleDismissRecording() {
27662
+ if (!this.isBrowser)
27663
+ return;
27607
27664
  this.onCancel();
27608
27665
  this.finalPopoverVisible = !this._finalPopoverVisible;
27609
27666
  this.buttonState = _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.IDLE;
@@ -27622,6 +27679,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27622
27679
  (_a = element === null || element === void 0 ? void 0 : element.querySelector(selector)) === null || _a === void 0 ? void 0 : _a.addEventListener(event, handler);
27623
27680
  }
27624
27681
  onRecordingButtonClick(e) {
27682
+ if (!this.isBrowser)
27683
+ return;
27625
27684
  if (this.buttonClickExternalHandler) {
27626
27685
  const shouldPropagate = this.buttonClickExternalHandler();
27627
27686
  if (shouldPropagate === false) {
@@ -27653,15 +27712,17 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27653
27712
  : _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.CANCEL;
27654
27713
  this.initialPopoverVisible = !this._initialPopoverVisible;
27655
27714
  }
27656
- if (this._initialPopoverVisible || this._finalPopoverVisible) {
27657
- document.addEventListener('click', this.handleClickOutside);
27658
- }
27659
- else {
27660
- document.removeEventListener('click', this.handleClickOutside);
27715
+ if (typeof document !== 'undefined') {
27716
+ if (this._initialPopoverVisible || this._finalPopoverVisible) {
27717
+ document.addEventListener('click', this.handleClickOutside);
27718
+ }
27719
+ else {
27720
+ document.removeEventListener('click', this.handleClickOutside);
27721
+ }
27661
27722
  }
27662
27723
  }
27663
27724
  updateButton(innerHTML, tooltip, excludeClasses, classes) {
27664
- if (!this.recorderButton)
27725
+ if (!this.isBrowser || !this.recorderButton)
27665
27726
  return;
27666
27727
  (0,_utils__WEBPACK_IMPORTED_MODULE_0__.insertTrustedHTML)(this.recorderButton, `${innerHTML}`);
27667
27728
  this.recorderButton.dataset['tooltip'] = tooltip;
@@ -27692,6 +27753,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27692
27753
  this.emit('toggle', [true]);
27693
27754
  }
27694
27755
  onStop() {
27756
+ if (!this.isBrowser)
27757
+ return;
27695
27758
  if (this.showRecorderButton && !this.recorderButton)
27696
27759
  return;
27697
27760
  this.submitSessionDialog.classList.add('hidden');
@@ -27709,6 +27772,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27709
27772
  this.emit('pause', []);
27710
27773
  }
27711
27774
  onResume() {
27775
+ if (!this.isBrowser)
27776
+ return;
27712
27777
  this.finalPopoverVisible = false;
27713
27778
  if (!this._continuousRecording) {
27714
27779
  this.buttonState = _buttonStateConfigs__WEBPACK_IMPORTED_MODULE_6__.ButtonState.RECORDING;
@@ -27719,28 +27784,35 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27719
27784
  }
27720
27785
  }
27721
27786
  onCancel() {
27787
+ if (!this.isBrowser)
27788
+ return;
27722
27789
  this.submitSessionDialog.classList.add('hidden');
27723
27790
  this.emit('cancel', []);
27724
27791
  }
27725
27792
  enable() {
27726
- if (!this.recorderButton)
27793
+ if (!this.isBrowser || !this.recorderButton)
27727
27794
  return;
27728
27795
  this.recorderButton.disabled = false;
27729
27796
  this.recorderButton.style.opacity = '1';
27730
27797
  }
27731
27798
  disable() {
27732
- if (!this.recorderButton)
27799
+ if (!this.isBrowser || !this.recorderButton)
27733
27800
  return;
27734
27801
  this.recorderButton.disabled = true;
27735
27802
  this.recorderButton.style.opacity = '0.5';
27736
27803
  }
27737
27804
  destroy() {
27738
- if (!this.recorderButton)
27805
+ if (!this.isBrowser || !this.recorderButton || typeof document === 'undefined')
27739
27806
  return;
27740
- document.body.removeChild(this.recorderButton);
27807
+ const rootWrapper = document.querySelector('.mp-root-wrapper');
27808
+ if (rootWrapper && rootWrapper.contains(this.recorderButton)) {
27809
+ document.body.removeChild(rootWrapper);
27810
+ }
27741
27811
  document.removeEventListener('click', this.handleClickOutside);
27742
27812
  }
27743
27813
  startTimer() {
27814
+ if (!this.isBrowser)
27815
+ return;
27744
27816
  if (this.timerInterval) {
27745
27817
  clearInterval(this.timerInterval);
27746
27818
  this.timerInterval = null;
@@ -27759,6 +27831,8 @@ class SessionWidget extends lib0_observable__WEBPACK_IMPORTED_MODULE_7__.Observa
27759
27831
  }
27760
27832
  }
27761
27833
  makeOverlayDraggable() {
27834
+ if (!this.isBrowser || typeof document === 'undefined')
27835
+ return;
27762
27836
  const element = this.overlay;
27763
27837
  const dragHandle = element.querySelector('.mp-drag-handle');
27764
27838
  if (!dragHandle)