@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/index.esm.js
CHANGED
|
@@ -19016,6 +19016,7 @@ class SessionReplayEngine {
|
|
|
19016
19016
|
this.events = [];
|
|
19017
19017
|
this.isActive = false;
|
|
19018
19018
|
this.hasFullSnapshot = false;
|
|
19019
|
+
this.startTime = 0;
|
|
19019
19020
|
this.sessionId = sessionId;
|
|
19020
19021
|
this.config = {
|
|
19021
19022
|
enabled: true,
|
|
@@ -19060,7 +19061,22 @@ class SessionReplayEngine {
|
|
|
19060
19061
|
});
|
|
19061
19062
|
this.isActive = true;
|
|
19062
19063
|
this.hasFullSnapshot = false;
|
|
19064
|
+
this.startTime = Date.now();
|
|
19063
19065
|
this.startBatchTimer();
|
|
19066
|
+
// Set timeout to check if FullSnapshot was captured
|
|
19067
|
+
this.snapshotTimeout = window.setTimeout(() => {
|
|
19068
|
+
if (!this.hasFullSnapshot) {
|
|
19069
|
+
console.error("[Zaplier] CRITICAL: FullSnapshot not captured after 5 seconds!", {
|
|
19070
|
+
eventsReceived: this.events.length,
|
|
19071
|
+
eventTypes: this.events.map((e) => e.type).slice(0, 10),
|
|
19072
|
+
});
|
|
19073
|
+
// Don't send batches without FullSnapshot - replay won't work
|
|
19074
|
+
// The issue is likely with rrweb errors preventing snapshot capture
|
|
19075
|
+
}
|
|
19076
|
+
else {
|
|
19077
|
+
console.log("[Zaplier] FullSnapshot confirmed captured");
|
|
19078
|
+
}
|
|
19079
|
+
}, 5000);
|
|
19064
19080
|
console.log("[Zaplier] Session replay started with rrweb");
|
|
19065
19081
|
return true;
|
|
19066
19082
|
}
|
|
@@ -19085,6 +19101,10 @@ class SessionReplayEngine {
|
|
|
19085
19101
|
clearInterval(this.batchTimer);
|
|
19086
19102
|
this.batchTimer = undefined;
|
|
19087
19103
|
}
|
|
19104
|
+
if (this.snapshotTimeout) {
|
|
19105
|
+
clearTimeout(this.snapshotTimeout);
|
|
19106
|
+
this.snapshotTimeout = undefined;
|
|
19107
|
+
}
|
|
19088
19108
|
// Send final batch
|
|
19089
19109
|
this.sendBatch();
|
|
19090
19110
|
}
|
|
@@ -19093,13 +19113,47 @@ class SessionReplayEngine {
|
|
|
19093
19113
|
*/
|
|
19094
19114
|
handleRRWebEvent(event) {
|
|
19095
19115
|
try {
|
|
19096
|
-
//
|
|
19097
|
-
|
|
19116
|
+
// Log ALL events until we get FullSnapshot, then log first 5
|
|
19117
|
+
const shouldLog = !this.hasFullSnapshot || this.events.length < 5;
|
|
19118
|
+
if (shouldLog) {
|
|
19119
|
+
const eventTypeNames = {
|
|
19120
|
+
[EventType.DomContentLoaded]: "DomContentLoaded",
|
|
19121
|
+
[EventType.Load]: "Load",
|
|
19122
|
+
[EventType.FullSnapshot]: "FullSnapshot",
|
|
19123
|
+
[EventType.IncrementalSnapshot]: "IncrementalSnapshot",
|
|
19124
|
+
[EventType.Meta]: "Meta",
|
|
19125
|
+
[EventType.Custom]: "Custom",
|
|
19126
|
+
[EventType.Plugin]: "Plugin",
|
|
19127
|
+
};
|
|
19128
|
+
console.log(`[Zaplier] Received event type ${event.type} (${eventTypeNames[event.type] || "Unknown"})`, {
|
|
19129
|
+
timestamp: new Date(event.timestamp).toISOString(),
|
|
19130
|
+
isFirst: this.events.length === 0,
|
|
19131
|
+
totalEvents: this.events.length + 1,
|
|
19132
|
+
});
|
|
19133
|
+
}
|
|
19134
|
+
// Check if this is a FullSnapshot
|
|
19135
|
+
if (event.type === EventType.FullSnapshot) {
|
|
19098
19136
|
this.hasFullSnapshot = true;
|
|
19099
|
-
console.log("[Zaplier] FullSnapshot captured");
|
|
19137
|
+
console.log("[Zaplier] ✅ FullSnapshot captured! Replay will work correctly.");
|
|
19138
|
+
// Clear timeout since we got the snapshot
|
|
19139
|
+
if (this.snapshotTimeout) {
|
|
19140
|
+
clearTimeout(this.snapshotTimeout);
|
|
19141
|
+
this.snapshotTimeout = undefined;
|
|
19142
|
+
}
|
|
19143
|
+
}
|
|
19144
|
+
else if (this.events.length === 0) {
|
|
19145
|
+
// First event is NOT a FullSnapshot - this is a problem!
|
|
19146
|
+
console.error(`[Zaplier] ⚠️ WARNING: First event is type ${event.type}, not FullSnapshot! Replay may not work.`);
|
|
19100
19147
|
}
|
|
19101
19148
|
// Add event to buffer
|
|
19102
19149
|
this.addEvent(event);
|
|
19150
|
+
// If we just got the FullSnapshot and have events, try sending immediately
|
|
19151
|
+
if (event.type === EventType.FullSnapshot && this.events.length > 0) {
|
|
19152
|
+
// Small delay to ensure all initial events are captured
|
|
19153
|
+
setTimeout(() => {
|
|
19154
|
+
this.sendBatch();
|
|
19155
|
+
}, 100);
|
|
19156
|
+
}
|
|
19103
19157
|
}
|
|
19104
19158
|
catch (error) {
|
|
19105
19159
|
// Silently ignore errors from rrweb to prevent breaking the app
|
|
@@ -19115,7 +19169,7 @@ class SessionReplayEngine {
|
|
|
19115
19169
|
// Prevent memory overflow
|
|
19116
19170
|
if (this.events.length > this.config.maxEventBuffer) {
|
|
19117
19171
|
// Keep FullSnapshot if present
|
|
19118
|
-
const fullSnapshotIndex = this.events.findIndex((e) => e.type ===
|
|
19172
|
+
const fullSnapshotIndex = this.events.findIndex((e) => e.type === EventType.FullSnapshot);
|
|
19119
19173
|
if (fullSnapshotIndex >= 0 &&
|
|
19120
19174
|
fullSnapshotIndex < this.events.length - this.config.maxEventBuffer) {
|
|
19121
19175
|
// Keep snapshot and recent events
|
|
@@ -19143,15 +19197,19 @@ class SessionReplayEngine {
|
|
|
19143
19197
|
if (this.events.length === 0) {
|
|
19144
19198
|
return;
|
|
19145
19199
|
}
|
|
19146
|
-
//
|
|
19200
|
+
// CRITICAL: Never send batches without FullSnapshot - replay won't work!
|
|
19147
19201
|
if (!this.hasFullSnapshot) {
|
|
19148
|
-
|
|
19149
|
-
|
|
19202
|
+
const waitTime = Date.now() - this.startTime;
|
|
19203
|
+
// Only log every 2 seconds to avoid spam
|
|
19204
|
+
if (waitTime % 2000 < 100) {
|
|
19205
|
+
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));
|
|
19206
|
+
}
|
|
19207
|
+
return; // Don't send without FullSnapshot
|
|
19150
19208
|
}
|
|
19151
19209
|
const batch = [...this.events];
|
|
19152
19210
|
this.events = [];
|
|
19153
19211
|
// Verify batch has FullSnapshot
|
|
19154
|
-
const hasSnapshot = batch.some((e) => e.type ===
|
|
19212
|
+
const hasSnapshot = batch.some((e) => e.type === EventType.FullSnapshot);
|
|
19155
19213
|
if (!hasSnapshot && this.hasFullSnapshot) {
|
|
19156
19214
|
console.warn("[Zaplier] Batch missing FullSnapshot, but one was captured earlier");
|
|
19157
19215
|
}
|