@zaplier/sdk 1.7.8 → 1.8.0
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 +76 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.esm.js +76 -12
- package/dist/index.esm.js.map +1 -1
- package/dist/sdk.js +76 -12
- package/dist/sdk.js.map +1 -1
- package/dist/sdk.legacy.min.js +6 -0
- package/dist/sdk.min.js +1 -1
- package/dist/src/core.d.ts +87 -0
- package/dist/src/core.d.ts.map +1 -0
- package/dist/src/sdk.d.ts +5 -1
- package/dist/src/sdk.d.ts.map +1 -1
- package/dist/src/utils/session-utils.d.ts +24 -0
- package/dist/src/utils/session-utils.d.ts.map +1 -1
- package/dist/v2/chunks/fingerprint-ergvAID6.js +8461 -0
- package/dist/v2/chunks/replay-CM8dTFmL.js +12158 -0
- package/dist/v2/chunks/session-replay-C_UkGoTj.js +240 -0
- package/dist/v2/core.d.ts +88 -0
- package/dist/v2/core.js +245 -0
- package/dist/v2/core.min.js +6 -0
- package/dist/v2/modules/anti-adblock.js +6 -0
- package/dist/v2/modules/browser-apis-uFUJ09Rq.js +6 -0
- package/dist/v2/modules/confidence-CQp4GgvX.js +6 -0
- package/dist/v2/modules/device-signals-B35sK6Ly.js +6 -0
- package/dist/v2/modules/dom-blockers-Dv-oD-zS.js +6 -0
- package/dist/v2/modules/fingerprint-Cx012xiQ.js +6 -0
- package/dist/v2/modules/fingerprint.js +6 -0
- package/dist/v2/modules/hardware-B-ewb7VY.js +6 -0
- package/dist/v2/modules/heatmap.js +6 -0
- package/dist/v2/modules/incognito-B-8zH3xS.js +6 -0
- package/dist/v2/modules/math-BLnUnJG8.js +6 -0
- package/dist/v2/modules/plugins-enhanced-BNnyFJad.js +6 -0
- package/dist/v2/modules/replay.js +6 -0
- package/dist/v2/modules/storage-iGy4i5YE.js +6 -0
- package/dist/v2/modules/system-Dcygxavm.js +6 -0
- package/package.json +6 -2
package/dist/index.cjs
CHANGED
|
@@ -21386,7 +21386,7 @@ class ZaplierSDK {
|
|
|
21386
21386
|
}
|
|
21387
21387
|
}
|
|
21388
21388
|
/**
|
|
21389
|
-
* Initialize SDK
|
|
21389
|
+
* Initialize SDK - Non-blocking approach
|
|
21390
21390
|
*/
|
|
21391
21391
|
async initialize() {
|
|
21392
21392
|
try {
|
|
@@ -21400,21 +21400,19 @@ class ZaplierSDK {
|
|
|
21400
21400
|
}
|
|
21401
21401
|
return;
|
|
21402
21402
|
}
|
|
21403
|
-
//
|
|
21404
|
-
|
|
21405
|
-
// Auto-track page view if enabled
|
|
21403
|
+
// CRITICAL: Initialize basic tracking immediately (non-blocking)
|
|
21404
|
+
this.isInitialized = true;
|
|
21405
|
+
// Auto-track page view if enabled (immediate, before fingerprinting)
|
|
21406
21406
|
if (this.config.autoTrack) {
|
|
21407
21407
|
this.trackPageView();
|
|
21408
21408
|
}
|
|
21409
|
-
|
|
21410
|
-
// Initialize anti-adblock system first
|
|
21411
|
-
this.initializeAntiAdblock();
|
|
21412
|
-
// Then initialize tracking engines (they'll connect to anti-adblock)
|
|
21413
|
-
this.initializeTrackingEngines();
|
|
21414
|
-
// Initialize auto tracker
|
|
21415
|
-
this.initializeAutoTracker();
|
|
21416
|
-
// Process queued events
|
|
21409
|
+
// Process any queued events immediately
|
|
21417
21410
|
this.processEventQueue();
|
|
21411
|
+
// PERFORMANCE: Defer heavy operations to avoid blocking main thread
|
|
21412
|
+
this.deferHeavyOperations();
|
|
21413
|
+
if (this.config.debug) {
|
|
21414
|
+
console.log("[Zaplier] Core SDK initialized (deferring heavy operations)");
|
|
21415
|
+
}
|
|
21418
21416
|
if (this.config.debug) {
|
|
21419
21417
|
console.log("[Zaplier] SDK initialized successfully", {
|
|
21420
21418
|
visitorId: this.visitorId,
|
|
@@ -21426,6 +21424,55 @@ class ZaplierSDK {
|
|
|
21426
21424
|
console.error("[Zaplier] Initialization failed:", error);
|
|
21427
21425
|
}
|
|
21428
21426
|
}
|
|
21427
|
+
/**
|
|
21428
|
+
* Defer heavy operations to avoid blocking main thread
|
|
21429
|
+
*/
|
|
21430
|
+
deferHeavyOperations() {
|
|
21431
|
+
// Use requestIdleCallback for optimal performance, fallback to setTimeout
|
|
21432
|
+
const scheduleWork = (callback, timeout = 5000) => {
|
|
21433
|
+
if (typeof requestIdleCallback !== 'undefined') {
|
|
21434
|
+
requestIdleCallback(callback, { timeout });
|
|
21435
|
+
}
|
|
21436
|
+
else {
|
|
21437
|
+
setTimeout(callback, 100); // Small delay fallback
|
|
21438
|
+
}
|
|
21439
|
+
};
|
|
21440
|
+
// Schedule fingerprinting when browser is idle
|
|
21441
|
+
scheduleWork(async () => {
|
|
21442
|
+
try {
|
|
21443
|
+
await this.collectFingerprint();
|
|
21444
|
+
if (this.config.debug) {
|
|
21445
|
+
console.log("[Zaplier] Fingerprint collected (deferred)");
|
|
21446
|
+
}
|
|
21447
|
+
}
|
|
21448
|
+
catch (error) {
|
|
21449
|
+
if (this.config.debug) {
|
|
21450
|
+
console.error("[Zaplier] Deferred fingerprinting failed:", error);
|
|
21451
|
+
}
|
|
21452
|
+
}
|
|
21453
|
+
}, 3000);
|
|
21454
|
+
// Schedule anti-adblock initialization
|
|
21455
|
+
scheduleWork(() => {
|
|
21456
|
+
this.initializeAntiAdblock();
|
|
21457
|
+
if (this.config.debug) {
|
|
21458
|
+
console.log("[Zaplier] Anti-adblock initialized (deferred)");
|
|
21459
|
+
}
|
|
21460
|
+
}, 1000);
|
|
21461
|
+
// Schedule tracking engines initialization
|
|
21462
|
+
scheduleWork(() => {
|
|
21463
|
+
this.initializeTrackingEngines();
|
|
21464
|
+
if (this.config.debug) {
|
|
21465
|
+
console.log("[Zaplier] Tracking engines initialized (deferred)");
|
|
21466
|
+
}
|
|
21467
|
+
}, 2000);
|
|
21468
|
+
// Schedule auto tracker initialization
|
|
21469
|
+
scheduleWork(() => {
|
|
21470
|
+
this.initializeAutoTracker();
|
|
21471
|
+
if (this.config.debug) {
|
|
21472
|
+
console.log("[Zaplier] Auto tracker initialized (deferred)");
|
|
21473
|
+
}
|
|
21474
|
+
}, 1500);
|
|
21475
|
+
}
|
|
21429
21476
|
/**
|
|
21430
21477
|
* Initialize tracking engines (Session Replay & Heatmap)
|
|
21431
21478
|
*/
|
|
@@ -21947,6 +21994,23 @@ class ZaplierSDK {
|
|
|
21947
21994
|
if (this.config.debug) {
|
|
21948
21995
|
console.log("[Zaplier] Replay batch result:", result);
|
|
21949
21996
|
}
|
|
21997
|
+
// CRITICAL: Synchronize session ID if backend returned a normalized one
|
|
21998
|
+
// This ensures all tracking components use the same session ID
|
|
21999
|
+
if (result.sessionId && result.sessionId !== this.sessionId) {
|
|
22000
|
+
const oldSessionId = this.sessionId;
|
|
22001
|
+
this.sessionId = result.sessionId;
|
|
22002
|
+
if (this.config.debug) {
|
|
22003
|
+
console.log("[Zaplier] Session ID synchronized from replay response:", {
|
|
22004
|
+
oldSessionId,
|
|
22005
|
+
newSessionId: this.sessionId,
|
|
22006
|
+
originalSessionId: result.originalSessionId
|
|
22007
|
+
});
|
|
22008
|
+
}
|
|
22009
|
+
// Update all tracking engines with the normalized session ID
|
|
22010
|
+
if (oldSessionId !== this.sessionId && this.sessionId) {
|
|
22011
|
+
this.updateTrackingEnginesSessionId(this.sessionId);
|
|
22012
|
+
}
|
|
22013
|
+
}
|
|
21950
22014
|
return result;
|
|
21951
22015
|
}
|
|
21952
22016
|
catch (error) {
|