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