@monoscopetech/browser 0.5.7 → 0.5.9
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/monoscope.min.js +1 -1
- package/dist/monoscope.min.js.map +1 -1
- package/dist/monoscope.umd.js +1 -1
- package/dist/monoscope.umd.js.map +1 -1
- package/dist/replay.js +15 -3
- package/package.json +1 -1
package/dist/replay.js
CHANGED
|
@@ -106,8 +106,15 @@ export class MonoscopeReplay {
|
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
108
108
|
if (this.events.length > MAX_RETRY_EVENTS) {
|
|
109
|
-
console.warn(`Event queue exceeded ${MAX_RETRY_EVENTS}, dropping
|
|
110
|
-
|
|
109
|
+
console.warn(`Event queue exceeded ${MAX_RETRY_EVENTS}, dropping middle events (preserving snapshots)`);
|
|
110
|
+
// Find full snapshot events (type 2) - these are critical for replay
|
|
111
|
+
const fullSnapshots = this.events.filter((e) => e.type === 2);
|
|
112
|
+
const otherEvents = this.events.filter((e) => e.type !== 2);
|
|
113
|
+
// Keep all snapshots and the most recent other events
|
|
114
|
+
const remainingSlots = MAX_RETRY_EVENTS - fullSnapshots.length;
|
|
115
|
+
this.events = [...fullSnapshots, ...otherEvents.slice(-remainingSlots)];
|
|
116
|
+
// Re-sort by timestamp to maintain order
|
|
117
|
+
this.events.sort((a, b) => a.timestamp - b.timestamp);
|
|
111
118
|
}
|
|
112
119
|
this.isSaving = true;
|
|
113
120
|
const { replayEventsBaseUrl, projectId } = this.config;
|
|
@@ -153,7 +160,12 @@ export class MonoscopeReplay {
|
|
|
153
160
|
console.error("Failed to save replay events:", error);
|
|
154
161
|
this.events = [...eventsToSend, ...this.events];
|
|
155
162
|
if (this.events.length > MAX_RETRY_EVENTS) {
|
|
156
|
-
|
|
163
|
+
// Preserve full snapshots when trimming
|
|
164
|
+
const fullSnapshots = this.events.filter((e) => e.type === 2);
|
|
165
|
+
const otherEvents = this.events.filter((e) => e.type !== 2);
|
|
166
|
+
const remainingSlots = MAX_RETRY_EVENTS - fullSnapshots.length;
|
|
167
|
+
this.events = [...fullSnapshots, ...otherEvents.slice(-remainingSlots)];
|
|
168
|
+
this.events.sort((a, b) => a.timestamp - b.timestamp);
|
|
157
169
|
}
|
|
158
170
|
}
|
|
159
171
|
finally {
|