@zaplier/sdk 1.3.3 → 1.3.4
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/index.cjs +66 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +66 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/sdk.js +66 -8
- package/dist/sdk.js.map +1 -1
- package/dist/sdk.min.js +1 -1
- package/dist/src/modules/session-replay.d.ts +2 -0
- package/dist/src/modules/session-replay.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/sdk.js
CHANGED
|
@@ -19022,6 +19022,7 @@
|
|
|
19022
19022
|
this.events = [];
|
|
19023
19023
|
this.isActive = false;
|
|
19024
19024
|
this.hasFullSnapshot = false;
|
|
19025
|
+
this.startTime = 0;
|
|
19025
19026
|
this.sessionId = sessionId;
|
|
19026
19027
|
this.config = {
|
|
19027
19028
|
enabled: true,
|
|
@@ -19066,7 +19067,22 @@
|
|
|
19066
19067
|
});
|
|
19067
19068
|
this.isActive = true;
|
|
19068
19069
|
this.hasFullSnapshot = false;
|
|
19070
|
+
this.startTime = Date.now();
|
|
19069
19071
|
this.startBatchTimer();
|
|
19072
|
+
// Set timeout to check if FullSnapshot was captured
|
|
19073
|
+
this.snapshotTimeout = window.setTimeout(() => {
|
|
19074
|
+
if (!this.hasFullSnapshot) {
|
|
19075
|
+
console.error("[Zaplier] CRITICAL: FullSnapshot not captured after 5 seconds!", {
|
|
19076
|
+
eventsReceived: this.events.length,
|
|
19077
|
+
eventTypes: this.events.map((e) => e.type).slice(0, 10),
|
|
19078
|
+
});
|
|
19079
|
+
// Don't send batches without FullSnapshot - replay won't work
|
|
19080
|
+
// The issue is likely with rrweb errors preventing snapshot capture
|
|
19081
|
+
}
|
|
19082
|
+
else {
|
|
19083
|
+
console.log("[Zaplier] FullSnapshot confirmed captured");
|
|
19084
|
+
}
|
|
19085
|
+
}, 5000);
|
|
19070
19086
|
console.log("[Zaplier] Session replay started with rrweb");
|
|
19071
19087
|
return true;
|
|
19072
19088
|
}
|
|
@@ -19091,6 +19107,10 @@
|
|
|
19091
19107
|
clearInterval(this.batchTimer);
|
|
19092
19108
|
this.batchTimer = undefined;
|
|
19093
19109
|
}
|
|
19110
|
+
if (this.snapshotTimeout) {
|
|
19111
|
+
clearTimeout(this.snapshotTimeout);
|
|
19112
|
+
this.snapshotTimeout = undefined;
|
|
19113
|
+
}
|
|
19094
19114
|
// Send final batch
|
|
19095
19115
|
this.sendBatch();
|
|
19096
19116
|
}
|
|
@@ -19099,13 +19119,47 @@
|
|
|
19099
19119
|
*/
|
|
19100
19120
|
handleRRWebEvent(event) {
|
|
19101
19121
|
try {
|
|
19102
|
-
//
|
|
19103
|
-
|
|
19122
|
+
// Log ALL events until we get FullSnapshot, then log first 5
|
|
19123
|
+
const shouldLog = !this.hasFullSnapshot || this.events.length < 5;
|
|
19124
|
+
if (shouldLog) {
|
|
19125
|
+
const eventTypeNames = {
|
|
19126
|
+
[EventType.DomContentLoaded]: "DomContentLoaded",
|
|
19127
|
+
[EventType.Load]: "Load",
|
|
19128
|
+
[EventType.FullSnapshot]: "FullSnapshot",
|
|
19129
|
+
[EventType.IncrementalSnapshot]: "IncrementalSnapshot",
|
|
19130
|
+
[EventType.Meta]: "Meta",
|
|
19131
|
+
[EventType.Custom]: "Custom",
|
|
19132
|
+
[EventType.Plugin]: "Plugin",
|
|
19133
|
+
};
|
|
19134
|
+
console.log(`[Zaplier] Received event type ${event.type} (${eventTypeNames[event.type] || "Unknown"})`, {
|
|
19135
|
+
timestamp: new Date(event.timestamp).toISOString(),
|
|
19136
|
+
isFirst: this.events.length === 0,
|
|
19137
|
+
totalEvents: this.events.length + 1,
|
|
19138
|
+
});
|
|
19139
|
+
}
|
|
19140
|
+
// Check if this is a FullSnapshot
|
|
19141
|
+
if (event.type === EventType.FullSnapshot) {
|
|
19104
19142
|
this.hasFullSnapshot = true;
|
|
19105
|
-
console.log("[Zaplier] FullSnapshot captured");
|
|
19143
|
+
console.log("[Zaplier] ✅ FullSnapshot captured! Replay will work correctly.");
|
|
19144
|
+
// Clear timeout since we got the snapshot
|
|
19145
|
+
if (this.snapshotTimeout) {
|
|
19146
|
+
clearTimeout(this.snapshotTimeout);
|
|
19147
|
+
this.snapshotTimeout = undefined;
|
|
19148
|
+
}
|
|
19149
|
+
}
|
|
19150
|
+
else if (this.events.length === 0) {
|
|
19151
|
+
// First event is NOT a FullSnapshot - this is a problem!
|
|
19152
|
+
console.error(`[Zaplier] ⚠️ WARNING: First event is type ${event.type}, not FullSnapshot! Replay may not work.`);
|
|
19106
19153
|
}
|
|
19107
19154
|
// Add event to buffer
|
|
19108
19155
|
this.addEvent(event);
|
|
19156
|
+
// If we just got the FullSnapshot and have events, try sending immediately
|
|
19157
|
+
if (event.type === EventType.FullSnapshot && this.events.length > 0) {
|
|
19158
|
+
// Small delay to ensure all initial events are captured
|
|
19159
|
+
setTimeout(() => {
|
|
19160
|
+
this.sendBatch();
|
|
19161
|
+
}, 100);
|
|
19162
|
+
}
|
|
19109
19163
|
}
|
|
19110
19164
|
catch (error) {
|
|
19111
19165
|
// Silently ignore errors from rrweb to prevent breaking the app
|
|
@@ -19121,7 +19175,7 @@
|
|
|
19121
19175
|
// Prevent memory overflow
|
|
19122
19176
|
if (this.events.length > this.config.maxEventBuffer) {
|
|
19123
19177
|
// Keep FullSnapshot if present
|
|
19124
|
-
const fullSnapshotIndex = this.events.findIndex((e) => e.type ===
|
|
19178
|
+
const fullSnapshotIndex = this.events.findIndex((e) => e.type === EventType.FullSnapshot);
|
|
19125
19179
|
if (fullSnapshotIndex >= 0 &&
|
|
19126
19180
|
fullSnapshotIndex < this.events.length - this.config.maxEventBuffer) {
|
|
19127
19181
|
// Keep snapshot and recent events
|
|
@@ -19149,15 +19203,19 @@
|
|
|
19149
19203
|
if (this.events.length === 0) {
|
|
19150
19204
|
return;
|
|
19151
19205
|
}
|
|
19152
|
-
//
|
|
19206
|
+
// CRITICAL: Never send batches without FullSnapshot - replay won't work!
|
|
19153
19207
|
if (!this.hasFullSnapshot) {
|
|
19154
|
-
|
|
19155
|
-
|
|
19208
|
+
const waitTime = Date.now() - this.startTime;
|
|
19209
|
+
// Only log every 2 seconds to avoid spam
|
|
19210
|
+
if (waitTime % 2000 < 100) {
|
|
19211
|
+
console.warn(`[Zaplier] Waiting for FullSnapshot before sending batch... (${Math.floor(waitTime / 1000)}s). Events so far: ${this.events.length}, types:`, this.events.map((e) => e.type).slice(0, 5));
|
|
19212
|
+
}
|
|
19213
|
+
return; // Don't send without FullSnapshot
|
|
19156
19214
|
}
|
|
19157
19215
|
const batch = [...this.events];
|
|
19158
19216
|
this.events = [];
|
|
19159
19217
|
// Verify batch has FullSnapshot
|
|
19160
|
-
const hasSnapshot = batch.some((e) => e.type ===
|
|
19218
|
+
const hasSnapshot = batch.some((e) => e.type === EventType.FullSnapshot);
|
|
19161
19219
|
if (!hasSnapshot && this.hasFullSnapshot) {
|
|
19162
19220
|
console.warn("[Zaplier] Batch missing FullSnapshot, but one was captured earlier");
|
|
19163
19221
|
}
|