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