@monoscopetech/browser 0.5.9 → 0.6.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/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 +19 -9
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/replay.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getRecordConsolePlugin } from "@rrweb/rrweb-plugin-console-record";
|
|
2
2
|
import * as rrweb from "rrweb";
|
|
3
3
|
const MAX_EVENT_BATCH = 50;
|
|
4
|
-
const SAVE_INTERVAL =
|
|
5
|
-
const MAX_RETRY_EVENTS =
|
|
4
|
+
const SAVE_INTERVAL = 2000;
|
|
5
|
+
const MAX_RETRY_EVENTS = 5000;
|
|
6
6
|
export class MonoscopeReplay {
|
|
7
7
|
constructor(config, sessionId) {
|
|
8
8
|
this.events = [];
|
|
@@ -91,7 +91,9 @@ export class MonoscopeReplay {
|
|
|
91
91
|
this.save();
|
|
92
92
|
}, SAVE_INTERVAL);
|
|
93
93
|
this.isConfigured = true;
|
|
94
|
-
|
|
94
|
+
if (this.config.debug) {
|
|
95
|
+
console.log("MonoscopeReplay configured successfully");
|
|
96
|
+
}
|
|
95
97
|
}
|
|
96
98
|
catch (error) {
|
|
97
99
|
console.error("Failed to configure MonoscopeReplay:", error);
|
|
@@ -106,7 +108,9 @@ export class MonoscopeReplay {
|
|
|
106
108
|
return;
|
|
107
109
|
}
|
|
108
110
|
if (this.events.length > MAX_RETRY_EVENTS) {
|
|
109
|
-
|
|
111
|
+
if (this.config.debug) {
|
|
112
|
+
console.warn(`Event queue exceeded ${MAX_RETRY_EVENTS}, dropping middle events (preserving snapshots)`);
|
|
113
|
+
}
|
|
110
114
|
// Find full snapshot events (type 2) - these are critical for replay
|
|
111
115
|
const fullSnapshots = this.events.filter((e) => e.type === 2);
|
|
112
116
|
const otherEvents = this.events.filter((e) => e.type !== 2);
|
|
@@ -141,19 +145,23 @@ export class MonoscopeReplay {
|
|
|
141
145
|
}
|
|
142
146
|
}
|
|
143
147
|
else {
|
|
144
|
-
//
|
|
148
|
+
// Use keepalive so the request survives page navigation,
|
|
149
|
+
// but only when payload fits under the 64KB keepalive limit
|
|
150
|
+
const body = JSON.stringify(payload);
|
|
145
151
|
const response = await fetch(baseUrl, {
|
|
146
152
|
method: "POST",
|
|
147
153
|
headers: {
|
|
148
154
|
"Content-Type": "application/json",
|
|
149
155
|
},
|
|
150
|
-
body
|
|
151
|
-
keepalive:
|
|
156
|
+
body,
|
|
157
|
+
keepalive: body.length < 63000,
|
|
152
158
|
});
|
|
153
159
|
if (!response.ok) {
|
|
154
160
|
throw new Error(`Failed to save replay events: ${response.status} ${response.statusText}`);
|
|
155
161
|
}
|
|
156
|
-
|
|
162
|
+
if (this.config.debug) {
|
|
163
|
+
console.log(`Successfully saved ${eventsToSend.length} replay events`);
|
|
164
|
+
}
|
|
157
165
|
}
|
|
158
166
|
}
|
|
159
167
|
catch (error) {
|
|
@@ -186,7 +194,9 @@ export class MonoscopeReplay {
|
|
|
186
194
|
window.removeEventListener("pagehide", this.handleUnload);
|
|
187
195
|
document.removeEventListener("visibilitychange", this.handleVisibilityChange);
|
|
188
196
|
this.isConfigured = false;
|
|
189
|
-
|
|
197
|
+
if (this.config.debug) {
|
|
198
|
+
console.log("MonoscopeReplay stopped");
|
|
199
|
+
}
|
|
190
200
|
}
|
|
191
201
|
getEventCount() {
|
|
192
202
|
return this.events.length;
|
package/dist/types.d.ts
CHANGED