1"use strict";(self.webpackChunk_automattic_woocommerce_analytics=self.webpackChunk_automattic_woocommerce_analytics||[]).push([[193],{19(e,i,t){t.d(i,{j:()=>h});var n=t(941),s=t.n(n),o=t(339),a=t(269),r=t(338),d=t(382);const c=s()("wc-analytics:analytics");class h{constructor(e,{eventQueue:i=[],commonProps:t={},features:n={},pages:s={}}){this.isInitialized=!1,this.sessionManager=e,this.apiClient=new o.O,this.eventQueue=i,this.commonProps=t,this.features=n,this.pages=s}init=()=>{if(!this.isInitialized){if(this.features.proxy&&this.apiClient.init(),this.features.sessionTracking){a.K.addConsentChangeListener(this.handleConsentChange),this.sessionManager.init();const{sessionId:e,landingPage:i,isNewSession:t}=this.sessionManager;this.features.proxy||(this.commonProps={...this.commonProps,session_id:e,landing_page:i}),t?this.maybeRecordSessionStartedEvent():this.maybeRecordEngagementEvent(),this.recordEvent("page_view")}this.maybeSetAnonId(),this.processEventQueue(),this.initListeners(),this.isInitialized=!0}};initListeners=()=>{this.pages.isAccountPage&&t.e(686).then(t.bind(t,358)).then(({initListeners:e})=>{e(this.recordEvent)})};processEventQueue=()=>{for(const e of this.eventQueue)this.recordEvent(e.eventName,e.props)};recordEvent=(e,i={})=>{if(!a.K.hasAnalyticsConsent())return void c("Skipping event recording due to lack of statistics consent: %s",e);if("string"!=typeof e||!r.bm.test(e))return void c("Skipping event recording because event name is not valid");const t={...this.commonProps,...i};this.features.ch?t.ch=1:delete t.ch,this.features.proxy?(this.addClientProperties(t),this.apiClient.addEvent(e,t)):this.fireDirectPixel(e,t),this.isInitialized&&this.maybeRecordEngagementEvent()};fireDirectPixel=(e,i)=>{window._wca?(c('Recording event via _wca: "%s" with props %o',e,i),i._en=`${r.CS}${e}`,window._wca.push(i)):c("Skipping event recording because _wca is not defined")};addClientProperties=e=>{const i=new Date;e._ts=i.getTime(),e._tz=i.getTimezoneOffset()/60;const t=window.navigator,n=window.screen;e._lg=t.language,e._pf=navigator?.platform,e._ht=n.height,e._wd=n.width;const s=void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body).scrollLeft,o=void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body).scrollTop;e._sx=void 0!==s?s:0,e._sy=void 0!==o?o:0,void 0!==document.location&&(e._dl=document.location.toString()),void 0!==document.referrer&&(e._dr=document.referrer)};maybeRecordSessionStartedEvent=()=>{this.features.sessionTracking&&this.sessionManager.isNewSession&&this.sessionManager.sessionId&&this.recordEvent("session_started")};maybeRecordEngagementEvent=()=>{this.features.sessionTracking&&!this.sessionManager.isEngaged&&this.sessionManager.sessionId&&(this.sessionManager.setEngaged(),this.recordEvent("session_engagement"))};handleConsentChange=e=>{e?this.sessionManager.sessionId||this.sessionManager.init():this.sessionManager.clearSession()};maybeSetAnonId(){if(!(0,d.R)("tk_ai")){const e=(0,d.I)(18),i=new Date(Date.now()+31536e6).toUTCString();document.cookie=`tk_ai=${e}; path=/; secure; samesite=strict; expires=${i}`}}}},339(e,i,t){t.d(i,{O:()=>r});var n=t(941),s=t.n(n),o=t(338);const a=s()("wc-analytics:api-client");class r{eventQueue=[];debounceTimer=null;isInitialized=!1;init=()=>{this.isInitialized||(a("API client initialized"),window.addEventListener("beforeunload",this.flush),window.addEventListener("pagehide",this.flush),this.isInitialized=!0)};addEvent=(e,i={})=>{if(!this.isInitialized)return void a("API client not initialized, skipping event: %s",e);a('Recording event via API: "%s" with props %o',e,i);const t={event_name:e,properties:i};this.eventQueue.push(t),a("Event added to queue: %s (queue size: %d)",e,this.eventQueue.length),this.debouncedSend(),this.eventQueue.length>=o.BU&&this.flush()};debouncedSend=()=>{this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=window.setTimeout(()=>{this.flush()},o.Op)};sendEventsViaBeacon=e=>{if("undefined"==typeof navigator||!navigator.sendBeacon)return a("Beacon API not available"),!1;try{const i=JSON.stringify(e),t=new Blob([i],{type:"application/json"});return navigator.sendBeacon(window.wcAnalytics.trackEndpoint,t)}catch(e){return a("Beacon API failed: %o",e),!1}};flush=()=>
1{if(this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),0===this.eventQueue.length)return;const e=[...this.eventQueue];if(this.eventQueue=[],!window.wcAnalytics?.trackEndpoint)return void a("Track endpoint not available");this.sendEventsViaBeacon(e)?a("Sent %d events via Beacon API",e.length):(a("Failed to send events via Beacon API, falling back to fetch with keepalive"),this.sendEvents(e))};sendEvents=async e=>{if(0!==e.length)try{a("Sending %d events to API",e.length);const i=await fetch(window.wcAnalytics.trackEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),keepalive:!0,credentials:"same-origin"});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);const t=await i.json();a("API response received: %o",t)}catch(i){a("Failed to send events to API: %o",i),this.eventQueue.unshift(...e)}}}},338(e,i,t){t.d(i,{BU:()=>a,CS:()=>s,Op:()=>r,bm:()=>o,z4:()=>n});const n="woocommerceanalytics_session",s="woocommerceanalytics_",o=/^[a-z_][a-z0-9_]*$/,a=10,r=1e3},633(e,i,t){t.r(i);var n=t(19),s=t(841);!function(){const e=new s.A;new n.j(e,{eventQueue:window.wcAnalytics.eventQueue,commonProps:window.wcAnalytics.commonProps,features:window.wcAnalytics.features,pages:window.wcAnalytics.pages}).init()}()},841(e,i,t){t.d(i,{A:()=>o});var n=t(338),s=t(382);class o{sessionId=null;landingPage=null;isEngaged=!1;isNewSession=!1;isInitialized=!1;init=()=>{this.isInitialized||(this.loadOrCreateSession(),this.isInitialized=!0)};loadOrCreateSession(){const e=this.getSessionCookie();e&&e.session_id?(this.sessionId=e.session_id,this.landingPage=e.landing_page||null,this.isEngaged=e.is_engaged||!1,this.isNewSession=!1):this.createNewSession()}createNewSession(){this.isNewSession=!0;const e={session_id:this.generateRandomUuid(),landing_page:JSON.stringify(window.wcAnalytics?.breadcrumbs||[]),expires:this.getSessionExpirationTime()};this.setSessionCookie(e)&&(this.sessionId=e.session_id,this.landingPage=e.landing_page,this.isEngaged=!1)}getSessionCookie(){const e=(0,s.R)(n.z4);if(!e)return null;try{return JSON.parse(decodeURIComponent(e))}catch(e){return console.error("Error parsing session cookie",e),null}}setSessionCookie(e){const i=encodeURIComponent(JSON.stringify(e)),t=e.expires||this.getSessionExpirationTime();document.cookie=`${n.z4}=${i}; expires=${t}; path=/; secure; samesite=strict`;return(0,s.R)(n.z4)===i}getSessionExpirationTime(){const e=Date.now()+18e5,i=new Date;i.setUTCDate(i.getUTCDate()+1),i.setUTCHours(0,0,0,0);const t=Math.min(e,i.getTime());return new Date(t).toUTCString()}generateRandomUuid(){if("undefined"!=typeof crypto&&crypto.randomUUID)return crypto.randomUUID();if("undefined"!=typeof crypto&&crypto.getRandomValues){const e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=15&e[6]|64,e[8]=63&e[8]|128;const i=Array.from(e,e=>e.toString(16).padStart(2,"0")).join("");return[i.slice(0,8),i.slice(8,12),i.slice(12,16),i.slice(16,20),i.slice(20,32)].join("-")}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const i=Math.floor(16*Math.random());return("x"===e?i:i%4+8).toString(16)})}setEngaged(){if(this.isEngaged)return;const e=this.getSessionCookie();e&&e.session_id&&(e.is_engaged=!0,this.setSessionCookie(e)),this.isEngaged=!0}clearSession(){document.cookie=`${n.z4}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; secure; samesite=strict`,this.sessionId=null,this.landingPage=null,this.isEngaged=!1,this.isNewSession=!1,this.isInitialized=!1}}},382(e,i,t){function n(e){const i=`; ${document.cookie}`.split(`; ${e}=`);return 2===i.length&&i.pop()?.split(";").shift()||null}function s(e){let i;if(window.crypto&&window.crypto.getRandomValues)i=new Uint8Array(e),window.crypto.getRandomValues(i);else for(let t=0;t<e;++t)i[t]=Math.floor(256*Math.random());return btoa(String.fromCharCode(...i))}t.d(i,{I:()=>s,R:()=>n})}}]);
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.