1const p="/api/public/pulse/ingest",g="epr_pulse_sid",f="epr_pulse_sid_ts";let r=[],c=null,s="",l=0,i=0,S=!1;function _(){const t=new Uint8Array(16);return crypto.getRandomValues(t),Array.from(t,e=>e.toString(16).padStart(2,"0")).join("")}function w(){try{const t=Date.now(),e=sessionStorage.getItem(g),n=sessionStorage.getItem(f),o=n?Number(n):0;if(e&&o&&t-o<18e5)return sessionStorage.setItem(f,String(t)),e;const a=_();return sessionStorage.setItem(g,a),sessionStorage.setItem(f,String(t)),a}catch{return _()}}function d(t){r.push({...t,session_id:w(),ts:new Date().toISOString()}),r.length>=50&&u()}function u(t=!1){if(r.length===0)return;const e=r;r=[];const n=JSON.stringify({events:e});try{if(t&&"sendBeacon"in navigator){const o=new Blob([n],{type:"application/json"});navigator.sendBeacon(p,o);return}fetch(p,{method:"POST",headers:{"Content-Type":"application/json"},body:n,keepalive:!0}).catch(()=>{})}catch{}}function h(){if(!s||!l)return;const t=Date.now()-l;d({event_type:"dwell",path:s,dwell_ms:t,scroll_pct:i})}function m(t){t!==s&&(h(),s=t,l=Date.now(),i=0,d({event_type:"pageview",path:t,referrer:document.referrer||void 0}))}function E(){const t=document.documentElement,e=t.scrollTop+window.innerHeight,n=t.scrollHeight;if(n<=0)return;const o=Math.min(100,Math.round(e/n*100));o>i&&(i=o)}function v(t){const e=t.target?.closest?.("a");if(!e)return;const n=e.getAttribute("href");if(n)try{const o=new URL(n,location.href),a=o.host!==location.host;d({event_type:a?"outbound_click":"internal_click",path:s||location.pathname,meta:{href:o.href}})}catch{}}function y(){document.visibilityState==="hidden"&&(h(),d({event_type:"session_end",path:s||location.pathname}),u(!0),l=Date.now(),i=0)}function I(){S||typeof window>"u"||(S=!0,m(location.pathname+location.search),c=setInterval(()=>u(!1),5e3),window.addEventListener("scroll",E,{passive:!0}),document.addEventListener("click",v,{capture:!0}),document.addEventListener("visibilitychange",y),window.addEventListener("pagehide",()=>{h(),u(!0)}))}function b(t){m(t)}function A(){c&&clearInterval(c),c=null,S=!1}export{I as startPulse,A as stopPulse,b as trackRouteChange};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.