userlens-session-recorder 2.2.0 → 2.2.1

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/index.esm.js CHANGED
@@ -20855,7 +20855,7 @@ _SessionManager_instances = new WeakSet(), _SessionManager_initWindow = function
20855
20855
  writeWindowState({ window_id: this._windowId, chunk_seq: 0 });
20856
20856
  };
20857
20857
 
20858
- var _SessionRecorder_instances, _SessionRecorder_uploading, _SessionRecorder_uploadingMaxTs, _SessionRecorder_bufferTimer, _SessionRecorder_log, _SessionRecorder_initRecorder, _SessionRecorder_isUserInteraction, _SessionRecorder_handleEvent, _SessionRecorder_armBufferTimer, _SessionRecorder_flushBuffer, _SessionRecorder_handlePageHide, _SessionRecorder_handleVisibilityChange, _SessionRecorder_initListeners, _SessionRecorder_trackEvents, _SessionRecorder_clearEvents;
20858
+ var _SessionRecorder_instances, _SessionRecorder_uploading, _SessionRecorder_uploadingMaxTs, _SessionRecorder_bufferTimer, _SessionRecorder_log, _SessionRecorder_initRecorder, _SessionRecorder_isUserInteraction, _SessionRecorder_isVisibilityMarker, _SessionRecorder_handleEvent, _SessionRecorder_armBufferTimer, _SessionRecorder_flushBuffer, _SessionRecorder_handlePageHide, _SessionRecorder_handleVisibilityChange, _SessionRecorder_initListeners, _SessionRecorder_trackEvents, _SessionRecorder_clearEvents;
20859
20859
  const BUFFER_TIMEOUT_MS = 2000;
20860
20860
  const MAX_BUFFER_BYTES = 900 * 1024;
20861
20861
  function estimateEventSize(event) {
@@ -21052,16 +21052,32 @@ _SessionRecorder_uploading = new WeakMap(), _SessionRecorder_uploadingMaxTs = ne
21052
21052
  return source === 2 || source === 5 || source === 6;
21053
21053
  }
21054
21054
  return false;
21055
+ }, _SessionRecorder_isVisibilityMarker = function _SessionRecorder_isVisibilityMarker(event) {
21056
+ var _a;
21057
+ if (event.type !== 5)
21058
+ return false;
21059
+ const tag = (_a = event.data) === null || _a === void 0 ? void 0 : _a.tag;
21060
+ return tag === "window visible" || tag === "window hidden";
21055
21061
  }, _SessionRecorder_handleEvent = function _SessionRecorder_handleEvent(event, _isCheckout) {
21056
21062
  try {
21057
21063
  const now = Date.now();
21058
21064
  const change = this.sessionManager.syncWithSharedState(now);
21065
+ // A rotated session starts mid-page: no recorder construction and no
21066
+ // visibilitychange fires, so without the marker emit below the new
21067
+ // session has no visibility marker and the player can't attribute
21068
+ // windows. Skip it when the triggering event IS a visibility marker
21069
+ // (refocus after idle) — that event lands right after the snapshot
21070
+ // anyway, and emitting another would double it.
21059
21071
  if (change === "expired") {
21060
21072
  __classPrivateFieldGet(this, _SessionRecorder_instances, "m", _SessionRecorder_clearEvents).call(this);
21061
21073
  takeFullSnapshot(true);
21074
+ if (!__classPrivateFieldGet(this, _SessionRecorder_instances, "m", _SessionRecorder_isVisibilityMarker).call(this, event))
21075
+ __classPrivateFieldGet(this, _SessionRecorder_handleVisibilityChange, "f").call(this);
21062
21076
  }
21063
21077
  else if (change === "rotated") {
21064
21078
  takeFullSnapshot(true);
21079
+ if (!__classPrivateFieldGet(this, _SessionRecorder_instances, "m", _SessionRecorder_isVisibilityMarker).call(this, event))
21080
+ __classPrivateFieldGet(this, _SessionRecorder_handleVisibilityChange, "f").call(this);
21065
21081
  }
21066
21082
  if (__classPrivateFieldGet(this, _SessionRecorder_instances, "m", _SessionRecorder_isUserInteraction).call(this, event)) {
21067
21083
  this.sessionManager.bumpActivity(now);