@zaplier/sdk 1.7.4 โ†’ 1.7.5

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.esm.js CHANGED
@@ -19570,27 +19570,52 @@ class AutoTracker {
19570
19570
  if (this.config.trackScrolls) {
19571
19571
  const scrollHandler = this.createEnhancedScrollHandler();
19572
19572
  this.delegationHandlers.set('scroll', scrollHandler);
19573
- // Always use document for scroll events (window doesn't work with removeEventListener)
19574
- document.addEventListener('scroll', scrollHandler, this.getEventOptions('scroll'));
19573
+ // MAJOR FIX: Use window instead of document for scroll events
19574
+ // Document doesn't reliably receive scroll events in all browsers
19575
+ const scrollTarget = window;
19576
+ const scrollOptions = {
19577
+ passive: false, // Changed from passive: true to ensure handler executes
19578
+ capture: false
19579
+ };
19580
+ scrollTarget.addEventListener('scroll', scrollHandler, scrollOptions);
19581
+ // Also add to document as backup (some scenarios need both)
19582
+ document.addEventListener('scroll', scrollHandler, scrollOptions);
19575
19583
  if (this.config.debug) {
19576
- console.log("[๐Ÿ“œ AutoTracker] โœ… Scroll delegation handler added to document");
19584
+ console.log("[๐Ÿ“œ AutoTracker] โœ… Scroll delegation handler added to BOTH window AND document");
19577
19585
  console.log("[๐Ÿ“œ AutoTracker] ๐Ÿ“‹ Event listener details:", {
19578
- target: 'document',
19586
+ primaryTarget: 'window',
19587
+ backupTarget: 'document',
19579
19588
  eventType: 'scroll',
19580
19589
  handlerType: typeof scrollHandler,
19581
- options: this.getEventOptions('scroll'),
19590
+ options: scrollOptions,
19582
19591
  handlerStored: this.delegationHandlers.has('scroll')
19583
19592
  });
19584
- // Test if handler is actually working
19593
+ // Enhanced test function with real scroll simulation
19585
19594
  const testHandler = () => {
19586
19595
  console.log("[๐Ÿ“œ AutoTracker] ๐Ÿงช MANUAL SCROLL TEST - Handler should trigger");
19587
19596
  scrollHandler(new Event('scroll'));
19588
19597
  };
19589
- // Expose test function globally for manual testing
19598
+ const testRealScroll = () => {
19599
+ console.log("[๐Ÿ“œ AutoTracker] ๐Ÿงช TESTING REAL SCROLL EVENT");
19600
+ window.scrollBy(0, 1); // Trigger real scroll
19601
+ setTimeout(() => {
19602
+ window.scrollBy(0, -1); // Scroll back
19603
+ }, 100);
19604
+ };
19605
+ // Expose test functions globally for manual testing
19590
19606
  if (typeof window !== 'undefined') {
19591
19607
  window.testScrollHandler = testHandler;
19592
- console.log("[๐Ÿ“œ AutoTracker] ๐Ÿงช Manual test available: window.testScrollHandler()");
19608
+ window.testRealScroll = testRealScroll;
19609
+ console.log("[๐Ÿ“œ AutoTracker] ๐Ÿงช Manual tests available:");
19610
+ console.log("[๐Ÿ“œ AutoTracker] ๐Ÿงช - window.testScrollHandler() (direct handler test)");
19611
+ console.log("[๐Ÿ“œ AutoTracker] ๐Ÿงช - window.testRealScroll() (real scroll test)");
19593
19612
  }
19613
+ // Add debug listener to verify scroll events are firing
19614
+ const debugScrollListener = () => {
19615
+ console.log("[๐Ÿ“œ AutoTracker] ๐Ÿ” DEBUG: Real scroll event detected!");
19616
+ };
19617
+ window.addEventListener('scroll', debugScrollListener, { once: true });
19618
+ console.log("[๐Ÿ“œ AutoTracker] ๐Ÿ” Debug scroll listener added (will fire once on next scroll)");
19594
19619
  // Immediate test of element detection
19595
19620
  setTimeout(() => {
19596
19621
  const scrollElements = this.getCachedScrollElements();
@@ -19607,16 +19632,11 @@ class AutoTracker {
19607
19632
  });
19608
19633
  });
19609
19634
  }
19610
- // Also test manually trigger one element
19611
- if (scrollElements.length > 0) {
19612
- const firstElement = scrollElements[0];
19613
- if (firstElement) {
19614
- console.log(`[๐Ÿ“œ AutoTracker] ๐Ÿงช Testing manual trigger on first element:`, firstElement.getAttribute('data-track-scroll'));
19615
- setTimeout(() => {
19616
- console.log("[๐Ÿ“œ AutoTracker] ๐Ÿงช Manual trigger test executed");
19617
- }, 500);
19618
- }
19619
- }
19635
+ // Test auto-scroll detection
19636
+ setTimeout(() => {
19637
+ console.log("[๐Ÿ“œ AutoTracker] ๐Ÿงช Auto-testing scroll detection in 1 second...");
19638
+ testRealScroll();
19639
+ }, 1000);
19620
19640
  }, 100);
19621
19641
  }
19622
19642
  }
@@ -20030,11 +20050,25 @@ class AutoTracker {
20030
20050
  */
20031
20051
  stop() {
20032
20052
  if (this.config.debug) {
20033
- console.log('[AutoTracker] Stopping auto tracking and cleaning up...');
20053
+ console.log('[๐Ÿ“œ AutoTracker] Stopping enhanced auto tracking and cleaning up...');
20034
20054
  }
20035
- // Remove delegation handlers
20055
+ // Remove delegation handlers from correct targets
20036
20056
  this.delegationHandlers.forEach((handler, eventType) => {
20037
- document.removeEventListener(eventType, handler);
20057
+ if (eventType === 'click') {
20058
+ const delegationTarget = this.getOptimalDelegationTarget();
20059
+ delegationTarget.removeEventListener('click', handler);
20060
+ }
20061
+ else if (eventType === 'scroll') {
20062
+ // Remove from both window and document (as we added to both)
20063
+ window.removeEventListener('scroll', handler);
20064
+ document.removeEventListener('scroll', handler);
20065
+ if (this.config.debug) {
20066
+ console.log('[๐Ÿ“œ AutoTracker] Removed scroll listeners from window and document');
20067
+ }
20068
+ }
20069
+ else {
20070
+ document.removeEventListener(eventType, handler);
20071
+ }
20038
20072
  });
20039
20073
  this.delegationHandlers.clear();
20040
20074
  // Disconnect observers
@@ -20049,6 +20083,9 @@ class AutoTracker {
20049
20083
  // Clear caches
20050
20084
  this.observedElements.clear();
20051
20085
  this.isInitialized = false;
20086
+ if (this.config.debug) {
20087
+ console.log('[๐Ÿ“œ AutoTracker] Enhanced cleanup completed');
20088
+ }
20052
20089
  }
20053
20090
  /**
20054
20091
  * Legacy method - now handled by intelligent mutation observer