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.
|
@@ -20675,7 +20675,7 @@
|
|
|
20675
20675
|
return "ok";
|
|
20676
20676
|
};
|
|
20677
20677
|
|
|
20678
|
-
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;
|
|
20678
|
+
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;
|
|
20679
20679
|
class SessionRecorder {
|
|
20680
20680
|
constructor(config) {
|
|
20681
20681
|
var _a, _b, _c;
|
|
@@ -20685,18 +20685,45 @@
|
|
|
20685
20685
|
this.debug = false;
|
|
20686
20686
|
_SessionRecorder_trackEventsThrottled.set(this, void 0);
|
|
20687
20687
|
_SessionRecorder_uploading.set(this, false);
|
|
20688
|
+
_SessionRecorder_uploadingMaxTs.set(this, 0);
|
|
20688
20689
|
_SessionRecorder_handlePageHide.set(this, () => {
|
|
20689
20690
|
try {
|
|
20690
20691
|
if (this.sessionEvents.length === 0)
|
|
20691
20692
|
return;
|
|
20692
|
-
|
|
20693
|
+
let toUpload;
|
|
20694
|
+
if (__classPrivateFieldGet(this, _SessionRecorder_uploading, "f") && __classPrivateFieldGet(this, _SessionRecorder_uploadingMaxTs, "f") > 0) {
|
|
20695
|
+
toUpload = this.sessionEvents.filter((e) => e.timestamp > __classPrivateFieldGet(this, _SessionRecorder_uploadingMaxTs, "f"));
|
|
20696
|
+
}
|
|
20697
|
+
else {
|
|
20698
|
+
toUpload = [...this.sessionEvents];
|
|
20699
|
+
}
|
|
20700
|
+
if (toUpload.length === 0)
|
|
20701
|
+
return;
|
|
20702
|
+
let events;
|
|
20703
|
+
if (toUpload[0].type !== 4) {
|
|
20704
|
+
let snapshotPair = [];
|
|
20705
|
+
for (let i = this.sessionEvents.length - 2; i >= 0; i--) {
|
|
20706
|
+
if (this.sessionEvents[i].type === 4 &&
|
|
20707
|
+
this.sessionEvents[i + 1].type === 2) {
|
|
20708
|
+
snapshotPair = [
|
|
20709
|
+
this.sessionEvents[i],
|
|
20710
|
+
this.sessionEvents[i + 1],
|
|
20711
|
+
];
|
|
20712
|
+
break;
|
|
20713
|
+
}
|
|
20714
|
+
}
|
|
20715
|
+
events = [...snapshotPair, ...toUpload];
|
|
20716
|
+
}
|
|
20717
|
+
else {
|
|
20718
|
+
events = toUpload;
|
|
20719
|
+
}
|
|
20693
20720
|
const state = readSessionState();
|
|
20694
20721
|
if (!state)
|
|
20695
20722
|
return;
|
|
20696
20723
|
const chunk_seq = __classPrivateFieldGet(this, _SessionRecorder_uploading, "f") ? state.chunk_seq + 1 : state.chunk_seq;
|
|
20697
20724
|
writeSessionState({ ...state, chunk_seq: chunk_seq + 1 });
|
|
20698
|
-
const start_ts_ms =
|
|
20699
|
-
const end_ts_ms =
|
|
20725
|
+
const start_ts_ms = toUpload[0].timestamp;
|
|
20726
|
+
const end_ts_ms = toUpload[toUpload.length - 1].timestamp;
|
|
20700
20727
|
uploadSessionEvents({
|
|
20701
20728
|
user_id: this.userId,
|
|
20702
20729
|
session_uuid: this.sessionUuid,
|
|
@@ -20775,7 +20802,7 @@
|
|
|
20775
20802
|
}
|
|
20776
20803
|
}
|
|
20777
20804
|
}
|
|
20778
|
-
_SessionRecorder_trackEventsThrottled = new WeakMap(), _SessionRecorder_uploading = new WeakMap(), _SessionRecorder_handlePageHide = new WeakMap(), _SessionRecorder_instances = new WeakSet(), _SessionRecorder_log = function _SessionRecorder_log(message, error) {
|
|
20805
|
+
_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) {
|
|
20779
20806
|
if (!this.debug)
|
|
20780
20807
|
return;
|
|
20781
20808
|
if (error) {
|
|
@@ -20798,7 +20825,6 @@
|
|
|
20798
20825
|
},
|
|
20799
20826
|
recordCrossOriginIframes: this.recordCrossOriginIframes,
|
|
20800
20827
|
plugins: [getRecordConsolePlugin()],
|
|
20801
|
-
checkoutEveryNth: 100,
|
|
20802
20828
|
});
|
|
20803
20829
|
__classPrivateFieldGet(this, _SessionRecorder_instances, "m", _SessionRecorder_initListeners).call(this);
|
|
20804
20830
|
}, _SessionRecorder_isUserInteraction = function _SessionRecorder_isUserInteraction(event) {
|
|
@@ -20873,6 +20899,7 @@
|
|
|
20873
20899
|
try {
|
|
20874
20900
|
const events = [...this.sessionEvents];
|
|
20875
20901
|
const snapshot_count = events.length;
|
|
20902
|
+
__classPrivateFieldSet(this, _SessionRecorder_uploadingMaxTs, events[events.length - 1].timestamp, "f");
|
|
20876
20903
|
const start_ts_ms = events[0].timestamp;
|
|
20877
20904
|
const end_ts_ms = events[events.length - 1].timestamp;
|
|
20878
20905
|
const state = readSessionState();
|
|
@@ -20890,10 +20917,22 @@
|
|
|
20890
20917
|
initial_url: chunk_seq === 0 ? state.initial_url : undefined,
|
|
20891
20918
|
events,
|
|
20892
20919
|
});
|
|
20893
|
-
|
|
20920
|
+
const remaining = this.sessionEvents.slice(snapshot_count);
|
|
20921
|
+
this.sessionEvents = [];
|
|
20922
|
+
try {
|
|
20923
|
+
takeFullSnapshot(true);
|
|
20924
|
+
}
|
|
20925
|
+
catch (err) {
|
|
20926
|
+
__classPrivateFieldGet(this, _SessionRecorder_instances, "m", _SessionRecorder_log).call(this, "takeFullSnapshot failed", err);
|
|
20927
|
+
}
|
|
20928
|
+
if (remaining.length > 0) {
|
|
20929
|
+
this.sessionEvents.push(...remaining);
|
|
20930
|
+
}
|
|
20894
20931
|
const after = readSessionState();
|
|
20895
|
-
if (after &&
|
|
20896
|
-
|
|
20932
|
+
if (after &&
|
|
20933
|
+
after.session_uuid === state.session_uuid &&
|
|
20934
|
+
after.chunk_seq === chunk_seq) {
|
|
20935
|
+
writeSessionState({ ...after, chunk_seq: chunk_seq + 1 });
|
|
20897
20936
|
}
|
|
20898
20937
|
}
|
|
20899
20938
|
catch (err) {
|
|
@@ -20901,6 +20940,7 @@
|
|
|
20901
20940
|
}
|
|
20902
20941
|
finally {
|
|
20903
20942
|
__classPrivateFieldSet(this, _SessionRecorder_uploading, false, "f");
|
|
20943
|
+
__classPrivateFieldSet(this, _SessionRecorder_uploadingMaxTs, 0, "f");
|
|
20904
20944
|
}
|
|
20905
20945
|
}, _SessionRecorder_clearEvents = function _SessionRecorder_clearEvents() {
|
|
20906
20946
|
this.sessionEvents = [];
|