@indiebob/tracker 0.2.3 → 0.3.0
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/CHANGELOG.md +80 -0
- package/README.md +125 -6
- package/dist/index.cjs +880 -2
- package/dist/index.d.mts +69 -11
- package/dist/index.d.ts +69 -11
- package/dist/index.global.js +3 -3
- package/dist/index.js +878 -2
- package/dist/server.d.mts +8 -0
- package/dist/server.d.ts +8 -0
- package/dist/server.js +5 -7
- package/dist/server.mjs +5 -7
- package/dist/vue.cjs +904 -2
- package/dist/vue.global.js +3 -3
- package/dist/vue.js +900 -2
- package/package.json +11 -9
package/dist/vue.global.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var IndieBob=(function(exports){'use strict';var ft=Object.defineProperty,pt=Object.defineProperties;var gt=Object.getOwnPropertyDescriptors;var F=Object.getOwnPropertySymbols;var mt=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable;var U=(e,t,n)=>t in e?ft(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))mt.call(t,n)&&U(e,n,t[n]);if(F)for(var n of F(t))ht.call(t,n)&&U(e,n,t[n]);return e},L=(e,t)=>pt(e,gt(t));var l=(e,t,n)=>new Promise((o,i)=>{var r=a=>{try{s(n.next(a));}catch(u){i(u);}},c=a=>{try{s(n.throw(a));}catch(u){i(u);}},s=a=>a.done?o(a.value):Promise.resolve(a.value).then(r,c);s((n=n.apply(e,t)).next());});var vt="https://www.indiebob.com/api/collect";function M(e){var t,n,o,i,r;if(!e.projectId||!e.projectId.startsWith("proj_"))throw new Error(`[IndieBob] Invalid projectId "${e.projectId}". Must start with "proj_".`);return {projectId:e.projectId,endpoint:(t=e.endpoint)!=null?t:vt,debug:(n=e.debug)!=null?n:false,respectDnt:(o=e.respectDnt)!=null?o:true,respectGpc:(i=e.respectGpc)!=null?i:true,autoDetect:(r=e.autoDetect)!=null?r:true}}var d="_ib_anon";function b(){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-",t="";if(typeof crypto!="undefined"&&crypto.getRandomValues){let n=new Uint8Array(21);crypto.getRandomValues(n);for(let o of n)t+=e[o%e.length];}else for(let n=0;n<21;n++)t+=e[Math.floor(Math.random()*e.length)];return t}function I(){try{let e=localStorage.getItem(d);return e||(e=b(),localStorage.setItem(d,e)),e}catch(e){try{let t=sessionStorage.getItem(d);return t||(t=b(),sessionStorage.setItem(d,t)),t}catch(t){return b()}}}function B(){try{localStorage.removeItem(d);}catch(e){}try{sessionStorage.removeItem(d);}catch(e){}}var S="_ib_session",E="_ib_session_last";function q(){try{return crypto.randomUUID()}catch(e){return Math.random().toString(36).slice(2)+Math.random().toString(36).slice(2)}}function _(){var e;try{let t=Date.now(),n=parseInt((e=sessionStorage.getItem(E))!=null?e:"0",10),o=sessionStorage.getItem(S),i=n>0&&t-n>18e5;return (!o||i)&&(o=q(),sessionStorage.setItem(S,o)),sessionStorage.setItem(E,String(t)),o}catch(t){return q()}}function j(){try{sessionStorage.removeItem(S);}catch(e){}try{sessionStorage.removeItem(E);}catch(e){}}var g="_ib_first_utm",Y="_ib_last_utm",m="_ib_referrer";function H(e){let t=new URLSearchParams(e),n={},o=false;return t.has("utm_source")?(n.source=t.get("utm_source"),o=true):t.get("ref")&&(n.source=t.get("ref"),o=true),t.has("utm_medium")&&(n.medium=t.get("utm_medium"),o=true),t.has("utm_campaign")&&(n.campaign=t.get("utm_campaign"),o=true),t.has("utm_term")&&(n.term=t.get("utm_term"),o=true),t.has("utm_content")&&(n.content=t.get("utm_content"),o=true),o?n:null}function K(e,t){let n=H(e);try{n&&!localStorage.getItem(g)&&localStorage.setItem(g,JSON.stringify(n)),n&&localStorage.setItem(Y,JSON.stringify(n)),t&&!localStorage.getItem(m)&&localStorage.setItem(m,t);}catch(o){}}function V(){try{let e=localStorage.getItem(g);return e?JSON.parse(e):void 0}catch(e){return}}function Q(){var e;try{return (e=localStorage.getItem(m))!=null?e:void 0}catch(t){return}}function z(e){var t;return (t=H(e))!=null?t:void 0}function X(){try{localStorage.removeItem(g);}catch(e){}try{localStorage.removeItem(Y);}catch(e){}try{localStorage.removeItem(m);}catch(e){}}var h="_ib_optout",yt="_ib_queue";function f(e){try{if(localStorage.getItem(h))return !1}catch(t){}return !(e.respectDnt&&typeof navigator!="undefined"&&(navigator.doNotTrack==="1"||navigator.msDoNotTrack==="1")||e.respectGpc&&typeof navigator!="undefined"&&navigator.globalPrivacyControl===true)}function $(){try{localStorage.setItem(h,"1");}catch(e){}B(),j(),X();try{localStorage.removeItem(yt);}catch(e){}}function J(){try{localStorage.removeItem(h);}catch(e){}}function G(){try{return !!localStorage.getItem(h)}catch(e){return false}}var bt=[1e3,2e3,4e3];function It(e){return l(this,null,function*(){return new Promise(t=>setTimeout(t,e))})}function w(e,t,n=false){return l(this,null,function*(){let o=JSON.stringify(e);if(n&&typeof navigator!="undefined"&&navigator.sendBeacon){let i=new Blob([o],{type:"text/plain;charset=UTF-8"}),r=navigator.sendBeacon(t.endpoint,i);return t.debug&&console.log("[IndieBob] sendBeacon:",r,e.batch.length,"events"),r}for(let i=0;i<3;i++){try{let r=yield fetch(t.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:o,keepalive:!0});if(r.ok)return t.debug&&console.log("[IndieBob] sent:",e.batch.length,"events"),!0;if(r.status>=400&&r.status<500)return t.debug&&console.warn("[IndieBob] 4xx error, not retrying:",r.status),!1}catch(r){t.debug&&console.warn("[IndieBob] fetch error (attempt",i+1,"):",r);}i<2&&(yield It(bt[i]));}return t.debug&&console.warn("[IndieBob] failed to send after",3,"attempts"),false})}var T="_ib_queue",St=10,Et=5e3,_t=50,v=class{constructor(t){this.queue=[];this.timer=null;this.flushing=false;this.config=t,this.startTimer(),this.setupVisibilityFlush(),this.setupOnlineFlush();}push(t){this.queue.push(t),this.queue.length>=St&&this.flush();}flush(t=false){return l(this,null,function*(){if(this.flushing&&!t||this.queue.length===0)return;this.flushing=true;let n=this.queue.splice(0);(yield w({batch:n},this.config,t))||this.pushToOfflineQueue(n),this.flushing=false;})}flushOfflineQueue(){return l(this,null,function*(){let t=this.getOfflineQueue();if(t.length===0)return;this.clearOfflineQueue(),yield w({batch:t},this.config);})}destroy(){this.timer&&clearInterval(this.timer);}startTimer(){this.timer=setInterval(()=>{this.queue.length>0&&this.flush();},Et);}setupVisibilityFlush(){typeof document!="undefined"&&(document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.flush(true);},{passive:true}),window.addEventListener("pagehide",()=>{this.flush(true);},{passive:true}));}setupOnlineFlush(){typeof window!="undefined"&&(window.addEventListener("online",()=>{this.flushOfflineQueue();}),navigator.onLine&&this.flushOfflineQueue());}pushToOfflineQueue(t){try{let i=[...this.getOfflineQueue(),...t].slice(-_t);localStorage.setItem(T,JSON.stringify(i));}catch(n){}}getOfflineQueue(){try{let t=localStorage.getItem(T);return t?JSON.parse(t):[]}catch(t){return []}}clearOfflineQueue(){try{localStorage.removeItem(T);}catch(t){}}};function W(){if(typeof window=="undefined")return "desktop";let e=window.innerWidth;return e<=768?"mobile":e<=1024?"tablet":"desktop"}function Z(){return typeof window=="undefined"?{width:0,height:0}:{width:window.innerWidth,height:window.innerHeight}}var wt=/^https?:\/\/[^/]*(stripe\.com|paypal\.com|paddle\.com|lemonsqueezy\.com|gumroad\.com)(\/|$)/i;function k(e){var x,A,P,C,D,N;let t=typeof window=="undefined",n=(x=e==null?void 0:e.path)!=null?x:t?"":window.location.pathname+window.location.search,o=t?"":window.location.href,i=(A=e==null?void 0:e.title)!=null?A:t?"":document.title,r=(P=e==null?void 0:e.referrer)!=null?P:t?"":document.referrer,c=!t&&(r===""||wt.test(r))&&(C=Q())!=null?C:r,s=Z(),a=W(),u=t?void 0:(D=z(window.location.search))!=null?D:V();return {page:{path:n,url:o,title:i,referrer:c},device:L(p({},s),{type:a}),utm:u,locale:t?"en":navigator.language,timezone:t?"UTC":(N=Intl.DateTimeFormat().resolvedOptions().timeZone)!=null?N:"UTC",sdkVersion:"0.2.3"}}function tt(e){if(typeof window=="undefined")return ()=>{};let t=history.pushState.bind(history),n=history.replaceState.bind(history);return history.pushState=function(...o){t(...o),e();},history.replaceState=function(...o){n(...o);},window.addEventListener("popstate",e),()=>{history.pushState=t,history.replaceState=n,window.removeEventListener("popstate",e);}}var Tt={signup:[/\/(sign-?up|register|join|create-?account|get-?started|onboard|registro|inscription|s-?inscrire|anmeldung|registrieren|cadastro|registrazione|aanmelden|inschrijven)/i],login:[/\/(log-?in|sign-?in|auth(\/login)?|iniciar-?sesion|connexion|se-?connecter|anmelden|einloggen|entrar|accesso|accedi|inloggen)/i],pricing:[/\/(pricing|plans|upgrade|subscribe|precios|tarifs|preise|precos|prezzi|prijzen)/i],checkout:[/\/(checkout|cart|basket|pay(ment)?|order|comprar|pagar|panier|caisse|warenkorb|kasse|carrinho|carrello|winkelwagen)/i],success:[/\/(success|thank-?you|thanks|confirmation|confirmed|complete[d]?|gracias|merci|danke|obrigado|grazie|bedankt)/i],onboarding:[/\/(onboarding|welcome|getting-?started|setup|bienvenido|bienvenue|willkommen|benvenuto|welkom)/i],contact:[/\/(contact|contacto|kontakt|contato|contatto|nous-?contacter)/i]},et={signup:"signup_start",login:"login_view",pricing:"pricing_view",checkout:"checkout_view",success:"success_view",onboarding:"onboarding_view",contact:"contact_view"};function kt(e,t){return e instanceof RegExp?e.test(t):t.includes(e)}function nt(e,t){var n;for(let o of Object.keys(et))if(((n=t==null?void 0:t[o])!=null?n:Tt[o]).some(r=>kt(r,e)))return et[o];return null}function ot(e){return e==="signup_start"?"signup_submit":e==="login_view"?"login_submit":e==="checkout_view"?"checkout_submit":null}function it(e,t){if(typeof document=="undefined")return ()=>{};let n=o=>{o.target instanceof HTMLFormElement&&t(e);};return document.addEventListener("submit",n,true),()=>document.removeEventListener("submit",n,true)}var R="ib_identified";function rt(){return typeof localStorage=="undefined"?true:!localStorage.getItem(R)}function st(){typeof localStorage!="undefined"&&localStorage.setItem(R,"1");}function at(){typeof localStorage!="undefined"&&localStorage.removeItem(R);}var ct="data-ib-event",ut="data-ib-";function lt(e){if(typeof document=="undefined")return ()=>{};let t=n=>{let o=n.target;for(;o&&o!==document.body;){let i=o.getAttribute(ct);if(i){let r={auto:true};for(let c of o.attributes)if(c.name.startsWith(ut)&&c.name!==ct){let s=c.name.slice(ut.length);r[s]=c.value;}e(i,r);return}o=o.parentElement;}};return document.addEventListener("click",t,true),()=>document.removeEventListener("click",t,true)}function dt(e){if(typeof document=="undefined")return ()=>{};let t=n=>{let o=n.target;for(;o&&o!==document.body;){if(o.tagName==="A"){let i=o.href;if(!i||!/^https?:\/\//.test(i))return;try{let r=new URL(i);r.hostname!==window.location.hostname&&e("outbound_click",{auto:!0,url:i,hostname:r.hostname});}catch(r){}return}o=o.parentElement;}};return document.addEventListener("click",t,true),()=>document.removeEventListener("click",t,true)}var y=class e{constructor(t){this.cleanupHistory=null;this.cleanupAttributes=null;this.cleanupOutbound=null;this.cleanupFormSubmit=null;if(this.config=t,this.queue=new v(t),typeof window!="undefined"&&(K(window.location.search,document.referrer),t.autoDetect!==false)){let n=typeof t.autoDetect=="object"?t.autoDetect:{};n.dataAttributes!==false&&(this.cleanupAttributes=lt((o,i)=>this.track(o,i))),n.outboundClicks!==false&&(this.cleanupOutbound=dt((o,i)=>this.track(o,i)));}}static init(t){let n=M(t);return new e(n)}page(t){var o;if(!f(this.config))return;let n=k(t);if(this.queue.push(this.buildEvent("page",{context:n})),this.config.autoDetect!==false){let i=n.page.path,r=typeof this.config.autoDetect=="object"?this.config.autoDetect:{},c={signup:r.signupPaths,login:r.loginPaths,pricing:r.pricingPaths,checkout:r.checkoutPaths,success:r.successPaths,onboarding:r.onboardingPaths,contact:r.contactPaths},s=nt(i,c);if(s&&(this.queue.push(this.buildEvent("track",{event:s,properties:{auto:true},context:n})),this.config.debug&&console.log(`[IndieBob] auto-detected: ${s} on ${i}`),r.formSubmit!==false)){(o=this.cleanupFormSubmit)==null||o.call(this);let a=ot(s);a&&(this.cleanupFormSubmit=it(a,u=>{this.queue.push(this.buildEvent("track",{event:u,properties:{auto:true}})),this.config.debug&&console.log(`[IndieBob] auto-detected: ${u}`);}));}}}track(t,n){f(this.config)&&this.queue.push(this.buildEvent("track",{event:t,properties:n}));}identify(t,n){if(f(this.config)&&(this.userId=t,this.queue.push(this.buildEvent("identify",{traits:n,userId:t})),this.config.autoDetect!==false)){let o=rt(),i=o?"signup":"login";this.queue.push(this.buildEvent("track",{event:i,properties:{auto:true}})),o&&st(),this.config.debug&&console.log(`[IndieBob] auto-detected: ${i} for ${t}`);}}revenue(t){var n;f(this.config)&&this.queue.push(this.buildEvent("revenue",{revenue:{amount:t.amount,currency:(n=t.currency)!=null?n:"USD",plan:t.plan,type:t.type}}));}optOut(){var t,n,o;this.queue.flush(),$(),at(),this.userId=void 0,(t=this.cleanupAttributes)==null||t.call(this),(n=this.cleanupOutbound)==null||n.call(this),(o=this.cleanupFormSubmit)==null||o.call(this),this.cleanupAttributes=null,this.cleanupOutbound=null,this.cleanupFormSubmit=null,this.config.debug&&console.log("[IndieBob] opted out");}optIn(){J(),this.config.debug&&console.log("[IndieBob] opted in");}isOptedOut(){return G()}flush(){return l(this,null,function*(){yield this.queue.flush();})}getAnonymousId(){return I()}getSessionId(){return _()}getConfig(){return Object.freeze(p({},this.config))}enableAutoPage(){var t;return (t=this.cleanupHistory)==null||t.call(this),this.cleanupHistory=tt(()=>this.page()),()=>{var n;(n=this.cleanupHistory)==null||n.call(this),this.cleanupHistory=null;}}buildEvent(t,n){var o,i;return {v:1,projectId:this.config.projectId,type:t,anonymousId:I(),userId:(o=this.userId)!=null?o:n.userId,sessionId:_(),timestamp:new Date().toISOString(),context:(i=n.context)!=null?i:k(),event:n.event,properties:n.properties,traits:n.traits,revenue:n.revenue}}};var Rt=Symbol("indiebob"),O=null,de={install(e,t){let n=y.init(t);O=n,e.provide(Rt,n),e.config.globalProperties.$bob=n;let o=e.config.globalProperties.$router;o&&o.afterEach(()=>{n.page();});}};function fe(){if(O)return O;throw new Error("[IndieBob] useTracker() called before IndieBobPlugin was installed.")}
|
|
2
|
-
exports.IndieBob=y;exports.IndieBobPlugin=
|
|
3
|
-
;
|
|
1
|
+
var IndieBob=(function(exports){'use strict';var it="https://www.indiebob.com/api/collect";function O(e){if(!e.projectId||!e.projectId.startsWith("proj_"))throw new Error(`[IndieBob] Invalid projectId "${e.projectId}". Must start with "proj_".`);return {projectId:e.projectId,endpoint:e.endpoint??it,debug:e.debug??false,respectDnt:e.respectDnt??true,respectGpc:e.respectGpc??true,autoDetect:e.autoDetect??true,hashMode:e.hashMode??false}}var l="_ib_anon";function u(){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-",t=new Uint8Array(21);if(typeof crypto<"u"&&crypto.getRandomValues)crypto.getRandomValues(t);else for(let o=0;o<21;o++)t[o]=Math.random()*64;let n="";for(let o of t)n+=e[o&63];return n}function b(){try{let e=localStorage.getItem(l);return e||(e=u(),localStorage.setItem(l,e)),e}catch{try{let e=sessionStorage.getItem(l);return e||(e=u(),sessionStorage.setItem(l,e)),e}catch{return u()}}}function A(){try{localStorage.removeItem(l);}catch{}try{sessionStorage.removeItem(l);}catch{}}var I="_ib_session",E="_ib_session_last",st=1800*1e3;function D(){try{return crypto.randomUUID()}catch{return u()}}function S(){try{let e=Date.now(),t=parseInt(sessionStorage.getItem(E)??"0",10),n=sessionStorage.getItem(I),o=t>0&&e-t>st;return (!n||o)&&(n=D(),sessionStorage.setItem(I,n)),sessionStorage.setItem(E,String(e)),n}catch{return D()}}function N(){try{sessionStorage.removeItem(I);}catch{}try{sessionStorage.removeItem(E);}catch{}}var g="_ib_first_utm",M="_ib_last_utm",m="_ib_referrer";function w(e){let t=new URLSearchParams(e),n={},o=false;!t.has("utm_source")&&t.get("ref")&&(n.source=t.get("ref"),o=true);for(let r of ["source","medium","campaign","term","content"])t.has("utm_"+r)&&(n[r]=t.get("utm_"+r),o=true);return o?n:null}function L(e,t){let n=w(e);try{n&&!localStorage.getItem(g)&&localStorage.setItem(g,JSON.stringify(n)),n&&localStorage.setItem(M,JSON.stringify(n)),t&&!localStorage.getItem(m)&&localStorage.setItem(m,t);}catch{}}function U(){try{let e=localStorage.getItem(g);return e?JSON.parse(e):void 0}catch{return}}function F(){try{return localStorage.getItem(m)??void 0}catch{return}}function j(){try{localStorage.removeItem(g);}catch{}try{localStorage.removeItem(M);}catch{}try{localStorage.removeItem(m);}catch{}}var f="ib_ignore";function K(e,t){let n=new URLSearchParams(e).get(f);return n==="1"?t.setItem(f,"1"):n==="0"&&t.removeItem(f),t.getItem(f)==="1"}function _(){try{return localStorage.getItem(f)==="1"}catch{return false}}function B(){return typeof navigator<"u"&&navigator.webdriver===true||_()}var h="_ib_optout",at="_ib_queue";function d(e){if(B())return false;try{if(localStorage.getItem(h))return !1}catch{}return !(e.respectDnt&&typeof navigator<"u"&&(navigator.doNotTrack==="1"||navigator.msDoNotTrack==="1")||e.respectGpc&&typeof navigator<"u"&&navigator.globalPrivacyControl===true)}function Y(){try{localStorage.setItem(h,"1");}catch{}A(),N(),j();try{localStorage.removeItem(at);}catch{}}function z(){try{localStorage.removeItem(h);}catch{}}function $(){try{return !!localStorage.getItem(h)}catch{return false}}function a(e,...t){e.debug&&console.log("[IndieBob]",...t);}async function x(e,t,n=false){let o=JSON.stringify(e);if(n&&typeof navigator<"u"&&navigator.sendBeacon){let r=new Blob([o],{type:"text/plain;charset=UTF-8"}),i=navigator.sendBeacon(t.endpoint,r);return a(t,"sendBeacon:",i,e.batch.length,"events"),i}for(let r=0;r<3;r++){try{let i=await fetch(t.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:o,keepalive:!0});if(i.ok)return a(t,"sent:",e.batch.length,"events"),!0;if(i.status>=400&&i.status<500)return a(t,"4xx error, not retrying:",i.status),!1}catch(i){a(t,"fetch error (attempt",r+1,"):",i);}r<2&&await new Promise(i=>setTimeout(i,1e3<<r));}return a(t,"failed to send after",3,"attempts"),false}var k="_ib_queue",ct=10,ut=5e3,lt=50,v=class{constructor(t,n){this.e=[];this.c=false;if(this.t=t,setInterval(()=>{this.e.length>0&&this.flush();},ut),typeof window>"u")return;let o=()=>{n?.(),this.flush(true);};document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&o();}),window.addEventListener("pagehide",o),window.addEventListener("online",()=>{this.p();}),navigator.onLine&&this.p();}push(t){this.e.push(t),this.e.length>=ct&&this.flush();}async flush(t=false){if(this.c&&!t||this.e.length===0)return;this.c=true;let n=this.e.splice(0);if(!await x({batch:n},this.t,t))try{let i=[...this.f(),...n].slice(-lt);localStorage.setItem(k,JSON.stringify(i));}catch{}this.c=false;}async p(){let t=this.f();if(t.length===0)return;try{localStorage.removeItem(k);}catch{}await x({batch:t},this.t);}f(){try{let t=localStorage.getItem(k);return t?JSON.parse(t):[]}catch{return []}}};function X(e,t){return e.pathname+e.search+(t?e.hash:"")}function H(e,t){if(typeof window>"u")return ()=>{};let n=history.pushState.bind(history),o=history.replaceState.bind(history);return history.pushState=function(...r){n(...r),e();},history.replaceState=function(...r){o(...r);},window.addEventListener("popstate",e),t&&window.addEventListener("hashchange",e),()=>{history.pushState=n,history.replaceState=o,window.removeEventListener("popstate",e),window.removeEventListener("hashchange",e);}}var dt=/^https?:\/\/[^/]*(stripe\.com|paypal\.com|paddle\.com|lemonsqueezy\.com|gumroad\.com)(\/|$)/i;function T(e,t){let n="0.3.0";if(typeof window>"u")return {page:{path:e?.path??"",url:"",title:e?.title??"",referrer:e?.referrer??""},device:{width:0,height:0,type:"desktop"},locale:"en",timezone:"UTC",sdkVersion:n};let o=e?.referrer??document.referrer,r=innerWidth;return {page:{path:e?.path??X(location,t),url:location.href,title:e?.title??document.title,referrer:o===""||dt.test(o)?F()??o:o},device:{width:r,height:innerHeight,type:r<=768?"mobile":r<=1024?"tablet":"desktop"},utm:w(location.search)??U(),locale:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone??"UTC",sdkVersion:n}}var pt=[["signup","signup_start",/\/(sign-?up|register|join|create-?account|get-?started|onboard|registro|inscription|s-?inscrire|anmeldung|registrieren|cadastro|registrazione|aanmelden|inschrijven)/i],["login","login_view",/\/(log-?in|sign-?in|auth(\/login)?|iniciar-?sesion|connexion|se-?connecter|anmelden|einloggen|entrar|accesso|accedi|inloggen)/i],["pricing","pricing_view",/\/(pricing|plans|upgrade|subscribe|precios|tarifs|preise|precos|prezzi|prijzen)/i],["checkout","checkout_view",/\/(checkout|cart|basket|pay(ment)?|order|comprar|pagar|panier|caisse|warenkorb|kasse|carrinho|carrello|winkelwagen)/i],["success","success_view",/\/(success|thank-?you|thanks|confirmation|confirmed|complete[d]?|gracias|merci|danke|obrigado|grazie|bedankt)/i],["onboarding","onboarding_view",/\/(onboarding|welcome|getting-?started|setup|bienvenido|bienvenue|willkommen|benvenuto|welkom)/i],["contact","contact_view",/\/(contact|contacto|kontakt|contato|contatto|nous-?contacter)/i]];function ft(e,t){return e instanceof RegExp?e.test(t):t.includes(e)}function V(e,t){for(let[n,o,r]of pt)if((t?.[`${n}Paths`]??[r]).some(c=>ft(c,e)))return o;return null}function G(e){let t=/^(signup|login|checkout)_/.exec(e);return t?t[1]+"_submit":null}function J(e,t){if(typeof document>"u")return ()=>{};let n=o=>{o.target instanceof HTMLFormElement&&t(e);};return document.addEventListener("submit",n,true),()=>document.removeEventListener("submit",n,true)}var R="ib_identified";function W(){return typeof localStorage>"u"?true:!localStorage.getItem(R)}function q(){typeof localStorage>"u"||localStorage.setItem(R,"1");}function Q(){typeof localStorage>"u"||localStorage.removeItem(R);}var Z="data-ib-event",tt="data-ib-";function et(e){for(;e&&e!==document.body;){let t=e.getAttribute(Z);if(t){let n={auto:true};for(let o of e.attributes)o.name.startsWith(tt)&&o.name!==Z&&(n[o.name.slice(tt.length)]=o.value);return [t,n]}e=e.parentElement;}return null}var gt=/\.(pdf|zip|dmg|exe|msi|pkg|apk|ipa|deb|rpm|appimage|t?gz|bz2|xz|tar|7z|rar|csv|xlsx?|docx?|pptx?|txt|epub|mp3|wav|mp4|mov|iso)$/i;function mt(e){let t=gt.exec(e);return t?t[1].toLowerCase():null}function ht(e,t,n,o){if(!/^https?:\/\//i.test(e))return null;try{let r=new URL(e),i=n&&mt(r.pathname);if(i)return ["file_download",{auto:!0,url:r.origin+r.pathname,path:r.pathname,ext:i}];if(o&&r.hostname!==t)return ["outbound_click",{auto:!0,url:e,hostname:r.hostname}]}catch{}return null}function nt(e,t,n,o){if(typeof document>"u")return ()=>{};let r=i=>{let c=i.target,s=c?.closest?.("a");for(let p of [t&&et(c),s&&ht(s.href,location.hostname,n,o)])p&&e(p[0],p[1]);};return document.addEventListener("click",r,true),()=>document.removeEventListener("click",r,true)}function vt(e,t,n){return t>n||e>=3e3}function yt(e,t,n){return n>0?Math.min(100,Math.round((e+t)/n*100)):0}function ot(){let e=0,t=0,n=0,o=0,r=()=>{let s=Date.now();t&&(e+=s-t),t=document.visibilityState==="visible"&&document.hasFocus()?s:0;},i=()=>{n=Math.max(n,yt(scrollY,innerHeight,Math.max(document.documentElement.scrollHeight,document.body?.scrollHeight??0)));},c=()=>{e=n=o=t=0,r();};for(let s of ["focus","blur"])window.addEventListener(s,r);return document.addEventListener("visibilitychange",r),window.addEventListener("scroll",i),c(),{y:i,b:c,I(s){if(s&&i(),r(),!vt(e,n,o))return null;let p={ms:Math.min(e,864e5),scroll:n};return e=0,o=n,p}}}var C={};function rt(){return typeof document<"u"&&(document.visibilityState==="hidden"||document.prerendering===true)}var y=class e{constructor(t){this.i=null;this.l=null;this.s=null;this.o=null;this.d=null;this.a=false;if(this.t=t,this.e=new v(t,()=>this.h(true)),typeof window<"u"){try{K(window.location.search,localStorage)&&console.info("IndieBob: this browser is excluded from analytics (ib_ignore)");}catch{}if(L(window.location.search,document.referrer),this.o=ot(),window.addEventListener("pageshow",n=>{n.persisted&&this.r!==void 0&&(this.r=void 0,this.page(this.g));}),t.autoDetect!==false){let n=typeof t.autoDetect=="object"?t.autoDetect:{};this.l=nt((o,r)=>this.track(o,r),n.dataAttributes!==false,n.fileDownloads!==false,n.outboundClicks!==false);}}}static init(t){var o;let n=O(t);return typeof window>"u"?new e(n):C[o=n.projectId]??(C[o]=new e(n))}page(t){if(!d(this.t))return;if(this.r===void 0&&rt()){if(this.m=t,!this.a){this.a=true;let o=()=>{this.a&&!rt()&&(this.a=false,this.page(this.m));};document.addEventListener("visibilitychange",o),document.addEventListener("prerenderingchange",o);}return}let n=T(t,this.t.hashMode);if(n.page.path!==this.r&&(this.h(false),this.r=n.page.path,this.g=t,this.d=n,this.o&&(this.o.b(),setTimeout(this.o.y,1e3)),this.e.push(this.n("page",{context:n})),this.t.autoDetect!==false)){let o=n.page.path,r=typeof this.t.autoDetect=="object"?this.t.autoDetect:{},i=V(o,r);if(i&&(this.e.push(this.n("track",{event:i,properties:{auto:true},context:n})),a(this.t,`auto-detected: ${i} on ${o}`),r.formSubmit!==false)){this.s?.();let c=G(i);c&&(this.s=J(c,s=>{this.e.push(this.n("track",{event:s,properties:{auto:true}})),a(this.t,`auto-detected: ${s}`);}));}}}track(t,n){d(this.t)&&this.e.push(this.n("track",{event:t,properties:n}));}identify(t,n,o){if(d(this.t)&&(this.u=t,this.e.push(this.n("identify",{traits:n,userId:t})),this.t.autoDetect!==false)){let i=(typeof o?.isNew=="boolean"?o.isNew:W())?"signup":"login";this.e.push(this.n("track",{event:i,properties:{auto:typeof o?.isNew!="boolean"}})),q(),a(this.t,`${i} for ${t}`);}}revenue(t){d(this.t)&&this.e.push(this.n("revenue",{revenue:{amount:t.amount,currency:t.currency??"USD",plan:t.plan,type:t.type}}));}optOut(){this.e.flush(),Y(),Q(),this.u=void 0,this.l?.(),this.s?.(),this.l=null,this.s=null,a(this.t,"opted out");}optIn(){z(),a(this.t,"opted in");}isOptedOut(){return $()}isIgnored(){return _()}async flush(){await this.e.flush();}getAnonymousId(){return b()}getSessionId(){return S()}getConfig(){return Object.freeze({...this.t})}enableAutoPage(){return this.i?.(),this.i=H(()=>this.page(),this.t.hashMode),()=>{this.i?.(),this.i=null;}}h(t){let n=this.d&&this.o?.I(t);n&&d(this.t)&&this.e.push(this.n("engagement",{context:this.d,engagement:n}));}n(t,n){return {...n,v:1,id:u(),projectId:this.t.projectId,type:t,anonymousId:b(),userId:this.u??n.userId,sessionId:S(),timestamp:new Date().toISOString(),context:n.context??T(void 0,this.t.hashMode)}}};var bt=Symbol("indiebob"),P=null,re={install(e,t){let n=y.init(t);P=n,e.provide(bt,n),e.config.globalProperties.$bob=n;let o=e.config.globalProperties.$router;o&&o.afterEach(()=>{n.page();});}};function ie(){if(P)return P;throw new Error("[IndieBob] useTracker() called before IndieBobPlugin was installed.")}
|
|
2
|
+
exports.IndieBob=y;exports.IndieBobPlugin=re;exports.useTracker=ie;return exports;})({});
|
|
3
|
+
;IndieBob.IndieBob&&(IndieBob=Object.assign(IndieBob.IndieBob,IndieBob));
|