PageSourceSearch

https://assets.dev.to/assets/feedEvents-d39d56b2a9cd948da5eab41780a494c61da2d5674fd5d8115179eda001632f45.js

js dev.to collected 2026-10-01 07:09:14 UTC 3,344 bytes, 1 lines download raw bytes

1(()=>{function e(){let e=document.getElementById("index-container"),i=document.getElementById("rendered-article-feed");if(!e||!i)return;let{feedCategoryClick:s,feedCategoryImpression:n,feedContextType:o,feedConfigId:r}=e.dataset;window.mainFeedTracker||(window.mainFeedTracker=new t({feedItemsRoot:i,config:{categoryClick:s,categoryImpression:n,contextType:o,feedConfigId:r},contentIdAttribute:"feedContentId"})),window.mainFeedTracker.init()}var t=class{constructor({feedItemsRoot:e,config:t,contentIdAttribute:i="feedContentId"}){e&&t?(this.feedItemsRoot=e,this.config=t,this.contentIdAttribute=i,this.queue=[],this.processInterval=null,this.beaconEnabled=!0,this.nextFeedPosition=1,this.trackFeedImpressions=this.trackFeedImpressions.bind(this),this.trackFeedClickListener=this.trackFeedClickListener.bind(this),this.submitEventsBatch=this.submitEventsBatch.bind(this),this.observer=new IntersectionObserver(this.trackFeedImpressions,{root:null,rootMargin:"0px",threshold:.25})):console.error("FeedTracker: Missing required constructor options.")}init(){this.processInterval||(this.processInterval=setInterval(this.submitEventsBatch,5e3)),this.observer.disconnect(),this.nextFeedPosition=1,this.findAndTrackFeedItems(this.feedItemsRoot),this.ensureQueueIsClearedBeforeExit()}findAndTrackFeedItems(e){Array.from(e.children).forEach((e=>{var t;e.classList.contains("paged-stories")?this.findAndTrackFeedItems(e):null!=(t=e.dataset)&&t[this.contentIdAttribute]&&(e.dataset.feedContentId=e.dataset[this.contentIdAttribute],e.dataset.feedPosition=this.nextFeedPosition,e.addEventListener("mousedown",this.trackFeedClickListener,!0),this.observer.observe(e),this.nextFeedPosition+=1)}))}ensureQueueIsClearedBeforeExit(){this.exitListenersAttached||(document.addEventListener("visibilitychange",(()=>{"hidden"==document.visibilityState&&this.submitEventsBatch()})),window.addEventListener("beforeunload",this.submitEventsBatch),this.exitListenersAttached=!0)}trackFeedImpressions(e){e.forEach((e=>{e.isIntersecting&&e.intersectionRatio>=.25&&queueMicrotask((()=>{let t=e.target;t.dataset.impressionRecorded||(this.queueEvent(t,this.config.categoryImpression),t.dataset.impressionRecorded="true")}))}))}trackFeedClickListener(e){let t=e.currentTarget;t.dataset.clickRecorded||(this.queueEvent(t,this.config.categoryClick),t.dataset.clickRecorded="true",this.submitEventsBatch())}queueEvent(e,t){let{feedContentId:i,feedPosition:s}=e.dataset;this.queue.push({article_id:i,article_position:s,category:t,feed_config_id:this.config.feedConfigId,context_type:this.config.contextType}),this.queue.length>=20&&this.submitEventsBatch()}submitEventsBatch(){if(0===this.queue.length)return;let e=document.querySelector("meta[name='csrf-token']"),t=null==e?void 0:e.getAttribute("content"),i=[...this.queue];this.queue=[];let s={authenticity_token:t,feed_events:i};if(this.beaconEnabled&&navigator.sendBeacon){let e=new Blob([JSON.stringify(s)],{type:"application/json"});navigator.sendBeacon("/feed_events",e)||(this.beaconEnabled=!1,this.fallbackRequest(t,i))}else this.fallbackRequest(t,i)}fallbackRequest(e,t){window.fetch("/feed_events",{method:"POST",headers:{"X-CSRF-Token":e,"Content-Type":"application/json"},body:JSON.stringify({feed_events:t}),credentials:"same-origin",keepalive:!0}).catch((e=>console.error(e)))}};window.observeFeedElements=e})();

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.