PageSourceSearch

https://www.theadvocates.org/build/assets/ArticleVisitTracker-DvSUaOKA.js

js theadvocates.org collected 2026-10-01 11:30:39 UTC 3,188 bytes, 1 lines download raw bytes

1import{useArticleVisit as M}from"./useArticleVisit-DGKo6Lxl.js";import{A,a as C,b as R}from"./articleInteractionEvents-CHQ6JXLz.js";import{p as V}from"./conversionTracking-3YzUHqND.js";import{defineComponent as q,onMounted as x,onUnmounted as z}from"./vue-vendor-Dr0siaL3.js";import"./useFingerprint-zDihWUUI.js";import"./fingerprintInterceptor-BqKHgKKR.js";import"./useUtmTracking-ByyU_yzE.js";const F="asg_last_article",H=q({__name:"ArticleVisitTracker",props:{postId:{},slug:{}},setup(y){const i=y,{trackArticleVisit:a,calculateScrollDepth:B}=M(),s=Date.now();let c=null,E=0,n=0,l=!1,d=null,u=!1,b=!1;const v=new Set;function f(){if(!d)return;const t=B(d);t>n&&(n=t);const e=d.getBoundingClientRect(),o=window.scrollY+e.bottom,m=window.scrollY+window.innerHeight;o<=m+10&&(l=!0)}function p(){const t={max_scroll_depth_percent:n};return(l||n>=100)&&(t.reached_bottom=!0),t}function g(){f();const t=Math.floor((Date.now()-s)/1e3);a(i.postId,t,n,{},p()).catch(()=>{}),h(t),E=t}function h(t){b||!l&&(t<30||n<50)||(b=!0,V("article_read",{article_id:i.postId,time_spent_seconds:t,scroll_depth_percent:Math.round(n),reached_bottom:l},i.postId))}function r(t,e={}){if(v.has(t))return;v.add(t),f();const o=Math.floor((Date.now()-s)/1e3);h(o),a(i.postId,o,n,{last_interaction:t,...e},{...p(),[t]:!0},{withFingerprint:!1}).catch(()=>{})}function N(t){let e;try{e=new URL(t.href,window.location.origin)}catch{return!1}return e.origin===window.location.origin&&/^\/quiz\/?$/.test(e.pathname)}function I(t){const e=t.target;if(!e)return;const o=e.closest("a[href]");if(o&&N(o)){r("quiz_clicked",{action:"quiz_link_click",href:o.getAttribute("href")});return}const m=e.closest("button[aria-label]");if(!m)return;const w=(m.getAttribute("aria-label")||"").toLowerCase();w.startsWith("share on facebook")?r("facebook_shared",{platform:"facebook"}):w.startsWith("share on twitter")?r("twitter_shared",{platform:"twitter"}):w==="copy link"&&r("link_copied",{platform:"copy"})}const L=()=>r("rating_submitted",{action:"submit"}),S=()=>r("signup_clicked",{action:"signup_button_click"}),k=()=>r("newsletter_subscribed",{action:"form_submit"});function U(){try{sessionStorage.setItem(F,JSON.stringify({id:i.postId,slug:i.slug??null,at:Date.now()}))}catch{}}function _(){if(u)return;u=!0,f();const t=Math.floor((Date.now()-s)/1e3);h(t),(t>0||n>0)&&a(i.postId,t,n,{},p()).catch(()=>{})}const T=()=>{document.visibilityState==="hidden"&&_()},D=()=>{_()};return x(()=>{d=document.querySelector(`article[data-article-id="${i.postId}"]`),U(),a(i.postId).catch(()=>{}),setTimeout(()=>{u||g()},1e3),c=setInterval(()=>{if(u)return;f(),Math.floor((Date.now()-s)/1e3)-E>=10&&g()},2e3),document.addEventListener("click",I,!0),window.addEventListener(A,L),window.addEventListener(C,S),window.addEventListener(R,k),document.addEventListener("visibilitychange",T),window.addEventListener("beforeunload",D)}),z(()=>{c&&(clearInterval(c),c=null),document.removeEventListener("click",I,!0),window.removeEventListener(A,L),window.removeEventListener(C,S),window.removeEventListener(R,k),document.removeEventListener("visibilitychange",T),window.removeEventListener("beforeunload",D),_()}),(t,e)=>null}});export{H as default};

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.