File tree 1 file changed +7
-7
lines changed
1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change 36
36
() => {
37
37
const BATCH_SIZE = 1000; // Maximum events to store in memory
38
38
39
- window.lmnrRrwebEventsBatch = [] ;
39
+ window.lmnrRrwebEventsBatch = new Set() ;
40
40
41
41
// Utility function to compress individual event data
42
42
async function compressEventData(data) {
50
50
51
51
window.lmnrGetAndClearEvents = () => {
52
52
const events = window.lmnrRrwebEventsBatch;
53
- window.lmnrRrwebEventsBatch = [] ;
54
- return events;
53
+ window.lmnrRrwebEventsBatch = new Set() ;
54
+ return Array.from( events) ;
55
55
};
56
56
57
57
// Add heartbeat events
62
62
timestamp: Date.now()
63
63
};
64
64
65
- window.lmnrRrwebEventsBatch.push (heartbeat);
65
+ window.lmnrRrwebEventsBatch.add (heartbeat);
66
66
67
67
// 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) );
70
70
}
71
71
}, 1000);
72
72
81
81
...event,
82
82
data: await compressEventData(event.data)
83
83
};
84
- window.lmnrRrwebEventsBatch.push (compressedEvent);
84
+ window.lmnrRrwebEventsBatch.add (compressedEvent);
85
85
}
86
86
});
87
87
}
You can’t perform that action at this time.
0 commit comments