@zaplier/sdk 1.6.6 → 1.6.8
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 +68 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +68 -20
- package/dist/index.esm.js.map +1 -1
- package/dist/sdk.js +68 -20
- package/dist/sdk.js.map +1 -1
- package/dist/sdk.min.js +1 -1
- package/dist/src/modules/auto-tracker.d.ts +1 -6
- package/dist/src/modules/auto-tracker.d.ts.map +1 -1
- package/dist/src/sdk.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/sdk.js
CHANGED
|
@@ -19267,21 +19267,60 @@
|
|
|
19267
19267
|
class AutoTracker {
|
|
19268
19268
|
constructor(sdkInstance, config = {}) {
|
|
19269
19269
|
this.observedElements = new Set();
|
|
19270
|
-
|
|
19271
|
-
* Event handlers (bound to this)
|
|
19272
|
-
*/
|
|
19273
|
-
this.handleClick = (event) => {
|
|
19274
|
-
const target = event.target;
|
|
19275
|
-
if (target.hasAttribute("data-track-click")) ;
|
|
19276
|
-
};
|
|
19270
|
+
this.scrollThrottle = 0;
|
|
19277
19271
|
this.handleScroll = () => {
|
|
19278
|
-
|
|
19279
|
-
|
|
19280
|
-
|
|
19281
|
-
|
|
19282
|
-
|
|
19283
|
-
|
|
19284
|
-
|
|
19272
|
+
if (!this.config.trackScrolls)
|
|
19273
|
+
return;
|
|
19274
|
+
// Throttle scroll events for performance
|
|
19275
|
+
const now = Date.now();
|
|
19276
|
+
if (now - this.scrollThrottle < 100)
|
|
19277
|
+
return; // 100ms throttle
|
|
19278
|
+
this.scrollThrottle = now;
|
|
19279
|
+
const scrollElements = document.querySelectorAll('[data-track-scroll]');
|
|
19280
|
+
if (this.config.debug && scrollElements.length > 0) {
|
|
19281
|
+
console.log(`[AutoTracker] Checking ${scrollElements.length} scroll elements`);
|
|
19282
|
+
}
|
|
19283
|
+
scrollElements.forEach((element) => {
|
|
19284
|
+
let hasTriggered = element.getAttribute('data-scroll-triggered') === 'true';
|
|
19285
|
+
if (hasTriggered)
|
|
19286
|
+
return;
|
|
19287
|
+
const threshold = parseFloat(element.getAttribute("data-scroll-threshold") || "0.5");
|
|
19288
|
+
const rect = element.getBoundingClientRect();
|
|
19289
|
+
const elementHeight = rect.height;
|
|
19290
|
+
const visibleHeight = Math.min(rect.bottom, window.innerHeight) - Math.max(rect.top, 0);
|
|
19291
|
+
const visibilityRatio = Math.max(0, visibleHeight) / elementHeight;
|
|
19292
|
+
if (this.config.debug) {
|
|
19293
|
+
console.log(`[AutoTracker] Element check:`, {
|
|
19294
|
+
elementId: element.id || element.className,
|
|
19295
|
+
visibilityRatio: Math.round(visibilityRatio * 100) / 100,
|
|
19296
|
+
threshold,
|
|
19297
|
+
triggered: hasTriggered
|
|
19298
|
+
});
|
|
19299
|
+
}
|
|
19300
|
+
if (visibilityRatio >= threshold) {
|
|
19301
|
+
element.setAttribute('data-scroll-triggered', 'true');
|
|
19302
|
+
const eventName = element.getAttribute("data-track-scroll");
|
|
19303
|
+
if (!eventName)
|
|
19304
|
+
return;
|
|
19305
|
+
const metadata = this.extractMetadata(element);
|
|
19306
|
+
this.trackEvent(eventName, {
|
|
19307
|
+
type: "scroll",
|
|
19308
|
+
element: element.tagName.toLowerCase(),
|
|
19309
|
+
threshold,
|
|
19310
|
+
scrollDepth: window.scrollY,
|
|
19311
|
+
visibilityRatio: Math.round(visibilityRatio * 100) / 100,
|
|
19312
|
+
...metadata,
|
|
19313
|
+
});
|
|
19314
|
+
if (this.config.debug) {
|
|
19315
|
+
console.log(`[AutoTracker] Scroll tracked: ${eventName}`, {
|
|
19316
|
+
threshold,
|
|
19317
|
+
visibilityRatio,
|
|
19318
|
+
scrollDepth: window.scrollY,
|
|
19319
|
+
...metadata
|
|
19320
|
+
});
|
|
19321
|
+
}
|
|
19322
|
+
}
|
|
19323
|
+
});
|
|
19285
19324
|
};
|
|
19286
19325
|
this.sdkInstance = sdkInstance;
|
|
19287
19326
|
this.config = {
|
|
@@ -19302,7 +19341,14 @@
|
|
|
19302
19341
|
if (!this.config.enabled)
|
|
19303
19342
|
return;
|
|
19304
19343
|
if (this.config.debug) {
|
|
19305
|
-
console.log("[Zaplier AutoTracker] Iniciando auto tracking"
|
|
19344
|
+
console.log("[Zaplier AutoTracker] Iniciando auto tracking", {
|
|
19345
|
+
enabled: this.config.enabled,
|
|
19346
|
+
trackClicks: this.config.trackClicks,
|
|
19347
|
+
trackScrolls: this.config.trackScrolls,
|
|
19348
|
+
trackViews: this.config.trackViews,
|
|
19349
|
+
trackHovers: this.config.trackHovers,
|
|
19350
|
+
trackForms: this.config.trackForms
|
|
19351
|
+
});
|
|
19306
19352
|
}
|
|
19307
19353
|
// Observer para novos elementos no DOM
|
|
19308
19354
|
this.observeDOM();
|
|
@@ -19312,15 +19358,16 @@
|
|
|
19312
19358
|
if (this.config.trackViews) {
|
|
19313
19359
|
this.setupViewTracking();
|
|
19314
19360
|
}
|
|
19361
|
+
// Setup global event listeners
|
|
19362
|
+
if (this.config.trackScrolls) {
|
|
19363
|
+
document.addEventListener("scroll", this.handleScroll, { passive: true });
|
|
19364
|
+
}
|
|
19315
19365
|
}
|
|
19316
19366
|
/**
|
|
19317
19367
|
* Parar auto tracking
|
|
19318
19368
|
*/
|
|
19319
19369
|
stop() {
|
|
19320
|
-
document.removeEventListener("click", this.handleClick);
|
|
19321
19370
|
document.removeEventListener("scroll", this.handleScroll);
|
|
19322
|
-
document.removeEventListener("mouseover", this.handleHover);
|
|
19323
|
-
document.removeEventListener("submit", this.handleForm);
|
|
19324
19371
|
if (this.intersectionObserver) {
|
|
19325
19372
|
this.intersectionObserver.disconnect();
|
|
19326
19373
|
}
|
|
@@ -19959,7 +20006,7 @@
|
|
|
19959
20006
|
*/
|
|
19960
20007
|
class ZaplierSDK {
|
|
19961
20008
|
constructor(userConfig) {
|
|
19962
|
-
this.version = "1.7.
|
|
20009
|
+
this.version = "1.7.1";
|
|
19963
20010
|
this.isInitialized = false;
|
|
19964
20011
|
this.eventQueue = [];
|
|
19965
20012
|
/**
|
|
@@ -20391,7 +20438,8 @@
|
|
|
20391
20438
|
const visitorIdentity = await this.visitorIdentityManager.getOrCreateVisitorIdentity({
|
|
20392
20439
|
fingerprintHash: result.data.hash,
|
|
20393
20440
|
stableCoreHash: result.data.stableCoreHash,
|
|
20394
|
-
|
|
20441
|
+
// CRITICAL: Use stableCoreHash as deviceFingerprint for consistency with backend
|
|
20442
|
+
deviceFingerprint: result.data.stableCoreHash || result.data.hash,
|
|
20395
20443
|
sessionId: this.sessionId,
|
|
20396
20444
|
userAgent: navigator.userAgent,
|
|
20397
20445
|
ipAddress: undefined, // Will be determined server-side
|