@zaplier/sdk 1.3.5 → 1.3.7

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.esm.js CHANGED
@@ -19064,19 +19064,20 @@ class SessionReplayEngine {
19064
19064
  this.hasFullSnapshot = false;
19065
19065
  this.startTime = Date.now();
19066
19066
  this.startBatchTimer();
19067
- // WORKAROUND: Force FullSnapshot creation to fix rrweb 2.0.0-alpha bug
19067
+ // WORKAROUND: Force FullSnapshot creation IMMEDIATELY to fix rrweb 2.0.0-alpha bug
19068
19068
  // where FullSnapshot is sometimes not created as the first event
19069
19069
  setTimeout(() => {
19070
19070
  if (!this.hasFullSnapshot) {
19071
- console.warn("[Zaplier] ⚠️ FullSnapshot not created automatically, forcing manual capture...");
19071
+ console.log("[Zaplier] Forcing immediate FullSnapshot to ensure correct event order...");
19072
19072
  try {
19073
- takeFullSnapshot(true); // Force a new FullSnapshot
19073
+ takeFullSnapshot(true); // Force a new FullSnapshot immediately
19074
+ console.log("[Zaplier] FullSnapshot manually triggered");
19074
19075
  }
19075
19076
  catch (error) {
19076
19077
  console.error("[Zaplier] Failed to force FullSnapshot:", error);
19077
19078
  }
19078
19079
  }
19079
- }, 500); // Give rrweb a chance to create natural FullSnapshot first
19080
+ }, 50); // Very short delay but let natural events come first
19080
19081
  // Set timeout to check if FullSnapshot was captured
19081
19082
  this.snapshotTimeout = window.setTimeout(() => {
19082
19083
  if (!this.hasFullSnapshot) {
@@ -19228,12 +19229,21 @@ class SessionReplayEngine {
19228
19229
  }
19229
19230
  const batch = [...this.events];
19230
19231
  this.events = [];
19232
+ // IMPORTANT: Ensure FullSnapshot comes first in the batch
19233
+ const fullSnapshotIndex = batch.findIndex((e) => e.type === EventType.FullSnapshot);
19234
+ if (fullSnapshotIndex > 0) {
19235
+ console.log("[Zaplier] Reordering events - moving FullSnapshot to first position");
19236
+ const fullSnapshot = batch.splice(fullSnapshotIndex, 1)[0];
19237
+ if (fullSnapshot) {
19238
+ batch.unshift(fullSnapshot);
19239
+ }
19240
+ }
19231
19241
  // Verify batch has FullSnapshot
19232
19242
  const hasSnapshot = batch.some((e) => e.type === EventType.FullSnapshot);
19233
19243
  if (!hasSnapshot && this.hasFullSnapshot) {
19234
19244
  console.warn("[Zaplier] Batch missing FullSnapshot, but one was captured earlier");
19235
19245
  }
19236
- console.log(`[Zaplier] Sending batch with ${batch.length} events for session ${this.sessionId}`, { hasSnapshot, firstEventType: batch[0]?.type });
19246
+ console.log(`[Zaplier] Sending batch with ${batch.length} events for session ${this.sessionId}`, { hasSnapshot, firstEventType: batch[0]?.type, eventTypes: batch.slice(0, 5).map(e => e.type) });
19237
19247
  const payload = {
19238
19248
  sessionId: this.sessionId,
19239
19249
  events: batch,
@@ -19335,7 +19345,7 @@ const DEFAULT_CONFIG = {
19335
19345
  */
19336
19346
  class ZaplierSDK {
19337
19347
  constructor(userConfig) {
19338
- this.version = "1.3.5";
19348
+ this.version = "1.3.7";
19339
19349
  this.isInitialized = false;
19340
19350
  this.eventQueue = [];
19341
19351
  /**