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