@monoscopetech/browser 0.5.6 → 0.5.8

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/replay.d.ts CHANGED
@@ -13,9 +13,6 @@ export declare class MonoscopeReplay {
13
13
  private handleVisibilityChange;
14
14
  configure(): void;
15
15
  save(forceSynchronous?: boolean): Promise<void>;
16
- /**
17
- * Stop recording and clean up
18
- */
19
16
  stop(): void;
20
17
  getEventCount(): number;
21
18
  getSessionId(): string;
package/dist/replay.js CHANGED
@@ -42,21 +42,13 @@ export class MonoscopeReplay {
42
42
  try {
43
43
  this.stopRecording = rrweb.record({
44
44
  emit: (event) => {
45
- // Don't record if we're in a weird state
46
- if (!event || typeof event !== "object") {
47
- console.warn("Invalid event received:", event);
48
- return;
49
- }
50
45
  this.events.push(event);
51
46
  // Auto-save when batch size reached
52
47
  if (this.events.length >= MAX_EVENT_BATCH) {
53
48
  this.save();
54
49
  }
55
50
  },
56
- // Prevent recording replay UI elements
57
51
  blockClass: "rr-block",
58
- blockSelector: "#replay-container, .replay-ui, [data-rrweb-ignore]",
59
- // Privacy settings
60
52
  maskAllInputs: true,
61
53
  maskInputOptions: {
62
54
  password: true,
@@ -83,7 +75,6 @@ export class MonoscopeReplay {
83
75
  media: 800,
84
76
  input: "last", // Only capture final input value
85
77
  },
86
- // Console plugin
87
78
  plugins: [
88
79
  getRecordConsolePlugin({
89
80
  level: ["info", "log", "warn", "error"],
@@ -96,7 +87,6 @@ export class MonoscopeReplay {
96
87
  }),
97
88
  ],
98
89
  });
99
- // Setup periodic save
100
90
  this.saveInterval = setInterval(() => {
101
91
  this.save();
102
92
  }, SAVE_INTERVAL);
@@ -109,15 +99,12 @@ export class MonoscopeReplay {
109
99
  }
110
100
  }
111
101
  async save(forceSynchronous = false) {
112
- // Prevent concurrent saves
113
102
  if (this.isSaving && !forceSynchronous) {
114
103
  return;
115
104
  }
116
- // Nothing to save
117
105
  if (this.events.length === 0) {
118
106
  return;
119
107
  }
120
- // Prevent event array from growing too large during failed saves
121
108
  if (this.events.length > MAX_RETRY_EVENTS) {
122
109
  console.warn(`Event queue exceeded ${MAX_RETRY_EVENTS}, dropping oldest events`);
123
110
  this.events = this.events.slice(-MAX_RETRY_EVENTS);
@@ -125,7 +112,7 @@ export class MonoscopeReplay {
125
112
  this.isSaving = true;
126
113
  const { replayEventsBaseUrl, projectId } = this.config;
127
114
  // Construct base URL
128
- let baseUrl = replayEventsBaseUrl || "https://app.monoscope.tech";
115
+ let baseUrl = replayEventsBaseUrl || "https://app.apitoolkit.io";
129
116
  baseUrl = `${baseUrl}/rrweb/${projectId}`;
130
117
  // Get events to send and clear buffer
131
118
  const eventsToSend = [...this.events];
@@ -138,7 +125,6 @@ export class MonoscopeReplay {
138
125
  };
139
126
  try {
140
127
  if (forceSynchronous && navigator.sendBeacon) {
141
- // Use sendBeacon for unload events (more reliable)
142
128
  const blob = new Blob([JSON.stringify(payload)], {
143
129
  type: "application/json",
144
130
  });
@@ -155,15 +141,16 @@ export class MonoscopeReplay {
155
141
  "Content-Type": "application/json",
156
142
  },
157
143
  body: JSON.stringify(payload),
158
- keepalive: true, // Important for unload scenarios
159
144
  });
160
145
  if (!response.ok) {
146
+ console.log(response);
161
147
  throw new Error(`Failed to save replay events: ${response.status} ${response.statusText}`);
162
148
  }
163
149
  console.log(`Successfully saved ${eventsToSend.length} replay events`);
164
150
  }
165
151
  }
166
152
  catch (error) {
153
+ console.log(error);
167
154
  console.error("Failed to save replay events:", error);
168
155
  this.events = [...eventsToSend, ...this.events];
169
156
  if (this.events.length > MAX_RETRY_EVENTS) {
@@ -174,9 +161,6 @@ export class MonoscopeReplay {
174
161
  this.isSaving = false;
175
162
  }
176
163
  }
177
- /**
178
- * Stop recording and clean up
179
- */
180
164
  stop() {
181
165
  this.save(true);
182
166
  if (this.stopRecording) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monoscopetech/browser",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",