@zaplier/sdk 1.3.6 → 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
@@ -19073,15 +19073,17 @@
19073
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
- console.log("[Zaplier] Forcing immediate FullSnapshot to ensure correct event order...");
19077
- try {
19078
- takeFullSnapshot(true); // Force a new FullSnapshot immediately
19079
- console.log("[Zaplier] FullSnapshot manually triggered");
19080
- }
19081
- catch (error) {
19082
- console.error("[Zaplier] Failed to force FullSnapshot:", error);
19076
+ if (!this.hasFullSnapshot) {
19077
+ console.log("[Zaplier] Forcing immediate FullSnapshot to ensure correct event order...");
19078
+ try {
19079
+ takeFullSnapshot(true); // Force a new FullSnapshot immediately
19080
+ console.log("[Zaplier] FullSnapshot manually triggered");
19081
+ }
19082
+ catch (error) {
19083
+ console.error("[Zaplier] Failed to force FullSnapshot:", error);
19084
+ }
19083
19085
  }
19084
- }, 100); // Very short delay to ensure it comes first
19086
+ }, 50); // Very short delay but let natural events come first
19085
19087
  // Set timeout to check if FullSnapshot was captured
19086
19088
  this.snapshotTimeout = window.setTimeout(() => {
19087
19089
  if (!this.hasFullSnapshot) {
@@ -19233,12 +19235,21 @@
19233
19235
  }
19234
19236
  const batch = [...this.events];
19235
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
+ }
19236
19247
  // Verify batch has FullSnapshot
19237
19248
  const hasSnapshot = batch.some((e) => e.type === EventType.FullSnapshot);
19238
19249
  if (!hasSnapshot && this.hasFullSnapshot) {
19239
19250
  console.warn("[Zaplier] Batch missing FullSnapshot, but one was captured earlier");
19240
19251
  }
19241
- 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) });
19242
19253
  const payload = {
19243
19254
  sessionId: this.sessionId,
19244
19255
  events: batch,
@@ -19340,7 +19351,7 @@
19340
19351
  */
19341
19352
  class ZaplierSDK {
19342
19353
  constructor(userConfig) {
19343
- this.version = "1.3.5";
19354
+ this.version = "1.3.7";
19344
19355
  this.isInitialized = false;
19345
19356
  this.eventQueue = [];
19346
19357
  /**