userlens-session-recorder 2.0.0 → 2.0.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
|
@@ -20669,7 +20669,7 @@ const uploadSessionEvents = async (args) => {
|
|
|
20669
20669
|
return "ok";
|
|
20670
20670
|
};
|
|
20671
20671
|
|
|
20672
|
-
var _SessionRecorder_instances, _SessionRecorder_trackEventsThrottled, _SessionRecorder_uploading, _SessionRecorder_log, _SessionRecorder_initRecorder, _SessionRecorder_isUserInteraction, _SessionRecorder_handleEvent, _SessionRecorder_resetSession, _SessionRecorder_createSession, _SessionRecorder_handlePageHide, _SessionRecorder_initListeners, _SessionRecorder_throttle, _SessionRecorder_trackEvents, _SessionRecorder_clearEvents;
|
|
20672
|
+
var _SessionRecorder_instances, _SessionRecorder_trackEventsThrottled, _SessionRecorder_uploading, _SessionRecorder_uploadingMaxTs, _SessionRecorder_log, _SessionRecorder_initRecorder, _SessionRecorder_isUserInteraction, _SessionRecorder_handleEvent, _SessionRecorder_resetSession, _SessionRecorder_createSession, _SessionRecorder_handlePageHide, _SessionRecorder_initListeners, _SessionRecorder_throttle, _SessionRecorder_trackEvents, _SessionRecorder_clearEvents;
|
|
20673
20673
|
class SessionRecorder {
|
|
20674
20674
|
constructor(config) {
|
|
20675
20675
|
var _a, _b, _c;
|
|
@@ -20679,18 +20679,45 @@ class SessionRecorder {
|
|
|
20679
20679
|
this.debug = false;
|
|
20680
20680
|
_SessionRecorder_trackEventsThrottled.set(this, void 0);
|
|
20681
20681
|
_SessionRecorder_uploading.set(this, false);
|
|
20682
|
+
_SessionRecorder_uploadingMaxTs.set(this, 0);
|
|
20682
20683
|
_SessionRecorder_handlePageHide.set(this, () => {
|
|
20683
20684
|
try {
|
|
20684
20685
|
if (this.sessionEvents.length === 0)
|
|
20685
20686
|
return;
|
|
20686
|
-
|
|
20687
|
+
let toUpload;
|
|
20688
|
+
if (__classPrivateFieldGet(this, _SessionRecorder_uploading, "f") && __classPrivateFieldGet(this, _SessionRecorder_uploadingMaxTs, "f") > 0) {
|
|
20689
|
+
toUpload = this.sessionEvents.filter((e) => e.timestamp > __classPrivateFieldGet(this, _SessionRecorder_uploadingMaxTs, "f"));
|
|
20690
|
+
}
|
|
20691
|
+
else {
|
|
20692
|
+
toUpload = [...this.sessionEvents];
|
|
20693
|
+
}
|
|
20694
|
+
if (toUpload.length === 0)
|
|
20695
|
+
return;
|
|
20696
|
+
let events;
|
|
20697
|
+
if (toUpload[0].type !== 4) {
|
|
20698
|
+
let snapshotPair = [];
|
|
20699
|
+
for (let i = this.sessionEvents.length - 2; i >= 0; i--) {
|
|
20700
|
+
if (this.sessionEvents[i].type === 4 &&
|
|
20701
|
+
this.sessionEvents[i + 1].type === 2) {
|
|
20702
|
+
snapshotPair = [
|
|
20703
|
+
this.sessionEvents[i],
|
|
20704
|
+
this.sessionEvents[i + 1],
|
|
20705
|
+
];
|
|
20706
|
+
break;
|
|
20707
|
+
}
|
|
20708
|
+
}
|
|
20709
|
+
events = [...snapshotPair, ...toUpload];
|
|
20710
|
+
}
|
|
20711
|
+
else {
|
|
20712
|
+
events = toUpload;
|
|
20713
|
+
}
|
|
20687
20714
|
const state = readSessionState();
|
|
20688
20715
|
if (!state)
|
|
20689
20716
|
return;
|
|
20690
20717
|
const chunk_seq = __classPrivateFieldGet(this, _SessionRecorder_uploading, "f") ? state.chunk_seq + 1 : state.chunk_seq;
|
|
20691
20718
|
writeSessionState({ ...state, chunk_seq: chunk_seq + 1 });
|
|
20692
|
-
const start_ts_ms =
|
|
20693
|
-
const end_ts_ms =
|
|
20719
|
+
const start_ts_ms = toUpload[0].timestamp;
|
|
20720
|
+
const end_ts_ms = toUpload[toUpload.length - 1].timestamp;
|
|
20694
20721
|
uploadSessionEvents({
|
|
20695
20722
|
user_id: this.userId,
|
|
20696
20723
|
session_uuid: this.sessionUuid,
|
|
@@ -20769,7 +20796,7 @@ class SessionRecorder {
|
|
|
20769
20796
|
}
|
|
20770
20797
|
}
|
|
20771
20798
|
}
|
|
20772
|
-
_SessionRecorder_trackEventsThrottled = new WeakMap(), _SessionRecorder_uploading = new WeakMap(), _SessionRecorder_handlePageHide = new WeakMap(), _SessionRecorder_instances = new WeakSet(), _SessionRecorder_log = function _SessionRecorder_log(message, error) {
|
|
20799
|
+
_SessionRecorder_trackEventsThrottled = new WeakMap(), _SessionRecorder_uploading = new WeakMap(), _SessionRecorder_uploadingMaxTs = new WeakMap(), _SessionRecorder_handlePageHide = new WeakMap(), _SessionRecorder_instances = new WeakSet(), _SessionRecorder_log = function _SessionRecorder_log(message, error) {
|
|
20773
20800
|
if (!this.debug)
|
|
20774
20801
|
return;
|
|
20775
20802
|
if (error) {
|
|
@@ -20792,7 +20819,6 @@ _SessionRecorder_trackEventsThrottled = new WeakMap(), _SessionRecorder_uploadin
|
|
|
20792
20819
|
},
|
|
20793
20820
|
recordCrossOriginIframes: this.recordCrossOriginIframes,
|
|
20794
20821
|
plugins: [getRecordConsolePlugin()],
|
|
20795
|
-
checkoutEveryNth: 100,
|
|
20796
20822
|
});
|
|
20797
20823
|
__classPrivateFieldGet(this, _SessionRecorder_instances, "m", _SessionRecorder_initListeners).call(this);
|
|
20798
20824
|
}, _SessionRecorder_isUserInteraction = function _SessionRecorder_isUserInteraction(event) {
|
|
@@ -20867,6 +20893,7 @@ _SessionRecorder_trackEventsThrottled = new WeakMap(), _SessionRecorder_uploadin
|
|
|
20867
20893
|
try {
|
|
20868
20894
|
const events = [...this.sessionEvents];
|
|
20869
20895
|
const snapshot_count = events.length;
|
|
20896
|
+
__classPrivateFieldSet(this, _SessionRecorder_uploadingMaxTs, events[events.length - 1].timestamp, "f");
|
|
20870
20897
|
const start_ts_ms = events[0].timestamp;
|
|
20871
20898
|
const end_ts_ms = events[events.length - 1].timestamp;
|
|
20872
20899
|
const state = readSessionState();
|
|
@@ -20884,10 +20911,22 @@ _SessionRecorder_trackEventsThrottled = new WeakMap(), _SessionRecorder_uploadin
|
|
|
20884
20911
|
initial_url: chunk_seq === 0 ? state.initial_url : undefined,
|
|
20885
20912
|
events,
|
|
20886
20913
|
});
|
|
20887
|
-
|
|
20914
|
+
const remaining = this.sessionEvents.slice(snapshot_count);
|
|
20915
|
+
this.sessionEvents = [];
|
|
20916
|
+
try {
|
|
20917
|
+
takeFullSnapshot(true);
|
|
20918
|
+
}
|
|
20919
|
+
catch (err) {
|
|
20920
|
+
__classPrivateFieldGet(this, _SessionRecorder_instances, "m", _SessionRecorder_log).call(this, "takeFullSnapshot failed", err);
|
|
20921
|
+
}
|
|
20922
|
+
if (remaining.length > 0) {
|
|
20923
|
+
this.sessionEvents.push(...remaining);
|
|
20924
|
+
}
|
|
20888
20925
|
const after = readSessionState();
|
|
20889
|
-
if (after &&
|
|
20890
|
-
|
|
20926
|
+
if (after &&
|
|
20927
|
+
after.session_uuid === state.session_uuid &&
|
|
20928
|
+
after.chunk_seq === chunk_seq) {
|
|
20929
|
+
writeSessionState({ ...after, chunk_seq: chunk_seq + 1 });
|
|
20891
20930
|
}
|
|
20892
20931
|
}
|
|
20893
20932
|
catch (err) {
|
|
@@ -20895,6 +20934,7 @@ _SessionRecorder_trackEventsThrottled = new WeakMap(), _SessionRecorder_uploadin
|
|
|
20895
20934
|
}
|
|
20896
20935
|
finally {
|
|
20897
20936
|
__classPrivateFieldSet(this, _SessionRecorder_uploading, false, "f");
|
|
20937
|
+
__classPrivateFieldSet(this, _SessionRecorder_uploadingMaxTs, 0, "f");
|
|
20898
20938
|
}
|
|
20899
20939
|
}, _SessionRecorder_clearEvents = function _SessionRecorder_clearEvents() {
|
|
20900
20940
|
this.sessionEvents = [];
|