Skip to content

Commit 5b4e5b9

Browse files
committed
quick fix: keep events as set, not array
1 parent e12ffee commit 5b4e5b9

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/lmnr/sdk/browser/pw_utils.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
() => {
3737
const BATCH_SIZE = 1000; // Maximum events to store in memory
3838
39-
window.lmnrRrwebEventsBatch = [];
39+
window.lmnrRrwebEventsBatch = new Set();
4040
4141
// Utility function to compress individual event data
4242
async function compressEventData(data) {
@@ -50,8 +50,8 @@
5050
5151
window.lmnrGetAndClearEvents = () => {
5252
const events = window.lmnrRrwebEventsBatch;
53-
window.lmnrRrwebEventsBatch = [];
54-
return events;
53+
window.lmnrRrwebEventsBatch = new Set();
54+
return Array.from(events);
5555
};
5656
5757
// Add heartbeat events
@@ -62,11 +62,11 @@
6262
timestamp: Date.now()
6363
};
6464
65-
window.lmnrRrwebEventsBatch.push(heartbeat);
65+
window.lmnrRrwebEventsBatch.add(heartbeat);
6666
6767
// Prevent memory issues by limiting batch size
68-
if (window.lmnrRrwebEventsBatch.length > BATCH_SIZE) {
69-
window.lmnrRrwebEventsBatch = window.lmnrRrwebEventsBatch.slice(-BATCH_SIZE);
68+
if (window.lmnrRrwebEventsBatch.size > BATCH_SIZE) {
69+
window.lmnrRrwebEventsBatch = new Set(Array.from(window.lmnrRrwebEventsBatch).slice(-BATCH_SIZE));
7070
}
7171
}, 1000);
7272
@@ -81,7 +81,7 @@
8181
...event,
8282
data: await compressEventData(event.data)
8383
};
84-
window.lmnrRrwebEventsBatch.push(compressedEvent);
84+
window.lmnrRrwebEventsBatch.add(compressedEvent);
8585
}
8686
});
8787
}

0 commit comments

Comments
 (0)