PageSourceSearch

https://thenewthings.com/assets/useNectarClickTracking-Dbw5JvAL.js

js thenewthings.com collected 2026-10-02 10:06:56 UTC 13,009 bytes, 5 lines download raw bytes

1
2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="2ec0c254-1ed0-5454-9acb-9f044986c83d")}catch(e){}}();
3import{a as e,n as t,s as n}from"./jsx-runtime-D4ePz0Hl.js";import{t as r}from"./react-BXH-GOAS.js";import{D as i}from"./components-CDo3yjgw.js";import{n as a}from"./exports-mk284NM-.js";import{t as o}from"./utils-CjUr88hv.js";import{B as s,I as c,L as l,R as u}from"./QueryClientProvider-Cdu2unP4.js";import{t as d}from"./useNonRevalidatingFetcher-CaohiMMR.js";import{t as f}from"./useNectarAnalyticsContext-DNygHzdW.js";import{n as p}from"./nectarPageBlock-Dhr05eLZ.js";var m=n(r(),1),h=()=>{try{let e=o(),t=e?.SENTRY_ENV;return!t||t===`production`?!1:e?.VITE_SHOW_NECTAR_CONSOLE===`true`}catch{return!1}},g=200,_=[],v=0,y=new Set,b=()=>{for(let e of y)e()},x=e=>{if(e.length===0)return;let t=Date.now(),n=`batch_${v++}`;_=[...e.map(e=>({loggedAt:t,batchId:n,event:e})).reverse(),..._].slice(0,g),b()},S=e=>(y.add(e),()=>{y.delete(e)}),C=()=>_,w=()=>{_.length!==0&&(_=[],b())},T=t(((e,t)=>{t.exports={}})),E=t(((t,n)=>{(function(e,r){typeof t==`object`?n.exports=t=r():typeof define==`function`&&define.amd?define([],r):e.CryptoJS=r()})(t,function(){var t=t||function(t,n){var r;if(typeof window<`u`&&window.crypto&&(r=window.crypto),typeof self<`u`&&self.crypto&&(r=self.crypto),typeof globalThis<`u`&&globalThis.crypto&&(r=globalThis.crypto),!r&&typeof window<`u`&&window.msCrypto&&(r=window.msCrypto),!r&&typeof global<`u`&&global.crypto&&(r=global.crypto),!r&&typeof e==`function`)try{r=T()}catch{}var i=function(){if(r){if(typeof r.getRandomValues==`function`)try{return r.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof r.randomBytes==`function`)try{return r.randomBytes(4).readInt32LE()}catch{}}throw Error(`Native crypto module could not be used to get secure random number.`)},a=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),o={},s=o.lib={},c=s.Base=function(){return{extend:function(e){var t=a(this);return e&&t.mixIn(e),(!t.hasOwnProperty(`init`)||this.init===t.init)&&(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty(`toString`)&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),l=s.WordArray=c.extend({init:function(e,t){e=this.words=e||[],t==n?this.sigBytes=e.length*4:this.sigBytes=t},toString:function(e){return(e||d).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,i=e.sigBytes;if(this.clamp(),r%4)for(var a=0;a<i;a++){var o=n[a>>>2]>>>24-a%4*8&255;t[r+a>>>2]|=o<<24-(r+a)%4*8}else for(var s=0;s<i;s+=4)t[r+s>>>2]=n[s>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,n=this.sigBytes;e[n>>>2]&=4294967295<<32-n%4*8,e.length=t.ceil(n/4)},clone:function(){var e=c.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n<e;n+=4)t.push(i());return new l.init(t,e)}}),u=o.enc={},d=u.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var a=t[i>>>2]>>>24-i%4*8&255;r.push((a>>>4).toString(16)),r.push((a&15).toString(16))}return r.join(``)},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new l.init(n,t/2)}},f=u.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var a=t[i>>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(a))}return r.join(``)},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(e.charCodeAt(r)&255)<<24-r%4*8;return new l.init(n,t)}},p=u.Utf8={stringify:function(e){try{return decodeURIComponent(escape(f.stringify(e)))}catch{throw Error(`Malformed UTF-8 data`)}},parse:function(e){return f.parse(unescape(encodeURIComponent(e)))}},m=s.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new l.init,this._nDataBytes=0},_append:function(e){typeof e==`string`&&(e=p.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var n,r=this._data,i=r.words,a=r.sigBytes,o=this.blockSize,s=a/(o*4);s=e?t.ceil(s):t.max((s|0)-this._minBufferSize,0);var c=s*o,u=t.min(c*4,a);if(c){for(var d=0;d<c;d+=o)this._doProcessBlock(i,d);n=i.splice(0,c),r.sigBytes-=u}return new l.init(n,u)},clone:function(){var e=c.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});s.Hasher=m.extend({cfg:c.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){m.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:512/32,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new h.HMAC.init(e,n).finalize(t)}}});var h=o.algo={};return o}(Math);return t})})),D=n(t(((e,t)=>{(function(n,r){typeof e==`object`?t.exports=e=r(E()):typeof define==`function`&&define.amd?define([`./core`],r):r(n.CryptoJS)})(e,function(e){return(function(t){var n=e,r=n.lib,i=r.WordArray,a=r.Hasher,o=n.algo,s=[],c=[];(function(){function e(e){for(var n=t.sqrt(e),r=2;r<=n;r++)if(!(e%r))return!1;return!0}function n(e){return(e-(e|0))*4294967296|0}for(var r=2,i=0;i<64;)e(r)&&(i<8&&(s[i]=n(t.pow(r,1/2))),c[i]=n(t.pow(r,1/3)),i++),r++})();var l=[],u=o.SHA256=a.extend({_doReset:function(){this._hash=new i.init(s.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],u=n[5],d=n[6],f=n[7],p=0;p<64;p++){if(p<16)l[p]=e[t+p]|0;else{var m=l[p-15],h=(m<<25|m>>>7)^(m<<14|m>>>18)^m>>>3,g=l[p-2],_=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;l[p]=h+l[p-7]+_+l[p-16]}var v=s&u^~s&d,y=r&i^r&a^i&a,b=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),x=(s<<26|s>>>6)^(s<<21|s>>>11)^(s<<7|s>>>25),S=f+x+v+c[p]+l[p],C=b+y;f=d,d=u,u=s,s=o+S|0,o=a,a=i,i=r,r=S+C|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+a|0,n[3]=n[3]+o|0,n[4]=n[4]+s|0,n[5]=n[5]+u|0,n[6]=n[6]+d|0,n[7]=n[7]+f|0},_doFinalize:function(){var e=this._data,n=e.words,r=this._nDataBytes*8,i=e.sigBytes*8;return n[i>>>5]|=128<<24-i%32,n[(i+64>>>9<<4)+14]=t.floor(r/4294967296),n[(i+64>>>9<<4)+15]=r,e.sigBytes=n.length*4,this._process(),this._hash},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}});n.SHA256=a._createHelper(u),n.HmacSHA256=a._createHmacHelper(u)})(Math),e.SHA256})}
3))(),1),O=class extends Error{};function k(e){if(!e||typeof e!=`string`)throw new O(`Invalid input: must be a non-empty string`);try{return(0,D.default)(e.trim()).toString()}catch(t){throw a(t,{extra:{input_length:e.length,input_preview:e.substring(0,100)}}),new O(`Failed to hash input`)}}var A=`visitTokenReady`,j=({shouldCreateVisitToken:e,setCookie:t})=>{let[n]=i(),r=d(),a=r.data;(0,m.useEffect)(()=>{if(e){let e=document.referrer,t=new FormData;t.append(`referrer`,e),t.append(`landing_page`,window.location.href);let i=`/visit_token`+(n.toString()?`?${n.toString()}`:``);r.submit(t,{method:`post`,action:i})}},[e]),(0,m.useEffect)(()=>{a?.visitToken&&e&&(t({name:`visit_token`,value:a?.visitToken,minutes:30}),typeof window<`u`&&window.dispatchEvent(new CustomEvent(A)))},[a])},M=e=>{if(e)try{return k(e.toLowerCase())}catch{return}},N=e=>{try{let t=new URL(e);return t.searchParams.has(`jwt_token`)&&t.searchParams.set(`jwt_token`,`REDACTED`),t.toString()}catch{return e}},P=function(e){return e.PAGEVIEW=`pageview`,e.CLICK=`click`,e.IMPRESSION=`impression`,e.SEARCH=`search`,e.ONBOARDING_COMPLETED=`onboarding_completed`,e}({}),F=({nectarId:e,enabled:t,publicationId:n,siteId:r,postId:i,communityId:a,communitySpaceId:o,subscriptionId:f,email:p,settings:g})=>{let _=(0,m.useRef)(``),v=(0,m.useRef)([]),y=(0,m.useRef)([]),b=(0,m.useRef)(null),S=(0,m.useRef)(!1),C=d(),w=(0,m.useCallback)(()=>c()||null,[]),T=(0,m.useCallback)(e=>{h()&&x(e),C.submit(JSON.stringify({events:e,settings:g}),{method:`post`,action:`/nectar_analytics`,encType:`application/json`})},[C,g]),E=(0,m.useCallback)(()=>{if(S.current||v.current.length===0)return;S.current=!0;let e=v.current.splice(0,g.batchSize);if(e.length===0){S.current=!1;return}T(e),S.current=!1,v.current.length>0&&(b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{E()},g.batchTimeoutMs))},[g.batchSize,g.batchTimeoutMs,T]),D=(0,m.useCallback)(()=>{b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{E()},g.batchTimeoutMs)},[E,g.batchTimeoutMs]),O=(0,m.useCallback)(()=>{b.current&&=(clearTimeout(b.current),null),E()},[E]),k=(0,m.useCallback)(e=>{v.current.push(e),v.current.length>=g.batchSize?(b.current&&=(clearTimeout(b.current),null),E()):D()},[E,D,g.batchSize]),j=(0,m.useCallback)(()=>{if(y.current.length===0)return;let e=w();e&&y.current.splice(0).forEach(t=>{t.visit_token=e,k(t)})},[w,k]),P=(0,m.useCallback)(t=>({user_agent:navigator.userAgent,url:N(window.location.href),event:t.event_type,client_timestamp:Date.now(),event_id:s(),nectar_id:e,publication_id:n,site_id:r,visit_token:w()||``,ip:``,store_ip:g.ipTracking,url_referrer:document.referrer||void 0,sendable_id:t.sendable_id??i,sendable_type:t.sendable_type??(i?`post`:void 0),community_id:a,community_space_id:t.community_space_id??o,subscription_id:f,email_hash_sha256:M(p),anonymous_user_id:l(),click_type:t.click_type,click_url:t.click_url,click_raw_tag_name:t.click_raw_tag_name,page_block:t.page_block??``,is_pwa:u()}),[w,e,n,r,g.ipTracking,i,a,o,f,p]),F=(0,m.useCallback)(e=>{y.current.push(e)},[]),I=(0,m.useCallback)(()=>{if(!g.pageViewTracking)return;let e=window.location.href;if(e===_.current)return;_.current=e;let t=P({event_type:`pageview`});t.visit_token?k(t):F(t)},[P,k,g.pageViewTracking,F]),L=(0,m.useCallback)(({clickType:e,clickUrl:t,clickRawTagName:n,pageBlock:r})=>{if(!g.clickTracking)return;let i=P({event_type:`click`,click_type:e,click_url:t,click_raw_tag_name:n,page_block:r});i.visit_token?k(i):F(i)},[P,k,g.clickTracking,F]),R=(0,m.useCallback)(({sendableId:e,sendableType:t,pageBlock:n,communitySpaceId:r})=>{let i=P({event_type:`impression`,sendable_id:e,sendable_type:t,page_block:n,community_space_id:r});i.visit_token?k(i):F(i)},[P,k,F]);return(0,m.useEffect)(()=>{let e=()=>{j()};return window.addEventListener(A,e),()=>{window.removeEventListener(A,e)}},[j]),(0,m.useEffect)(()=>()=>{b.current&&clearTimeout(b.current)},[]),(0,m.useEffect)(()=>{let e=()=>{O()};return window.addEventListener(`beforeunload`,e),()=>{window.removeEventListener(`beforeunload`,e)}},[O]),t?{trackPageView:I,trackClick:L,trackImpression:R}:{trackPageView:()=>{},trackClick:()=>{},trackImpression:()=>{}}},I=e=>{let t=e.tagName.toLowerCase();if(t===`input`){let t=e.getAttribute(`type`);
3return t===`submit`?`submit`:t===`button`?`button`:t===`checkbox`?`checkbox`:t===`radio`?`radio`:`input`}if(t===`a`){let t=e.getAttribute(`href`);if(t){if(t.startsWith(`mailto:`))return`email`;if(t.startsWith(`tel:`))return`phone`}return`link`}let n=e.closest(`a`);if(n){let e=n.getAttribute(`href`);if(e){if(e.startsWith(`mailto:`))return`email`;if(e.startsWith(`tel:`))return`phone`}return`link`}return t===`button`?`button`:t===`select`?`select`:t===`textarea`||t===`label`?`input`:t===`summary`?`summary`:t===`img`?`img`:t===`span`?`span`:t===`svg`?`svg`:t===`p`?`p`:t===`h1`?`h1`:t===`h2`?`h2`:t===`h3`?`h3`:t===`h4`?`h4`:t===`h5`?`h5`:t===`h6`?`h6`:t===`div`?`div`:t===`section`?`section`:t===`article`?`article`:t===`header`?`header`:t===`footer`?`footer`:t===`nav`?`nav`:t===`main`?`main`:t===`aside`?`aside`:t===`body`?`body`:t===`form`?`form`:t===`fieldset`?`fieldset`:t===`legend`?`legend`:t===`ul`?`ul`:t===`ol`?`ol`:t===`li`?`li`:t===`table`?`table`:t===`tr`?`tr`:t===`td`?`td`:t===`th`?`th`:t===`body`?`body`:t===`html`?`html`:t===`u`?`u`:t===`strong`?`strong`:t===`b`?`b`:t===`em`?`em`:t===`i`?`i`:t===`path`?`path`:`unknown`},L=(e,t)=>{let n=e.getAttribute(t);if(n){if(n.startsWith(`/`))return window.location.origin+n;if(n.startsWith(`#`))return window.location.href+n;if(n.startsWith(`http`))return n}},R=e=>{if(e.tagName.toLowerCase()===`a`)return L(e,`href`);let t=e.closest(`a`);if(t)return L(t,`href`);if(e.tagName.toLowerCase()===`form`)return L(e,`action`)},z=`data-nectar-no-track`,B=()=>{let e=f(),t=(0,m.useCallback)(t=>{let n=t.target;if(!n||n.closest(`[data-nectar-no-track]`))return;let r=I(n),i=R(n),a=n.tagName.toLowerCase(),o=p(n);e.trackClick({clickType:r,clickUrl:i,clickRawTagName:a,pageBlock:o})},[e]);(0,m.useEffect)(()=>(document.addEventListener(`click`,t,!0),()=>{document.removeEventListener(`click`,t,!0)}),[t])};export{j as a,S as c,F as i,h as l,B as n,w as o,P as r,C as s,z as t};
4//# sourceMappingURL=useNectarClickTracking-Dbw5JvAL.js.map
5//# debugId=2ec0c254-1ed0-5454-9acb-9f044986c83d

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.