veo-sdk 0.3.0 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builder-VPQDAUIL.mjs +5 -0
- package/dist/{builder-UEGKG2UR.mjs.map → builder-VPQDAUIL.mjs.map} +1 -1
- package/dist/builder.cjs +166 -34
- package/dist/builder.cjs.map +1 -1
- package/dist/builder.d.cts +23 -5
- package/dist/builder.d.ts +23 -5
- package/dist/builder.mjs +5 -5
- package/dist/{chunk-CI7NWEH2.mjs → chunk-GHP7ZJCW.mjs} +21 -26
- package/dist/chunk-GHP7ZJCW.mjs.map +1 -0
- package/dist/{chunk-66UQ474G.mjs → chunk-PASI5SAK.mjs} +153 -16
- package/dist/chunk-PASI5SAK.mjs.map +1 -0
- package/dist/chunk-PTG3BTJE.mjs +10 -0
- package/dist/chunk-PTG3BTJE.mjs.map +1 -0
- package/dist/{chunk-G5CKTGEG.mjs → chunk-R4E3LIDB.mjs} +3 -3
- package/dist/{chunk-G5CKTGEG.mjs.map → chunk-R4E3LIDB.mjs.map} +1 -1
- package/dist/index.cjs +178 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/next.cjs.map +1 -1
- package/dist/next.mjs +1 -1
- package/dist/veo-builder.js +36 -3
- package/dist/veo-builder.js.map +1 -1
- package/dist/veo.js +2 -2
- package/dist/veo.js.map +1 -1
- package/package.json +1 -1
- package/dist/builder-UEGKG2UR.mjs +0 -5
- package/dist/chunk-66UQ474G.mjs.map +0 -1
- package/dist/chunk-CI7NWEH2.mjs.map +0 -1
- package/dist/chunk-JIU5JLI3.mjs +0 -7
- package/dist/chunk-JIU5JLI3.mjs.map +0 -1
package/dist/veo.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var veo=(function(exports){'use strict';var x="0.0.1";var D="https://veo-backend-production-8c78.up.railway.app";function g(r){let e=r?.apiUrl;if(typeof e=="string"&&e.trim())return e;let t=globalThis.__VEO_API_URL__;return typeof t=="string"&&t.trim()?t:D}function u(){return typeof window<"u"}function l(){return typeof document<"u"}function P(){try{if(typeof localStorage>"u")return !1;let r="__veo_test__";return localStorage.setItem(r,"1"),localStorage.removeItem(r),!0}catch{return false}}function z(){return typeof navigator<"u"&&typeof navigator.sendBeacon=="function"}var G="veoBuilder",K="veoBuilderOrigin";var H="veo:builder_token",fe="veo:builder_origin";function q(){try{return window.sessionStorage}catch{return null}}function me(){try{return new URLSearchParams(window.location.search)}catch{return null}}function U(){if(!u())return null;let r=me(),e=r?.get(G);if(e){let t=q();try{t?.setItem(H,e);let n=r?.get(K);n&&t?.setItem(fe,n);}catch{}return e}try{return q()?.getItem(H)??null}catch{return null}}function R(){return U()!==null}function F(r){if(!u()||!l()||U()===null||(r.apiKey&&r.apiUrl&&(window.__veoBuilder={apiKey:r.apiKey,apiUrl:r.apiUrl}),window.veoBuilder))return;let e=r.builderUrl??he();if(e){if(document.querySelector(`script[src="${e}"]`))return;let t=document.createElement("script");t.src=e,t.async=true,r.debug&&t.addEventListener("error",()=>console.error("[veo] no pude cargar",e)),document.head.appendChild(t);return}if(r.loadBuilder){r.loadBuilder().catch(t=>{r.debug&&console.error("[veo] no pude cargar el builder (import din\xE1mico)",t);});return}r.debug&&console.warn("[veo] builder mode pedido pero no pude resolver la URL de veo-builder.js");}function he(){let r=document.querySelectorAll("script[src]");for(let e of Array.from(r))if(/\bveo(\.min)?\.js(\?.*)?$/.test(e.src))return e.src.replace(/\bveo(\.min)?\.js/,"veo-builder$1.js");return null}var j=null;function Y(r){return j??(j=ve(r)),j}function ve(r){return new Promise(e=>{if(!u()||!l()){e(null);return}let t=window;if(t.veoGuides){e(t.veoGuides);return}let n=r.guidesUrl??ye();if(!n){r.debug&&console.warn("[veo] no pude resolver la URL de veo-guides.js"),e(null);return}let i=()=>e(t.veoGuides??null),o=document.querySelector(`script[src="${n}"]`);if(o){o.addEventListener("load",i),o.addEventListener("error",()=>e(null));return}let s=document.createElement("script");s.src=n,s.async=true,s.addEventListener("load",i),s.addEventListener("error",()=>{r.debug&&console.error("[veo] no pude cargar",n),e(null);}),document.head.appendChild(s);})}function ye(){let r=document.querySelectorAll("script[src]");for(let e of Array.from(r))if(/\bveo(\.min)?\.js(\?.*)?$/.test(e.src))return e.src.replace(/\bveo(\.min)?\.js/,"veo-guides$1.js");return null}var we="veoPreview";function W(){if(!u())return null;try{let r=new URLSearchParams(window.location.search).get(we);return r||null}catch{return null}}function Ee(r){return r}var X={enabled:true,captureClicks:true,captureSubmits:true,captureChanges:true,maskAllInputs:true,maskAllText:false,throttleMs:100,maxTextLength:200,captureElementMetadata:true,captureAncestors:5},J=10,Z=["[data-veo-ignore]",".veo-ignore",'input[type="password"]','input[type="email"]','input[type="tel"]','input[type="hidden"]','[autocomplete="cc-number"]','[autocomplete="cc-csc"]','[autocomplete="cc-exp"]','[autocomplete="cc-name"]','[name*="password" i]','[name*="ssn" i]','[name*="credit" i]','[name*="card" i]','[id*="password" i]','[id*="ssn" i]'],Q=["value","data-credit-card","data-ssn","data-password"],ee=["id","name","type","role","href","data-action","data-veo-tag","data-testid","aria-label","aria-labelledby"],te=[/^css-[a-z0-9]{4,}$/i,/^_[a-z0-9]+_[a-z0-9]{4,}_\d+$/,/^[a-z]{2,4}-[a-z0-9]{6,}$/i,/^[a-f0-9]{6,}$/i,/^sc-[a-z0-9]+$/i];function v(r,e=[]){let t=[...Z,...e],n=r;for(;n&&n!==document.documentElement;){for(let i of t)try{if(n.matches(i))return !0}catch{}n=n.parentElement;}return false}function re(r){let e=r.toLowerCase();return Q.includes(e)||/password|secret|token|ssn|credit/i.test(r)}function ne(r,e,t){if(t)return "";let n=r.tagName.toLowerCase();if(n==="input"||n==="textarea")return "";let o=((r instanceof HTMLElement?r.innerText:"")||r.textContent||"").trim().replace(/\s+/g," ");return o.length>e?`${o.slice(0,e)}\u2026`:o}function Se(r){return te.some(e=>e.test(r))}function f(r){return Array.from(r.classList).filter(e=>!Se(e)&&e.length<64)}var Ie=["data-testid","data-test","data-cy","name","aria-label","placeholder","alt","title","href","role","type"],be=100;function C(r){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(r):r.replace(/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g,"\\$&")}function ie(r){return r.replace(/[\\"]/g,"\\$&")}function Ae(r,e){for(let t of Ie){let n=r.getAttribute(t);if(n&&n.length>0&&n.length<=be)return `${e}[${t}="${ie(n)}"]`}return null}function _e(r){let e=r.tagName.toLowerCase(),t=r.getAttribute("data-veo-tag");if(t)return `${e}[data-veo-tag="${ie(t)}"]`;if(r.id){let s=f(r),a=s.length>0?`.${s.map(C).join(".")}`:"";return `${e}#${C(r.id)}${a}`}let n=Ae(r,e);if(n)return n;let i=f(r),o=i.length>0?`.${i.map(C).join(".")}`:"";return `${e}${o}`}function oe(r,e=5){let t=[],n=r,i=0;for(;n&&n!==document.documentElement&&i<=e;)t.unshift(_e(n)),n=n.parentElement,i++;return t.join(" > ")}function Te(r){let e={};for(let t of ee){let n=r.getAttribute(t);n!==null&&!re(t)&&n.length<256&&(e[t]=n);}return e}function xe(r,e){let t=r.getBoundingClientRect();return {tag:r.tagName.toLowerCase(),id:r.id||null,classes:f(r),text:ne(r,e.maxTextLength,e.maskAllText),attributes:e.captureElementMetadata?Te(r):{},position:{x:Math.round(t.left+window.scrollX),y:Math.round(t.top+window.scrollY),w:Math.round(t.width),h:Math.round(t.height)}}}function Pe(r,e){let t=[],n=r.parentElement,i=0;for(;n&&n!==document.documentElement&&i<e;)t.push({tag:n.tagName.toLowerCase(),id:n.id||null,classes:f(n),veoTag:n.getAttribute("data-veo-tag")||null}),n=n.parentElement,i++;return t}function se(r,e,t){return {$event_type:r,$element:xe(e,t),$ancestors:Pe(e,t.captureAncestors),$selector_path:oe(e,t.captureAncestors),$page_url:window.location.href,$page_path:window.location.pathname}}var y=class{constructor(e){this.windowMs=e;this.lastFired=new WeakMap;}shouldFire(e){let t=Date.now(),n=this.lastFired.get(e)??0;return t-n<this.windowMs?false:(this.lastFired.set(e,t),true)}};var w=class{constructor(e,t){this.client=e;this.cleanups=[];let n=X;this.config={enabled:t.enabled??n.enabled,captureClicks:t.captureClicks??n.captureClicks,captureSubmits:t.captureSubmits??n.captureSubmits,captureChanges:t.captureChanges??n.captureChanges,maskAllInputs:t.maskAllInputs??n.maskAllInputs,maskAllText:t.maskAllText??n.maskAllText,blockSelectors:t.blockSelectors??[],throttleMs:t.throttleMs??n.throttleMs,maxTextLength:t.maxTextLength??n.maxTextLength,captureElementMetadata:t.captureElementMetadata??n.captureElementMetadata,captureAncestors:Math.min(t.captureAncestors??n.captureAncestors,J)},this.throttle=new y(this.config.throttleMs);}install(){!l()||!this.config.enabled||(this.config.captureClicks&&this.attach("click",e=>this.handleClick(e)),this.config.captureSubmits&&this.attach("submit",e=>this.handleSubmit(e),true),this.config.captureChanges&&this.attach("change",e=>this.handleChange(e),true));}destroy(){for(let e of this.cleanups)e();this.cleanups=[];}attach(e,t,n=false){let i=o=>{if(o.isTrusted)try{t(o);}catch{}};document.addEventListener(e,i,n),this.cleanups.push(()=>document.removeEventListener(e,i,n));}handleClick(e){let t=e.target;if(!(t instanceof Element))return;let n=this.findMeaningfulAncestor(t);n&&(v(n,this.config.blockSelectors)||this.throttle.shouldFire(n)&&this.emit("click",n));}handleSubmit(e){let t=e.target;!(t instanceof Element)||t.tagName.toLowerCase()!=="form"||v(t,this.config.blockSelectors)||this.throttle.shouldFire(t)&&this.emit("submit",t);}handleChange(e){let t=e.target;if(!(t instanceof Element))return;let n=t.tagName.toLowerCase();n!=="select"&&n!=="input"&&n!=="textarea"||t instanceof HTMLInputElement&&t.type!=="checkbox"&&t.type!=="radio"||v(t,this.config.blockSelectors)||this.throttle.shouldFire(t)&&this.emit("change",t);}findMeaningfulAncestor(e){let t=e,n=0;for(;t&&t!==document.documentElement&&n<5;){let i=t.tagName.toLowerCase();if(i==="button"||i==="a"||i==="input"||i==="select"||i==="textarea"||t.hasAttribute("data-veo-tag")||t.hasAttribute("role")||t.hasAttribute("onclick")||t instanceof HTMLElement&&t.style.cursor==="pointer")return t;t=t.parentElement,n++;}return null}emit(e,t){let n=se(e,t,this.config);this.client.track("$autocapture",n);}};function k(r={}){let e=null;return {name:"autocapture",install(t){e=new w(t,r),e.install();},destroy(){e?.destroy(),e=null;}}}function L(){return {name:"spa-router",install(r){if(!u())return;r.pageview();let e=()=>{queueMicrotask(()=>r.pageview());},t=window.history.pushState,n=window.history.replaceState;window.history.pushState=function(...i){t.apply(this,i),e();},window.history.replaceState=function(...i){n.apply(this,i),e();},window.addEventListener("popstate",e),window.addEventListener("hashchange",e);}}}function d(){let e=Date.now().toString(16).padStart(12,"0"),t=new Uint8Array(10);if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function")crypto.getRandomValues(t);else for(let i=0;i<t.length;i++)t[i]=Math.floor(Math.random()*256);t[0]=(t[0]??0)&15|112,t[2]=(t[2]??0)&63|128;let n=Array.from(t,i=>i.toString(16).padStart(2,"0")).join("");return [e.slice(0,8),e.slice(8,12),n.slice(0,4),n.slice(4,8),n.slice(8,20)].join("-")}var E=class{constructor(e){this.config=e;this.buffer=[];this.timer=null;this.flushing=false;this.retryCount=0;this.retryTimer=null;this.startTimer();}add(e){this.buffer.push(e),this.buffer.length>=this.config.batchSize&&this.flush();}async flush(){if(this.flushing||this.buffer.length===0)return;this.flushing=true;let e=this.buffer.splice(0,this.buffer.length);try{await this.config.transport.send("/v1/events",{events:e}),this.retryCount=0;}catch(t){this.buffer.unshift(...e),this.scheduleRetry(),this.config.onError?.(t);}finally{this.flushing=false;}}flushBeacon(){if(this.buffer.length===0)return;let e=this.buffer.splice(0,this.buffer.length);this.config.transport.sendBeacon("/v1/events",{events:e})||this.buffer.unshift(...e);}destroy(){this.timer&&clearInterval(this.timer),this.retryTimer&&clearTimeout(this.retryTimer),this.timer=null,this.retryTimer=null;}startTimer(){this.timer=setInterval(()=>{this.flush();},this.config.flushIntervalMs);}scheduleRetry(){let e=this.config.maxRetries??3;if(this.retryCount>=e){this.retryCount=0;return}this.retryCount++;let t=Math.min(1e3*2**(this.retryCount-1),3e4);this.retryTimer&&clearTimeout(this.retryTimer),this.retryTimer=setTimeout(()=>{this.flush();},t);}};var ae="anonymous_user_id",V="end_user_id",S="session_id",m="session_last_active",ue=1800*1e3,I=class{constructor(e){this.storage=e;this._endUserId=null;this._anonymousId=this.loadOrCreateAnonymousId(),this._sessionId=this.loadOrCreateSession(),this._endUserId=this.storage.get(V);}get anonymousId(){return this._anonymousId}get sessionId(){return this._sessionId}get endUserId(){return this._endUserId}get effectiveUserId(){return this._endUserId??this._anonymousId}setEndUserId(e){this._endUserId=e,this.storage.set(V,e);}touch(){let e=this.storage.get(m),t=Date.now();e&&t-Number.parseInt(e,10)>ue&&(this._sessionId=d(),this.storage.set(S,this._sessionId)),this.storage.set(m,String(t));}reset(){this._endUserId=null,this.storage.remove(V),this._sessionId=d(),this.storage.set(S,this._sessionId),this.storage.set(m,String(Date.now()));}loadOrCreateAnonymousId(){let e=this.storage.get(ae);return e||(e=d(),this.storage.set(ae,e)),e}loadOrCreateSession(){let e=this.storage.get(S),t=this.storage.get(m);if(e&&t&&Date.now()-Number.parseInt(t,10)<ue)return e;let n=d();return this.storage.set(S,n),this.storage.set(m,String(Date.now())),n}};var c="veo:",Ue=365*24*60*60*1e3,b=class{get(e){return localStorage.getItem(c+e)}set(e,t){try{localStorage.setItem(c+e,t);}catch{}}remove(e){localStorage.removeItem(c+e);}clear(){let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(c)&&e.push(n);}for(let t of e)localStorage.removeItem(t);}};function le(){let r=document.cookie;return r===""?[]:r.split("; ")}var A=class{get(e){let t=`${c}${e}=`;for(let n of le())if(n.startsWith(t))return decodeURIComponent(n.slice(t.length));return null}set(e,t,n){let i=Math.floor((n?.ttlMs??Ue)/1e3),o=typeof location<"u"&&location.protocol==="https:"?"; Secure":"";document.cookie=`${c}${e}=${encodeURIComponent(t)}; Path=/; Max-Age=${i}; SameSite=Lax${o}`;}remove(e){document.cookie=`${c}${e}=; Path=/; Max-Age=0; SameSite=Lax`;}clear(){for(let e of le()){let t=e.indexOf("="),n=t===-1?e:e.slice(0,t);n.startsWith(c)&&this.remove(n.slice(c.length));}}},_=class{constructor(){this.store=new Map;}get(e){return this.store.get(e)??null}set(e,t){this.store.set(e,t);}remove(e){this.store.delete(e);}clear(){this.store.clear();}};function ce(r="localStorage"){return r==="localStorage"&&P()?new b:r==="cookie"&&l()?new A:r==="memory"?new _:P()?new b:l()?new A:new _}var M=class extends Error{constructor(t,n){super(t);this.statusCode=n;this.name="TransportError";}},T=class{constructor(e){this.config=e;}async send(e,t){let n=`${this.config.apiUrl}${e}`,i=new AbortController,o=this.config.timeoutMs??1e4,s=setTimeout(()=>i.abort(new DOMException(`Veo request timeout (${o}ms)`,"TimeoutError")),o);try{let a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json","X-Api-Key":this.config.apiKey,"X-Sdk-Version":this.config.sdkVersion},body:JSON.stringify(t),signal:i.signal});if(!a.ok)throw new M(`HTTP ${a.status}`,a.status);return await a.json()}finally{clearTimeout(s);}}sendBeacon(e,t){if(!z())return false;let n=new URL(`${this.config.apiUrl}${e}`);n.searchParams.set("key",this.config.apiKey),n.searchParams.set("v",this.config.sdkVersion);let i=new Blob([JSON.stringify(t)],{type:"application/json"});return navigator.sendBeacon(n.toString(),i)}};var O="organization_id",de="end_user_id",$="identify_signature";function N(r){return r===null||typeof r!="object"?JSON.stringify(r)??"null":Array.isArray(r)?`[${r.map(N).join(",")}]`:`{${Object.keys(r).sort().map(t=>`${JSON.stringify(t)}:${N(r[t])}`).join(",")}}`}var h=class{constructor(e){this.config=e;this.plugins=[];this.currentOrganizationId=null;this.listeners={pageview:new Set,identify:new Set};if(!e.apiKey)throw new Error("apiKey is required");this.storage=ce(e.storage??"localStorage"),this.session=new I(this.storage),this.transport=new T({apiKey:e.apiKey,apiUrl:g(e).replace(/\/$/,""),sdkVersion:x}),this.queue=new E({transport:this.transport,flushIntervalMs:e.flushInterval??5e3,batchSize:e.flushBatchSize??20,onError:i=>{e.debug&&console.error("[veo] flush error:",i);}});let t=this.storage.get(de);t&&this.session.setEndUserId(t);let n=this.storage.get(O);n&&(this.currentOrganizationId=n),this.setupUnloadHandlers(),e.debug&&console.log("[veo] initialized",{anonymousId:this.session.anonymousId,sessionId:this.session.sessionId,endUserId:this.session.endUserId});}identify(e){let{visitor:t,organization:n}=e,i=N({id:t.id,traits:t.traits??{},org:n?{id:n.id,attributes:n.attributes??{}}:null});if(this.session.endUserId===t.id&&this.storage.get($)===i){this.config.debug&&console.debug("[veo] identify: sin cambios, omitido");return}let o=this.session.endUserId===null?this.session.anonymousId:void 0;this.session.setEndUserId(t.id),n&&(this.currentOrganizationId=n.id,this.storage.set(O,n.id));let a={endUser:{id:t.id,traits:t.traits??{},...o!==void 0?{anonymousId:o}:{}},...n?{organization:{id:n.id,attributes:n.attributes??{}}}:{}};this.transport.send("/v1/identify",a).catch(p=>{this.config.debug&&console.error("[veo] identify failed:",p);}),this.enqueue({actionType:"identify",actionProperties:{traits:t.traits,organizationAttributes:n?.attributes}}),this.storage.set($,i),this.emit("identify",{endUserId:t.id,sessionId:this.session.sessionId});}track(e,t){if(!e||typeof e!="string"){this.config.debug&&console.error("[veo] track: name is required");return}this.enqueue({actionType:"track",actionName:e,...t!==void 0?{actionProperties:t}:{}});}pageview(e){if(!l())return;let t=window.location.href,n=e??window.location.pathname;this.enqueue({actionType:"pageview",pageUrl:t,pagePath:n,pageTitle:document.title,pageReferrer:document.referrer}),this.emit("pageview",{url:t,path:n,sessionId:this.session.sessionId,endUserId:this.session.endUserId});}reset(){this.session.reset(),this.currentOrganizationId=null,this.storage.remove(O),this.storage.remove(de),this.storage.remove($);}flush(){return this.queue.flush()}use(e){return this.plugins.push(e),e.install(this),this}getEndUserId(){return this.session.endUserId}getAnonymousId(){return this.session.anonymousId}getSessionId(){return this.session.sessionId}on(e,t){return this.listeners[e].add(t),()=>{this.listeners[e].delete(t);}}emit(e,t){for(let n of this.listeners[e])try{n(t);}catch(i){this.config.debug&&console.error(`[veo] listener for '${e}' failed:`,i);}}enqueue(e){this.session.touch();let t=this.currentOrganizationId??void 0,n=e.pageUrl??(u()?window.location.href:void 0),i=e.pagePath??(u()?window.location.pathname:void 0),o=e.pageTitle??(l()?document.title:void 0),s=e.pageReferrer??(l()?document.referrer:void 0),a={actionId:d(),endUserId:this.session.effectiveUserId,sessionId:this.session.sessionId,actionType:e.actionType,occurredAt:new Date().toISOString(),...t!==void 0?{organizationId:t}:{},...e.actionName!==void 0?{actionName:e.actionName}:{},...n!==void 0?{pageUrl:n}:{},...i!==void 0?{pagePath:i}:{},...o!==void 0?{pageTitle:o}:{},...s!==void 0?{pageReferrer:s}:{},...e.actionProperties!==void 0?{actionProperties:e.actionProperties}:{}};this.queue.add(a);}setupUnloadHandlers(){u()&&(window.addEventListener("pagehide",()=>this.queue.flushBeacon()),window.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.queue.flushBeacon();}));}};function pe(r,e,t){let n=new h(r);if(n.use(L()),r.autocapture!==false){let i=typeof r.autocapture=="object"?r.autocapture:{};n.use(k(i));}if(e(n),typeof window<"u"){let o=window.veo?._q??[];window.veo=n;for(let s of o){let[a,p]=s;if(a==="init")continue;let B=n[a];if(typeof B=="function")try{B.apply(n,Array.from(p));}catch(ge){r.debug&&console.error("[veo] drain error:",ge);}}F({...r.builderUrl!==void 0?{builderUrl:r.builderUrl}:{},...r.debug!==void 0?{debug:r.debug}:{},...r.apiKey!==void 0?{apiKey:r.apiKey}:{},apiUrl:g(r),...{}});}return n}function Kt(r){let e=g(r);return pe(r,t=>{let n=()=>Y({...r.guidesUrl!==void 0?{guidesUrl:r.guidesUrl}:{},...r.debug!==void 0?{debug:r.debug}:{}}),i=W();r.guides===true&&!R()&&i===null&&n().then(o=>{o&&t.use(o.guidesPlugin({apiUrl:e,apiKey:r.apiKey,...r.debug!==void 0?{debug:r.debug}:{}}));}),i!==null&&n().then(o=>o?.runPreviewMode({apiKey:r.apiKey,apiUrl:e,token:i,...r.debug!==void 0?{debug:r.debug}:{}})),t.preview=o=>{let s=null,a=n().then(p=>p?(s=p.previewGuide(o),s.ready):{rendered:false});return {close:()=>s?.close(),ready:a}},t.closePreview=()=>{n().then(o=>o?.closeGuidePreview());};})}
|
|
2
|
-
exports.Client=h;exports.SDK_VERSION=
|
|
1
|
+
var veo=(function(exports){'use strict';var P="0.0.1";var $="https://veo-backend-production-8c78.up.railway.app";function g(r){let e=r?.apiUrl;if(typeof e=="string"&&e.trim())return e;let t=globalThis.__VEO_API_URL__;return typeof t=="string"&&t.trim()?t:$}function u(){return typeof window<"u"}function l(){return typeof document<"u"}function x(){try{if(typeof localStorage>"u")return !1;let r="__veo_test__";return localStorage.setItem(r,"1"),localStorage.removeItem(r),!0}catch{return false}}function D(){return typeof navigator<"u"&&typeof navigator.sendBeacon=="function"}var G="veoBuilder",z="veoBuilderOrigin",H="veoBuilderPanel",K="veoBuilderPanelPath",q="veoGuide";var F="veo:builder_ctx";function j(){try{return window.sessionStorage}catch{return null}}function ye(){try{return new URLSearchParams(window.location.search)}catch{return null}}function Y(){if(!u())return null;let r=ye(),e=r?.get(G);if(e){let t={token:e,origin:r?.get(z)??null,panel:r?.get(H)==="1",guide:r?.get(q)??null,panelPath:r?.get(K)??null};try{j()?.setItem(F,JSON.stringify(t));}catch{}return t}try{let t=j()?.getItem(F);return t?JSON.parse(t):null}catch{return null}}function W(){return Y()?.token??null}function R(){return Y()!==null}function X(r){if(!u()||!l()||W()===null||(r.apiKey&&r.apiUrl&&(window.__veoBuilder={apiKey:r.apiKey,apiUrl:r.apiUrl}),window.veoBuilder))return;let e=r.builderUrl??we();if(e){if(document.querySelector(`script[src="${e}"]`))return;let t=document.createElement("script");t.src=e,t.async=true,r.debug&&t.addEventListener("error",()=>console.error("[veo] no pude cargar",e)),document.head.appendChild(t);return}if(r.loadBuilder){r.loadBuilder().catch(t=>{r.debug&&console.error("[veo] no pude cargar el builder (import din\xE1mico)",t);});return}r.debug&&console.warn("[veo] builder mode pedido pero no pude resolver la URL de veo-builder.js");}function we(){let r=document.querySelectorAll("script[src]");for(let e of Array.from(r))if(/\bveo(\.min)?\.js(\?.*)?$/.test(e.src))return e.src.replace(/\bveo(\.min)?\.js/,"veo-builder$1.js");return null}var J=null;function Z(r){return J??(J=Ee(r)),J}function Ee(r){return new Promise(e=>{if(!u()||!l()){e(null);return}let t=window;if(t.veoGuides){e(t.veoGuides);return}let n=r.guidesUrl??Ae();if(!n){r.debug&&console.warn("[veo] no pude resolver la URL de veo-guides.js"),e(null);return}let i=()=>e(t.veoGuides??null),o=document.querySelector(`script[src="${n}"]`);if(o){o.addEventListener("load",i),o.addEventListener("error",()=>e(null));return}let s=document.createElement("script");s.src=n,s.async=true,s.addEventListener("load",i),s.addEventListener("error",()=>{r.debug&&console.error("[veo] no pude cargar",n),e(null);}),document.head.appendChild(s);})}function Ae(){let r=document.querySelectorAll("script[src]");for(let e of Array.from(r))if(/\bveo(\.min)?\.js(\?.*)?$/.test(e.src))return e.src.replace(/\bveo(\.min)?\.js/,"veo-guides$1.js");return null}var Ie="veoPreview";function Q(){if(!u())return null;try{let r=new URLSearchParams(window.location.search).get(Ie);return r||null}catch{return null}}function Se(r){return r}var ee={enabled:true,captureClicks:true,captureSubmits:true,captureChanges:true,maskAllInputs:true,maskAllText:false,throttleMs:100,maxTextLength:200,captureElementMetadata:true,captureAncestors:5},te=10,re=["[data-veo-ignore]",".veo-ignore",'input[type="password"]','input[type="email"]','input[type="tel"]','input[type="hidden"]','[autocomplete="cc-number"]','[autocomplete="cc-csc"]','[autocomplete="cc-exp"]','[autocomplete="cc-name"]','[name*="password" i]','[name*="ssn" i]','[name*="credit" i]','[name*="card" i]','[id*="password" i]','[id*="ssn" i]'],ne=["value","data-credit-card","data-ssn","data-password"],ie=["id","name","type","role","href","data-action","data-veo-tag","data-testid","aria-label","aria-labelledby"],oe=[/^css-[a-z0-9]{4,}$/i,/^_[a-z0-9]+_[a-z0-9]{4,}_\d+$/,/^[a-z]{2,4}-[a-z0-9]{6,}$/i,/^[a-f0-9]{6,}$/i,/^sc-[a-z0-9]+$/i];function v(r,e=[]){let t=[...re,...e],n=r;for(;n&&n!==document.documentElement;){for(let i of t)try{if(n.matches(i))return !0}catch{}n=n.parentElement;}return false}function se(r){let e=r.toLowerCase();return ne.includes(e)||/password|secret|token|ssn|credit/i.test(r)}function ae(r,e,t){if(t)return "";let n=r.tagName.toLowerCase();if(n==="input"||n==="textarea")return "";let o=((r instanceof HTMLElement?r.innerText:"")||r.textContent||"").trim().replace(/\s+/g," ");return o.length>e?`${o.slice(0,e)}\u2026`:o}function be(r){return oe.some(e=>e.test(r))}function f(r){return Array.from(r.classList).filter(e=>!be(e)&&e.length<64)}var _e=["data-testid","data-test","data-cy","name","aria-label","placeholder","alt","title","href","role","type"],Te=100;function C(r){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(r):r.replace(/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g,"\\$&")}function ue(r){return r.replace(/[\\"]/g,"\\$&")}function Pe(r,e){for(let t of _e){let n=r.getAttribute(t);if(n&&n.length>0&&n.length<=Te)return `${e}[${t}="${ue(n)}"]`}return null}function xe(r){let e=r.tagName.toLowerCase(),t=r.getAttribute("data-veo-tag");if(t)return `${e}[data-veo-tag="${ue(t)}"]`;if(r.id){let s=f(r),a=s.length>0?`.${s.map(C).join(".")}`:"";return `${e}#${C(r.id)}${a}`}let n=Pe(r,e);if(n)return n;let i=f(r),o=i.length>0?`.${i.map(C).join(".")}`:"";return `${e}${o}`}function le(r,e=5){let t=[],n=r,i=0;for(;n&&n!==document.documentElement&&i<=e;)t.unshift(xe(n)),n=n.parentElement,i++;return t.join(" > ")}function Re(r){let e={};for(let t of ie){let n=r.getAttribute(t);n!==null&&!se(t)&&n.length<256&&(e[t]=n);}return e}function Ce(r,e){let t=r.getBoundingClientRect();return {tag:r.tagName.toLowerCase(),id:r.id||null,classes:f(r),text:ae(r,e.maxTextLength,e.maskAllText),attributes:e.captureElementMetadata?Re(r):{},position:{x:Math.round(t.left+window.scrollX),y:Math.round(t.top+window.scrollY),w:Math.round(t.width),h:Math.round(t.height)}}}function Ue(r,e){let t=[],n=r.parentElement,i=0;for(;n&&n!==document.documentElement&&i<e;)t.push({tag:n.tagName.toLowerCase(),id:n.id||null,classes:f(n),veoTag:n.getAttribute("data-veo-tag")||null}),n=n.parentElement,i++;return t}function ce(r,e,t){return {$event_type:r,$element:Ce(e,t),$ancestors:Ue(e,t.captureAncestors),$selector_path:le(e,t.captureAncestors),$page_url:window.location.href,$page_path:window.location.pathname}}var y=class{constructor(e){this.windowMs=e;this.lastFired=new WeakMap;}shouldFire(e){let t=Date.now(),n=this.lastFired.get(e)??0;return t-n<this.windowMs?false:(this.lastFired.set(e,t),true)}};var w=class{constructor(e,t){this.client=e;this.cleanups=[];let n=ee;this.config={enabled:t.enabled??n.enabled,captureClicks:t.captureClicks??n.captureClicks,captureSubmits:t.captureSubmits??n.captureSubmits,captureChanges:t.captureChanges??n.captureChanges,maskAllInputs:t.maskAllInputs??n.maskAllInputs,maskAllText:t.maskAllText??n.maskAllText,blockSelectors:t.blockSelectors??[],throttleMs:t.throttleMs??n.throttleMs,maxTextLength:t.maxTextLength??n.maxTextLength,captureElementMetadata:t.captureElementMetadata??n.captureElementMetadata,captureAncestors:Math.min(t.captureAncestors??n.captureAncestors,te)},this.throttle=new y(this.config.throttleMs);}install(){!l()||!this.config.enabled||(this.config.captureClicks&&this.attach("click",e=>this.handleClick(e)),this.config.captureSubmits&&this.attach("submit",e=>this.handleSubmit(e),true),this.config.captureChanges&&this.attach("change",e=>this.handleChange(e),true));}destroy(){for(let e of this.cleanups)e();this.cleanups=[];}attach(e,t,n=false){let i=o=>{if(o.isTrusted)try{t(o);}catch{}};document.addEventListener(e,i,n),this.cleanups.push(()=>document.removeEventListener(e,i,n));}handleClick(e){let t=e.target;if(!(t instanceof Element))return;let n=this.findMeaningfulAncestor(t);n&&(v(n,this.config.blockSelectors)||this.throttle.shouldFire(n)&&this.emit("click",n));}handleSubmit(e){let t=e.target;!(t instanceof Element)||t.tagName.toLowerCase()!=="form"||v(t,this.config.blockSelectors)||this.throttle.shouldFire(t)&&this.emit("submit",t);}handleChange(e){let t=e.target;if(!(t instanceof Element))return;let n=t.tagName.toLowerCase();n!=="select"&&n!=="input"&&n!=="textarea"||t instanceof HTMLInputElement&&t.type!=="checkbox"&&t.type!=="radio"||v(t,this.config.blockSelectors)||this.throttle.shouldFire(t)&&this.emit("change",t);}findMeaningfulAncestor(e){let t=e,n=0;for(;t&&t!==document.documentElement&&n<5;){let i=t.tagName.toLowerCase();if(i==="button"||i==="a"||i==="input"||i==="select"||i==="textarea"||t.hasAttribute("data-veo-tag")||t.hasAttribute("role")||t.hasAttribute("onclick")||t instanceof HTMLElement&&t.style.cursor==="pointer")return t;t=t.parentElement,n++;}return null}emit(e,t){let n=ce(e,t,this.config);this.client.track("$autocapture",n);}};function U(r={}){let e=null;return {name:"autocapture",install(t){e=new w(t,r),e.install();},destroy(){e?.destroy(),e=null;}}}function k(){return {name:"spa-router",install(r){if(!u())return;r.pageview();let e=()=>{queueMicrotask(()=>r.pageview());},t=window.history.pushState,n=window.history.replaceState;window.history.pushState=function(...i){t.apply(this,i),e();},window.history.replaceState=function(...i){n.apply(this,i),e();},window.addEventListener("popstate",e),window.addEventListener("hashchange",e);}}}function d(){let e=Date.now().toString(16).padStart(12,"0"),t=new Uint8Array(10);if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function")crypto.getRandomValues(t);else for(let i=0;i<t.length;i++)t[i]=Math.floor(Math.random()*256);t[0]=(t[0]??0)&15|112,t[2]=(t[2]??0)&63|128;let n=Array.from(t,i=>i.toString(16).padStart(2,"0")).join("");return [e.slice(0,8),e.slice(8,12),n.slice(0,4),n.slice(4,8),n.slice(8,20)].join("-")}var E=class{constructor(e){this.config=e;this.buffer=[];this.timer=null;this.flushing=false;this.retryCount=0;this.retryTimer=null;this.startTimer();}add(e){this.buffer.push(e),this.buffer.length>=this.config.batchSize&&this.flush();}async flush(){if(this.flushing||this.buffer.length===0)return;this.flushing=true;let e=this.buffer.splice(0,this.buffer.length);try{await this.config.transport.send("/v1/events",{events:e}),this.retryCount=0;}catch(t){this.buffer.unshift(...e),this.scheduleRetry(),this.config.onError?.(t);}finally{this.flushing=false;}}flushBeacon(){if(this.buffer.length===0)return;let e=this.buffer.splice(0,this.buffer.length);this.config.transport.sendBeacon("/v1/events",{events:e})||this.buffer.unshift(...e);}destroy(){this.timer&&clearInterval(this.timer),this.retryTimer&&clearTimeout(this.retryTimer),this.timer=null,this.retryTimer=null;}startTimer(){this.timer=setInterval(()=>{this.flush();},this.config.flushIntervalMs);}scheduleRetry(){let e=this.config.maxRetries??3;if(this.retryCount>=e){this.retryCount=0;return}this.retryCount++;let t=Math.min(1e3*2**(this.retryCount-1),3e4);this.retryTimer&&clearTimeout(this.retryTimer),this.retryTimer=setTimeout(()=>{this.flush();},t);}};var de="anonymous_user_id",L="end_user_id",A="session_id",m="session_last_active",pe=1800*1e3,I=class{constructor(e){this.storage=e;this._endUserId=null;this._anonymousId=this.loadOrCreateAnonymousId(),this._sessionId=this.loadOrCreateSession(),this._endUserId=this.storage.get(L);}get anonymousId(){return this._anonymousId}get sessionId(){return this._sessionId}get endUserId(){return this._endUserId}get effectiveUserId(){return this._endUserId??this._anonymousId}setEndUserId(e){this._endUserId=e,this.storage.set(L,e);}touch(){let e=this.storage.get(m),t=Date.now();e&&t-Number.parseInt(e,10)>pe&&(this._sessionId=d(),this.storage.set(A,this._sessionId)),this.storage.set(m,String(t));}reset(){this._endUserId=null,this.storage.remove(L),this._sessionId=d(),this.storage.set(A,this._sessionId),this.storage.set(m,String(Date.now()));}loadOrCreateAnonymousId(){let e=this.storage.get(de);return e||(e=d(),this.storage.set(de,e)),e}loadOrCreateSession(){let e=this.storage.get(A),t=this.storage.get(m);if(e&&t&&Date.now()-Number.parseInt(t,10)<pe)return e;let n=d();return this.storage.set(A,n),this.storage.set(m,String(Date.now())),n}};var c="veo:",ke=365*24*60*60*1e3,S=class{get(e){return localStorage.getItem(c+e)}set(e,t){try{localStorage.setItem(c+e,t);}catch{}}remove(e){localStorage.removeItem(c+e);}clear(){let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(c)&&e.push(n);}for(let t of e)localStorage.removeItem(t);}};function ge(){let r=document.cookie;return r===""?[]:r.split("; ")}var b=class{get(e){let t=`${c}${e}=`;for(let n of ge())if(n.startsWith(t))return decodeURIComponent(n.slice(t.length));return null}set(e,t,n){let i=Math.floor((n?.ttlMs??ke)/1e3),o=typeof location<"u"&&location.protocol==="https:"?"; Secure":"";document.cookie=`${c}${e}=${encodeURIComponent(t)}; Path=/; Max-Age=${i}; SameSite=Lax${o}`;}remove(e){document.cookie=`${c}${e}=; Path=/; Max-Age=0; SameSite=Lax`;}clear(){for(let e of ge()){let t=e.indexOf("="),n=t===-1?e:e.slice(0,t);n.startsWith(c)&&this.remove(n.slice(c.length));}}},_=class{constructor(){this.store=new Map;}get(e){return this.store.get(e)??null}set(e,t){this.store.set(e,t);}remove(e){this.store.delete(e);}clear(){this.store.clear();}};function fe(r="localStorage"){return r==="localStorage"&&x()?new S:r==="cookie"&&l()?new b:r==="memory"?new _:x()?new S:l()?new b:new _}var V=class extends Error{constructor(t,n){super(t);this.statusCode=n;this.name="TransportError";}},T=class{constructor(e){this.config=e;}async send(e,t){let n=`${this.config.apiUrl}${e}`,i=new AbortController,o=this.config.timeoutMs??1e4,s=setTimeout(()=>i.abort(new DOMException(`Veo request timeout (${o}ms)`,"TimeoutError")),o);try{let a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json","X-Api-Key":this.config.apiKey,"X-Sdk-Version":this.config.sdkVersion},body:JSON.stringify(t),signal:i.signal});if(!a.ok)throw new V(`HTTP ${a.status}`,a.status);return await a.json()}finally{clearTimeout(s);}}sendBeacon(e,t){if(!D())return false;let n=new URL(`${this.config.apiUrl}${e}`);n.searchParams.set("key",this.config.apiKey),n.searchParams.set("v",this.config.sdkVersion);let i=new Blob([JSON.stringify(t)],{type:"application/json"});return navigator.sendBeacon(n.toString(),i)}};var M="organization_id",me="end_user_id",N="identify_signature";function O(r){return r===null||typeof r!="object"?JSON.stringify(r)??"null":Array.isArray(r)?`[${r.map(O).join(",")}]`:`{${Object.keys(r).sort().map(t=>`${JSON.stringify(t)}:${O(r[t])}`).join(",")}}`}var h=class{constructor(e){this.config=e;this.plugins=[];this.currentOrganizationId=null;this.listeners={pageview:new Set,identify:new Set};if(!e.apiKey)throw new Error("apiKey is required");this.storage=fe(e.storage??"localStorage"),this.session=new I(this.storage),this.transport=new T({apiKey:e.apiKey,apiUrl:g(e).replace(/\/$/,""),sdkVersion:P}),this.queue=new E({transport:this.transport,flushIntervalMs:e.flushInterval??5e3,batchSize:e.flushBatchSize??20,onError:i=>{e.debug&&console.error("[veo] flush error:",i);}});let t=this.storage.get(me);t&&this.session.setEndUserId(t);let n=this.storage.get(M);n&&(this.currentOrganizationId=n),this.setupUnloadHandlers(),e.debug&&console.log("[veo] initialized",{anonymousId:this.session.anonymousId,sessionId:this.session.sessionId,endUserId:this.session.endUserId});}identify(e){let{visitor:t,organization:n}=e,i=O({id:t.id,traits:t.traits??{},org:n?{id:n.id,attributes:n.attributes??{}}:null});if(this.session.endUserId===t.id&&this.storage.get(N)===i){this.config.debug&&console.debug("[veo] identify: sin cambios, omitido");return}let o=this.session.endUserId===null?this.session.anonymousId:void 0;this.session.setEndUserId(t.id),n&&(this.currentOrganizationId=n.id,this.storage.set(M,n.id));let a={endUser:{id:t.id,traits:t.traits??{},...o!==void 0?{anonymousId:o}:{}},...n?{organization:{id:n.id,attributes:n.attributes??{}}}:{}};this.transport.send("/v1/identify",a).catch(p=>{this.config.debug&&console.error("[veo] identify failed:",p);}),this.enqueue({actionType:"identify",actionProperties:{traits:t.traits,organizationAttributes:n?.attributes}}),this.storage.set(N,i),this.emit("identify",{endUserId:t.id,sessionId:this.session.sessionId});}track(e,t){if(!e||typeof e!="string"){this.config.debug&&console.error("[veo] track: name is required");return}this.enqueue({actionType:"track",actionName:e,...t!==void 0?{actionProperties:t}:{}});}pageview(e){if(!l())return;let t=window.location.href,n=e??window.location.pathname;this.enqueue({actionType:"pageview",pageUrl:t,pagePath:n,pageTitle:document.title,pageReferrer:document.referrer}),this.emit("pageview",{url:t,path:n,sessionId:this.session.sessionId,endUserId:this.session.endUserId});}reset(){this.session.reset(),this.currentOrganizationId=null,this.storage.remove(M),this.storage.remove(me),this.storage.remove(N);}flush(){return this.queue.flush()}use(e){return this.plugins.push(e),e.install(this),this}getEndUserId(){return this.session.endUserId}getAnonymousId(){return this.session.anonymousId}getSessionId(){return this.session.sessionId}on(e,t){return this.listeners[e].add(t),()=>{this.listeners[e].delete(t);}}emit(e,t){for(let n of this.listeners[e])try{n(t);}catch(i){this.config.debug&&console.error(`[veo] listener for '${e}' failed:`,i);}}enqueue(e){this.session.touch();let t=this.currentOrganizationId??void 0,n=e.pageUrl??(u()?window.location.href:void 0),i=e.pagePath??(u()?window.location.pathname:void 0),o=e.pageTitle??(l()?document.title:void 0),s=e.pageReferrer??(l()?document.referrer:void 0),a={actionId:d(),endUserId:this.session.effectiveUserId,sessionId:this.session.sessionId,actionType:e.actionType,occurredAt:new Date().toISOString(),...t!==void 0?{organizationId:t}:{},...e.actionName!==void 0?{actionName:e.actionName}:{},...n!==void 0?{pageUrl:n}:{},...i!==void 0?{pagePath:i}:{},...o!==void 0?{pageTitle:o}:{},...s!==void 0?{pageReferrer:s}:{},...e.actionProperties!==void 0?{actionProperties:e.actionProperties}:{}};this.queue.add(a);}setupUnloadHandlers(){u()&&(window.addEventListener("pagehide",()=>this.queue.flushBeacon()),window.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.queue.flushBeacon();}));}};function he(r,e,t){let n=new h(r);if(n.use(k()),r.autocapture!==false){let i=typeof r.autocapture=="object"?r.autocapture:{};n.use(U(i));}if(e(n),typeof window<"u"){let o=window.veo?._q??[];window.veo=n;for(let s of o){let[a,p]=s;if(a==="init")continue;let B=n[a];if(typeof B=="function")try{B.apply(n,Array.from(p));}catch(ve){r.debug&&console.error("[veo] drain error:",ve);}}X({...r.builderUrl!==void 0?{builderUrl:r.builderUrl}:{},...r.debug!==void 0?{debug:r.debug}:{},...r.apiKey!==void 0?{apiKey:r.apiKey}:{},apiUrl:g(r),...{}});}return n}function Ft(r){let e=g(r);return he(r,t=>{let n=()=>Z({...r.guidesUrl!==void 0?{guidesUrl:r.guidesUrl}:{},...r.debug!==void 0?{debug:r.debug}:{}}),i=Q();r.guides===true&&!R()&&i===null&&n().then(o=>{o&&t.use(o.guidesPlugin({apiUrl:e,apiKey:r.apiKey,...r.debug!==void 0?{debug:r.debug}:{}}));}),i!==null&&n().then(o=>o?.runPreviewMode({apiKey:r.apiKey,apiUrl:e,token:i,...r.debug!==void 0?{debug:r.debug}:{}})),t.preview=o=>{let s=null,a=n().then(p=>p?(s=p.previewGuide(o),s.ready):{rendered:false});return {close:()=>s?.close(),ready:a}},t.closePreview=()=>{n().then(o=>o?.closeGuidePreview());};})}
|
|
2
|
+
exports.Client=h;exports.SDK_VERSION=P;exports.autocapturePlugin=U;exports.definePlugin=Se;exports.init=Ft;exports.spaRouterPlugin=k;return exports;})({});//# sourceMappingURL=veo.js.map
|
|
3
3
|
//# sourceMappingURL=veo.js.map
|