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