PageSourceSearch

https://snew.ai/assets/productFunnelPersistence-vjQb8r4K.js

js snew.ai collected 2026-10-05 15:07:15 UTC 2,166 bytes, 1 lines download raw bytes

1import{s as p,P as v}from"./productFunnel-DiJFcMU2.js";import"./index-L9AYrVUw.js";const m="snew_funnel_outbox_v1",_=100,g=160,N=new Set(v),b=new Set(["funnel","language","acquisition_source","acquisition_plan","acquisition_cycle","step","reason","completion_path","intent","generation_count","welcome_credit_budget","credit_source","source_kind","generated_count","failed_count","outcome","plan","cycle","surface","elapsed_seconds"]);function h(){try{return window.localStorage}catch{return null}}function l(t){return`${m}:${t}`}function w(t,e){try{const n=JSON.parse(t.getItem(l(e))??"[]");return Array.isArray(n)?n.slice(-_):[]}catch{return[]}}function y(t,e,n){try{n.length===0?t.removeItem(l(e)):t.setItem(l(e),JSON.stringify(n.slice(-_)))}catch{}}function E(t,e=crypto.randomUUID()){const n=typeof t.event=="string"?t.event:"",o=n.startsWith("snew_")?n.slice(5):n;if(!N.has(o))return null;const r={};for(const[i,s]of Object.entries(t))b.has(i)&&(s===null||typeof s=="number"||typeof s=="boolean"?r[i]=s:typeof s=="string"&&!s.includes("@")&&(r[i]=s.slice(0,g)));return{id:e,eventName:o,properties:r}}let d=!1,c=Promise.resolve();const u=new Set;async function a(){var e;const{data:t}=await p.auth.getSession();return((e=t.session)==null?void 0:e.user.id)??null}async function f(t){if(u.has(t))return;const e=h();if(e){u.add(t);try{const n=w(e,t);for(;n.length>0;){if(await a()!==t)return;const r=n[0],{error:i}=await p.rpc("record_product_funnel_event",{p_event_id:r.id,p_event_name:r.eventName,p_properties:r.properties});if(i)return;n.shift(),y(e,t,n)}}catch{}finally{u.delete(t)}}}async function O(t){const e=E(t);if(!e)return;const n=await a();if(!n)return;const o=h();if(!o)return;const r=w(o,n);r.some(i=>i.id===e.id)||r.push(e),y(o,n,r),await f(n)}function P(t=window){d||(d=!0,t.addEventListener("snew:product-funnel",e=>{const n=e.detail;!n||typeof n!="object"||(c=c.then(()=>O(n)).catch(()=>{}))}),t.addEventListener("online",()=>{c=c.then(async()=>{const e=await a();e&&await f(e)}).catch(()=>{})}),c=c.then(async()=>{const e=await a();e&&await f(e)}).catch(()=>{}))}export{P as installProductFunnelPersistence,E as productFunnelRecordFromPayload};

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.