if (sessionStorage.getItem('PLAYWRIGHT') === 'true' && sessionStorage.getItem('BAT_FORCE') !== 'true') { if (window.console && console.log) { console.log('[BAT Analytics] Skipped (Playwright mode):', eventName); console.log('[BAT Analytics] Tracking:', payload); } return; } sendRequest('https://dragon.online-convert.com/api/bat', payload); }, }; // --- Replace stub and replay queue --- var oldQueue = window.Analytics._queue || []; window.Analytics = AnalyticsImpl; if (oldQueue && oldQueue.length) { oldQueue.forEach(function (args) { AnalyticsImpl.trackEvent.apply(AnalyticsImpl, args); }); } // --- Auto pageview tracking --- function trackPageView() { var props = {}; if (window.pageConfig && window.pageConfig.operation) { props.operation = window.pageConfig.operation; } AnalyticsImpl.trackEvent('page_view', props); } if (document.readyState === 'complete') { trackPageView(); } else { window.addEventListener('load', trackPageView); } window.addEventListener('popstate', trackPageView); window.addEventListener('hashchange', trackPageView); // --- Rage Click Detection --- (function setupRageClickTracking() { var clicks = []; var MAX_TIME = 1000; // ms var MAX_DISTANCE = 50; // px var REQUIRED_CLICKS = 3; // 3+ quick clicks in same spot document.addEventListener('click', function (e) { var now = Date.now(); clicks.push({ x: e.clientX, y: e.clientY, time: now }); // Keep only last few clicks clicks = clicks.filter(function (c) { return now - c.time < MAX_TIME; }); if (clicks.length >= REQUIRED_CLICKS) { var base = clicks[0]; var allClose = clicks.every(function (c) { return ( Math.abs(c.x - base.x) < MAX_DISTANCE && Math.abs(c.y - base.y) < MAX_DISTANCE ); }); if (allClose) { AnalyticsImpl.trackEvent('rage_click', { x: base.x, y: base.y, count: clicks.length, path: window.location.pathname, }); clicks = []; } } }); })(); // --- Scroll Depth Tracking --- (function setupScrollTracking() { var maxScroll = 0; var lastSentDepth = 0; function getScrollDepthPercent() { var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0; var docHeight = Math.max( document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight, document.body.clientHeight, document.documentElement.clientHeight ) - window.innerHeight; if (docHeight <= 0) return 100; return Math.round((scrollTop / docHeight) * 100); } function onScroll() { var depth = getScrollDepthPercent(); if (depth > maxScroll) maxScroll = depth; // Send every 25% increment if (maxScroll >= lastSentDepth + 25) { lastSentDepth = Math.floor(maxScroll / 25) * 25; AnalyticsImpl.trackEvent('scroll_depth', { depth: lastSentDepth, path: window.location.pathname, }, ['engagement']); } } window.addEventListener('scroll', onScroll, { passive: true }); })(); })(window, document); #}