{"version":3,"file":"PosthogScrollDepthTracking.Dp_WaAz7.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/BQtBHiyeE44UEHGRP0ph/MRtgRoAq7Zflo7eym6Xw/PosthogScrollDepthTracking.js"],"sourcesContent":["// Framer Scroll Depth Tracking Override\n// Add this as a code override to your page layout component\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useEffect,useRef}from\"react\";const MILESTONE_PERCENTAGES=Array.from({length:20},(_,i)=>+(.05*(i+1)).toFixed(2));const SCROLL_HANDLER_DEBOUNCE_TIME_MS=500;export function withScrollDepthTracking(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const maxScrollPercentage=useRef(0);const maxScrollPixels=useRef(0);const seenMilestonePercentages=useRef(new Set);const isInitialized=useRef(false);const debounceTimeout=useRef(null);function getScrollDepth(){const windowHeight=window.innerHeight;const pageYOffset=window.pageYOffset;const documentHeight=document.documentElement.scrollHeight;const currentPixels=windowHeight+pageYOffset;const currentPercentage=documentHeight>0?Math.min(1,currentPixels/documentHeight):1;return{pixels:currentPixels,percentage:currentPercentage};}function trackMilestone(milestone,percentage,pixels){if(window.posthog){window.posthog.capture(\"biograph_web.scroll_milestone_reached\",{milestone:milestone,scroll_percentage:percentage,scroll_pixels:pixels,page_url:window.location.href,page_title:document.title});}}function handleScroll(){const{pixels,percentage}=getScrollDepth();if(percentage>maxScrollPercentage.current){maxScrollPercentage.current=percentage;}if(pixels>maxScrollPixels.current){maxScrollPixels.current=pixels;}MILESTONE_PERCENTAGES.forEach(milestone=>{if(percentage>=milestone&&!seenMilestonePercentages.current.has(milestone)){seenMilestonePercentages.current.add(milestone);trackMilestone(milestone,percentage,pixels);}});}function handleScrollDebounced(){if(debounceTimeout.current){clearTimeout(debounceTimeout.current);}debounceTimeout.current=setTimeout(()=>{handleScroll();debounceTimeout.current=null;},SCROLL_HANDLER_DEBOUNCE_TIME_MS);}function trackPageLeave(){if(window.posthog){const{pixels,percentage}=getScrollDepth();window.posthog.capture(\"biograph_web.page_leave_scroll_depth\",{max_scroll_percentage:maxScrollPercentage.current,max_scroll_pixels:maxScrollPixels.current,final_scroll_percentage:percentage,final_scroll_pixels:pixels,page_url:window.location.href,page_title:document.title});}}function initTracking(){if(isInitialized.current)return;try{seenMilestonePercentages.current=new Set;window.addEventListener(\"scroll\",handleScrollDebounced,{passive:true});window.addEventListener(\"beforeunload\",trackPageLeave);isInitialized.current=true;}catch(error){console.error(\"Failed to initialize scroll tracking:\",error);}}function cleanup(){if(!isInitialized.current)return;trackPageLeave();window.removeEventListener(\"scroll\",handleScrollDebounced);window.removeEventListener(\"beforeunload\",trackPageLeave);if(debounceTimeout.current){clearTimeout(debounceTimeout.current);debounceTimeout.current=null;}isInitialized.current=false;}useEffect(()=>{initTracking();return()=>{cleanup();};},[]);return /*#__PURE__*/_jsx(Component,{ref:ref,...props});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withScrollDepthTracking\":{\"type\":\"reactHoc\",\"name\":\"withScrollDepthTracking\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./PosthogScrollDepthTracking.map"],"mappings":"8IAEuN,SAAgB,EAAwB,EAAU,CAAC,OAAoB,GAAY,EAAM,IAAM,CAAC,IAAM,EAAoBA,EAAO,EAAE,CAAO,EAAgBA,EAAO,EAAE,CAAO,EAAyBA,EAAO,IAAI,IAAI,CAAO,EAAcA,EAAO,GAAM,CAAO,EAAgBA,EAAO,KAAK,CAAC,SAAS,GAAgB,CAAC,IAAM,EAAa,EAAO,YAAkB,EAAY,EAAO,YAAkB,EAAe,SAAS,gBAAgB,aAAmB,EAAc,EAAa,EAAgG,MAAM,CAAC,OAAO,EAAc,WAAxF,EAAe,EAAE,KAAK,IAAI,EAAE,EAAc,EAAe,CAAC,EAA2D,CAAE,SAAS,EAAe,EAAU,EAAW,EAAO,CAAI,EAAO,SAAS,EAAO,QAAQ,QAAQ,wCAAwC,CAAW,YAAU,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