flowsery 1.0.1 → 1.0.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/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/main.hash.js +1 -1
- package/dist/main.js +1 -1
- package/dist/script.hash.js +1 -1
- package/dist/script.js +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var h=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o)=>{let n=Math.random()*16|0;return(o==="x"?n:n&3|8).toString(16)})},D=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0};var i=()=>{return window.__flowsery_config||null},b=()=>{return document.querySelector("script[data-fl-website-id]")},B=()=>{let o=i();if(o)return o.websiteId;return b()?.getAttribute("data-fl-website-id")||""},d=()=>{let o=i();if(o?.apiBase)return o.apiBase;let n=b();return n?.getAttribute("data-api")||n?.src?.replace(/\/js\/(?:script|main)(?:\.hash)?\.js.*/,"")||""},E=()=>{return"https://analytics.flowsery.com/analytics"},G=()=>{let o=i();if(o?.domain)return o.domain;return b()?.getAttribute("data-domain")||location.hostname},F=()=>{let o=i();if(o)return!!o.cookieless;return b()?.hasAttribute("data-cookieless")??!1},Qo=new Set(["localhost","127.0.0.1","[::1]"]),R=()=>{return Qo.has(location.hostname)||location.hostname.endsWith(".local")},O=()=>{let o=i();if(o)return!!o.local;return b()?.hasAttribute("data-local")??!1},T=()=>{return location.protocol==="file:"},_=()=>{let o=i();if(o)return!!o.allowFileProtocol;return b()?.hasAttribute("data-allow-file-protocol")??!1},S=()=>{try{return window.self!==window.top}catch{return!0}},a=()=>{let o=i();if(o)return!!o.allowIframe;return b()?.hasAttribute("data-debug")??!1};var M=()=>{let o=i();if(o)return!!o.hashMode;return b()?.src?.includes(".hash.js")??!1},oo=()=>{let o=i();if(o?.allowedHostnames)return o.allowedHostnames;let t=b()?.getAttribute("data-allowed-hostnames");return t?t.split(",").map((c)=>c.trim()).filter(Boolean):[]},no=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},to=()=>{let o=new URLSearchParams(window.location.search),n={};for(let t of["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref","source","via"]){let c=o.get(t);if(c)n[t]=c}return n};var l=(o,n)=>{let c=`${d()}/api/track`,r=B(),f=JSON.stringify({...n,websiteId:r,type:o});if(typeof navigator.sendBeacon==="function"){let s=new Blob([f],{type:"application/json"});if(navigator.sendBeacon(c,s))return}fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:f,keepalive:!0}).catch(()=>{})};var W="_fs_vid",$="_fs_sid",j="_fs_sts",Zo=1800000,V="_fs_vid",U="_fs_sid",qo=(o)=>{let n=document.cookie.match(new RegExp(`(?:^|; )${o}=([^;]*)`));return n?decodeURIComponent(n[1]):null},co=(o,n,t)=>{let c=new Date(Date.now()+t*86400000).toUTCString(),r=G(),f=r?`;domain=.${r}`:"";document.cookie=`${o}=${encodeURIComponent(n)};expires=${c};path=/${f};SameSite=Lax;Secure`},go=(o)=>{let n=G(),t=n?`;domain=.${n}`:"";document.cookie=`${o}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${t};SameSite=Lax;Secure`},Xo=()=>{let o=new URLSearchParams(window.location.search),n=o.get(V)||void 0,t=o.get(U)||void 0;if(n||t){o.delete(V),o.delete(U);let c=o.toString(),r=window.location.pathname+(c?`?${c}`:"")+window.location.hash;history.replaceState(null,"",r)}return{vid:n,sid:t}},J=null,ro=()=>{if(J===null)J=Xo();return J},x=()=>{if(F())return;let o=ro();if(o.vid){co(W,o.vid,730);let t=o.vid;return o.vid=void 0,t}let n=qo(W);if(!n)n=h(),co(W,n,730);return n},u=()=>{if(F())return;let o=ro();if(o.sid){let r=o.sid;return sessionStorage.setItem($,r),sessionStorage.setItem(j,Date.now().toString()),o.sid=void 0,r}let n=Date.now(),t=parseInt(sessionStorage.getItem(j)||"0",10),c=sessionStorage.getItem($);if(!c||n-t>Zo)c=h(),sessionStorage.setItem($,c);return sessionStorage.setItem(j,n.toString()),c},fo=()=>{if(F())return;sessionStorage.setItem(j,Date.now().toString())},Q=()=>{let o=x(),n=u();return{...o&&{_fs_vid:o},...n&&{_fs_sid:n}}},m=(o)=>{let n=Q(),t=new URL(o);if(n._fs_vid)t.searchParams.set(V,n._fs_vid);if(n._fs_sid)t.searchParams.set(U,n._fs_sid);return t.toString()},Y=()=>{go(W),sessionStorage.removeItem($),sessionStorage.removeItem(j),J=null};var Ho=5000,N=0,Z=0,q=null,ho=()=>{let o=document.documentElement,n=window.scrollY||o.scrollTop,t=o.scrollHeight-o.clientHeight;if(t<=0)return 100;return Math.min(100,Math.round(n/t*100))},K=()=>{N++},xo=()=>{let o=ho();Z=Math.max(Z,o);let n=x(),t=u();l("heartbeat",{...n&&{visitorUid:n},...t&&{sessionUid:t},path:location.pathname+location.search,scrollDepth:Z,isVisible:document.visibilityState==="visible",interactionCount:N}),fo()},uo=()=>{N=0,Z=0},lo=()=>{document.addEventListener("click",K,{passive:!0}),document.addEventListener("scroll",K,{passive:!0}),document.addEventListener("keydown",K,{passive:!0}),q=setInterval(xo,Ho),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")xo()})},P=()=>{if(q)clearInterval(q),q=null};var eo="",so=!1,w=()=>{let o=M(),n=o?location.href:location.pathname+location.search;if(n===eo)return;eo=n,uo();let t=to(),c=x(),r=u(),f=o?location.pathname+location.search+location.hash:location.pathname+location.search;if(l("pageview",{...c&&{visitorUid:c},...r&&{sessionUid:r},hostname:location.hostname,path:f,referrer:document.referrer||void 0,title:document.title||void 0,screenWidth:window.screen?.width,screenHeight:window.screen?.height,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||void 0,language:navigator.language||void 0,utmSource:t.utm_source,utmMedium:t.utm_medium,utmCampaign:t.utm_campaign,utmTerm:t.utm_term,utmContent:t.utm_content,ref:t.ref,source:t.source,via:t.via}),!so){so=!0;let s=E();if(s){let y=JSON.stringify({type:"geo",websiteId:B(),visitorUid:c||void 0,sessionUid:r||void 0});try{fetch(`${s}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:y,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},io=()=>{w();let{pushState:o,replaceState:n}=history;if(history.pushState=function(...t){o.apply(this,t),w()},history.replaceState=function(...t){n.apply(this,t),w()},window.addEventListener("popstate",()=>w()),M())window.addEventListener("hashchange",()=>w())};var bo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t)return;try{let c=new URL(t);if(c.protocol!=="http:"&&c.protocol!=="https:")return;if(c.hostname===location.hostname)return;let r=x(),f=u();if(!r||!f)return;l("exit_click",{visitorUid:r,sessionUid:f,hostname:location.hostname,url:t})}catch{}})};var Go=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,po=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t||!Go.test(t))return;let c=x(),r=u();l("goal",{...c&&{visitorUid:c},...r&&{sessionUid:r},name:"file_download",metadata:{url:t}})})};var p=(o,n)=>{let t=x(),c=u();l("goal",{...t&&{visitorUid:t},...c&&{sessionUid:c},name:o,metadata:n})};var v="data-fs-goal",wo="data-fs-goal-",Mo=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(wo)&&c.name!==v){let r=c.name.slice(wo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},yo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest(`[${v}]`);if(!n)return;let t=n.getAttribute(v);if(!t)return;let c=Mo(n);p(t,c)})};var g="data-fs-scroll",mo="data-fs-scroll-threshold",L="data-fs-scroll-delay",Bo="data-fs-scroll-",Vo=new Set([g,mo,L]),jo=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(Bo)&&!Vo.has(c.name)){let r=c.name.slice(Bo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},zo=()=>{let o=document.querySelectorAll(`[${g}]`);if(!o.length)return;let n=new Set,t=new IntersectionObserver((c)=>{for(let r of c){let f=r.target;if(!r.isIntersecting||n.has(f))continue;let s=f.getAttribute(g);if(!s)continue;let y=parseInt(f.getAttribute(L)||"0",10)||0,e=()=>{if(n.has(f))return;n.add(f),t.unobserve(f);let z=jo(f);p(s,z)};if(y>0)setTimeout(e,y);else e()}},{threshold:0});for(let c of Array.from(o)){let r=parseFloat(c.getAttribute(mo)||"0.5");if(r!==0.5){let f=new IntersectionObserver((s)=>{for(let y of s){let e=y.target;if(!y.isIntersecting||n.has(e))continue;let z=e.getAttribute(g);if(!z)continue;let C=parseInt(e.getAttribute(L)||"0",10)||0,A=()=>{if(n.has(e))return;n.add(e),f.unobserve(e);let Jo=jo(e);p(z,Jo)};if(C>0)setTimeout(A,C);else A()}},{threshold:r});f.observe(c)}else t.observe(c)}};var k=null,Fo=()=>{if(!k)k=new Set(oo());return k},Uo=(o)=>{let n=Fo();if(!n.size)return!1;for(let t of n)if(o===t||o.endsWith(`.${t}`))return!0;return!1},Wo=()=>{if(!Fo().size)return;document.addEventListener("click",(n)=>{let t=n.target.closest("a");if(!t)return;let c=t.href;if(!c)return;try{let r=new URL(c);if(r.hostname===location.hostname)return;if(!Uo(r.hostname))return;t.href=m(c)}catch{}})};var X=(o)=>{let n=x(),t=u();l("payment",{...n&&{visitorUid:n},...t&&{sessionUid:t},...o.amount!=null&&{amount:o.amount},...o.currency&&{currency:o.currency},...o.transactionId&&{transactionId:o.transactionId},...o.email&&{email:o.email},...o.name&&{name:o.name},...o.customerId&&{customerId:o.customerId},...o.isRenewal!=null&&{isRenewal:o.isRenewal},...o.isRefund!=null&&{isRefund:o.isRefund}})};var H=(o)=>{let n=x();l("identify",{...n&&{visitorUid:n},userId:o.userId,name:o.name,image:o.image,profileData:o.profileData})};var $o=(o)=>{let[n,...t]=o;switch(n){case"identify":H(t[0]);break;case"payment":X(t[0]);break;default:p(n,t[0]);break}},I=()=>{if(D())return;if(!B())return;if(no())return;if(R()&&!O())return;if(T()&&!_())return;if(S()&&!a())return;io(),lo(),bo(),po(),yo(),zo(),Wo();let o=window,n=o.flowsery?.q||[];for(let t of n)$o(t);o.flowsery=function(...t){$o(t)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",I);else I();var hn=async(o)=>{let n=window;return n.__flowsery_config=o,I(),{trackEvent:p,trackPayment:X,trackPageview:w,identify:H,stop:P,reset:Y,getTrackingParams:Q,buildCrossDomainUrl:m,getVisitorId:x,getSessionId:u}};export{X as trackPayment,w as trackPageview,p as trackEvent,P as stopHeartbeat,Y as reset,hn as initFlowsery,H as identify,x as getVisitorId,Q as getTrackingParams,u as getSessionId,m as buildCrossDomainUrl};
|
|
1
|
+
var h=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o)=>{let n=Math.random()*16|0;return(o==="x"?n:n&3|8).toString(16)})},D=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0};var i=()=>{return window.__flowsery_config||null},b=()=>{return document.querySelector("script[data-fl-website-id]")},m=()=>{let o=i();if(o)return o.websiteId;return b()?.getAttribute("data-fl-website-id")||""},E=()=>{let o=i();if(o?.apiBase)return o.apiBase;let n=b();return n?.getAttribute("data-api")||n?.src?.replace(/\/js\/(?:script|main)(?:\.hash)?\.js.*/,"")||""},d=()=>{return"https://analytics.flowsery.com/analytics"},G=()=>{let o=i();if(o?.domain)return o.domain;return b()?.getAttribute("data-domain")||location.hostname},F=()=>{let o=i();if(o)return!!o.cookieless;return b()?.hasAttribute("data-cookieless")??!1},Qo=new Set(["localhost","127.0.0.1","[::1]"]),R=()=>{return Qo.has(location.hostname)||location.hostname.endsWith(".local")},O=()=>{let o=i();if(o)return!!o.local;return b()?.hasAttribute("data-local")??!1},T=()=>{return location.protocol==="file:"},_=()=>{let o=i();if(o)return!!o.allowFileProtocol;return b()?.hasAttribute("data-allow-file-protocol")??!1},S=()=>{try{return window.self!==window.top}catch{return!0}},a=()=>{let o=i();if(o)return!!o.allowIframe;return b()?.hasAttribute("data-allow-iframe")??!1};var M=()=>{let o=i();if(o)return!!o.hashMode;return b()?.src?.includes(".hash.js")??!1},oo=()=>{let o=i();if(o?.allowedHostnames)return o.allowedHostnames;let t=b()?.getAttribute("data-allowed-hostnames");return t?t.split(",").map((c)=>c.trim()).filter(Boolean):[]},no=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},to=()=>{let o=new URLSearchParams(window.location.search),n={};for(let t of["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref","source","via"]){let c=o.get(t);if(c)n[t]=c}return n};var l=(o,n)=>{let c=`${E()}/api/track`,r=m(),f=JSON.stringify({...n,websiteId:r,type:o});if(typeof navigator.sendBeacon==="function"){let s=new Blob([f],{type:"application/json"});if(navigator.sendBeacon(c,s))return}fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:f,keepalive:!0}).catch(()=>{})};var W="_fs_vid",$="_fs_sid",B="_fs_sts",Zo=1800000,V="_fs_vid",U="_fs_sid",qo=(o)=>{let n=document.cookie.match(new RegExp(`(?:^|; )${o}=([^;]*)`));return n?decodeURIComponent(n[1]):null},co=(o,n,t)=>{let c=new Date(Date.now()+t*86400000).toUTCString(),r=G(),f=r?`;domain=.${r}`:"";document.cookie=`${o}=${encodeURIComponent(n)};expires=${c};path=/${f};SameSite=Lax;Secure`},Xo=(o)=>{let n=G(),t=n?`;domain=.${n}`:"";document.cookie=`${o}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${t};SameSite=Lax;Secure`},go=()=>{let o=new URLSearchParams(window.location.search),n=o.get(V)||void 0,t=o.get(U)||void 0;if(n||t){o.delete(V),o.delete(U);let c=o.toString(),r=window.location.pathname+(c?`?${c}`:"")+window.location.hash;history.replaceState(null,"",r)}return{vid:n,sid:t}},J=null,ro=()=>{if(J===null)J=go();return J},x=()=>{if(F())return;let o=ro();if(o.vid){co(W,o.vid,730);let t=o.vid;return o.vid=void 0,t}let n=qo(W);if(!n)n=h(),co(W,n,730);return n},u=()=>{if(F())return;let o=ro();if(o.sid){let r=o.sid;return sessionStorage.setItem($,r),sessionStorage.setItem(B,Date.now().toString()),o.sid=void 0,r}let n=Date.now(),t=parseInt(sessionStorage.getItem(B)||"0",10),c=sessionStorage.getItem($);if(!c||n-t>Zo)c=h(),sessionStorage.setItem($,c);return sessionStorage.setItem(B,n.toString()),c},fo=()=>{if(F())return;sessionStorage.setItem(B,Date.now().toString())},Q=()=>{let o=x(),n=u();return{...o&&{_fs_vid:o},...n&&{_fs_sid:n}}},j=(o)=>{let n=Q(),t=new URL(o);if(n._fs_vid)t.searchParams.set(V,n._fs_vid);if(n._fs_sid)t.searchParams.set(U,n._fs_sid);return t.toString()},Y=()=>{Xo(W),sessionStorage.removeItem($),sessionStorage.removeItem(B),J=null};var Ho=5000,N=0,Z=0,q=null,ho=()=>{let o=document.documentElement,n=window.scrollY||o.scrollTop,t=o.scrollHeight-o.clientHeight;if(t<=0)return 100;return Math.min(100,Math.round(n/t*100))},K=()=>{N++},xo=()=>{let o=ho();Z=Math.max(Z,o);let n=x(),t=u();l("heartbeat",{...n&&{visitorUid:n},...t&&{sessionUid:t},path:location.pathname+location.search,scrollDepth:Z,isVisible:document.visibilityState==="visible",interactionCount:N}),fo()},uo=()=>{N=0,Z=0},lo=()=>{document.addEventListener("click",K,{passive:!0}),document.addEventListener("scroll",K,{passive:!0}),document.addEventListener("keydown",K,{passive:!0}),q=setInterval(xo,Ho),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")xo()})},P=()=>{if(q)clearInterval(q),q=null};var eo="",so=!1,w=()=>{let o=M(),n=o?location.href:location.pathname+location.search;if(n===eo)return;eo=n,uo();let t=to(),c=x(),r=u(),f=o?location.pathname+location.search+location.hash:location.pathname+location.search;if(l("pageview",{...c&&{visitorUid:c},...r&&{sessionUid:r},hostname:location.hostname,path:f,referrer:document.referrer||void 0,title:document.title||void 0,screenWidth:window.screen?.width,screenHeight:window.screen?.height,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||void 0,language:navigator.language||void 0,utmSource:t.utm_source,utmMedium:t.utm_medium,utmCampaign:t.utm_campaign,utmTerm:t.utm_term,utmContent:t.utm_content,ref:t.ref,source:t.source,via:t.via}),!so){so=!0;let s=d();if(s){let y=JSON.stringify({type:"geo",websiteId:m(),visitorUid:c||void 0,sessionUid:r||void 0});try{fetch(`${s}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:y,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},io=()=>{w();let{pushState:o,replaceState:n}=history;if(history.pushState=function(...t){o.apply(this,t),w()},history.replaceState=function(...t){n.apply(this,t),w()},window.addEventListener("popstate",()=>w()),M())window.addEventListener("hashchange",()=>w())};var bo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t)return;try{let c=new URL(t);if(c.protocol!=="http:"&&c.protocol!=="https:")return;if(c.hostname===location.hostname)return;let r=x(),f=u();if(!r||!f)return;l("exit_click",{visitorUid:r,sessionUid:f,hostname:location.hostname,url:t})}catch{}})};var Go=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,po=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t||!Go.test(t))return;let c=x(),r=u();l("goal",{...c&&{visitorUid:c},...r&&{sessionUid:r},name:"file_download",metadata:{url:t}})})};var p=(o,n)=>{let t=x(),c=u();l("goal",{...t&&{visitorUid:t},...c&&{sessionUid:c},name:o,metadata:n})};var v="data-fs-goal",wo="data-fs-goal-",Mo=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(wo)&&c.name!==v){let r=c.name.slice(wo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},yo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest(`[${v}]`);if(!n)return;let t=n.getAttribute(v);if(!t)return;let c=Mo(n);p(t,c)})};var X="data-fs-scroll",jo="data-fs-scroll-threshold",L="data-fs-scroll-delay",mo="data-fs-scroll-",Vo=new Set([X,jo,L]),Bo=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(mo)&&!Vo.has(c.name)){let r=c.name.slice(mo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},zo=()=>{let o=document.querySelectorAll(`[${X}]`);if(!o.length)return;let n=new Set,t=new IntersectionObserver((c)=>{for(let r of c){let f=r.target;if(!r.isIntersecting||n.has(f))continue;let s=f.getAttribute(X);if(!s)continue;let y=parseInt(f.getAttribute(L)||"0",10)||0,e=()=>{if(n.has(f))return;n.add(f),t.unobserve(f);let z=Bo(f);p(s,z)};if(y>0)setTimeout(e,y);else e()}},{threshold:0});for(let c of Array.from(o)){let r=parseFloat(c.getAttribute(jo)||"0.5");if(r!==0.5){let f=new IntersectionObserver((s)=>{for(let y of s){let e=y.target;if(!y.isIntersecting||n.has(e))continue;let z=e.getAttribute(X);if(!z)continue;let C=parseInt(e.getAttribute(L)||"0",10)||0,A=()=>{if(n.has(e))return;n.add(e),f.unobserve(e);let Jo=Bo(e);p(z,Jo)};if(C>0)setTimeout(A,C);else A()}},{threshold:r});f.observe(c)}else t.observe(c)}};var k=null,Fo=()=>{if(!k)k=new Set(oo());return k},Uo=(o)=>{let n=Fo();if(!n.size)return!1;for(let t of n)if(o===t||o.endsWith(`.${t}`))return!0;return!1},Wo=()=>{if(!Fo().size)return;document.addEventListener("click",(n)=>{let t=n.target.closest("a");if(!t)return;let c=t.href;if(!c)return;try{let r=new URL(c);if(r.hostname===location.hostname)return;if(!Uo(r.hostname))return;t.href=j(c)}catch{}})};var g=(o)=>{let n=x(),t=u();l("payment",{...n&&{visitorUid:n},...t&&{sessionUid:t},...o.amount!=null&&{amount:o.amount},...o.currency&&{currency:o.currency},...o.transactionId&&{transactionId:o.transactionId},...o.email&&{email:o.email},...o.name&&{name:o.name},...o.customerId&&{customerId:o.customerId},...o.isRenewal!=null&&{isRenewal:o.isRenewal},...o.isRefund!=null&&{isRefund:o.isRefund}})};var H=(o)=>{let n=x();l("identify",{...n&&{visitorUid:n},userId:o.userId,name:o.name,email:o.email,image:o.image,profileData:o.profileData})};var $o=(o)=>{let[n,...t]=o;switch(n){case"identify":H(t[0]);break;case"payment":g(t[0]);break;default:p(n,t[0]);break}},I=()=>{if(D())return;if(!m())return;if(no())return;if(R()&&!O())return;if(T()&&!_())return;if(S()&&!a())return;io(),lo(),bo(),po(),yo(),zo(),Wo();let o=window,n=o.flowsery?.q||[];for(let t of n)$o(t);o.flowsery=function(...t){$o(t)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",I);else I();var hn=async(o)=>{let n=window;return n.__flowsery_config=o,I(),{trackEvent:p,trackPayment:g,trackPageview:w,identify:H,stop:P,reset:Y,getTrackingParams:Q,buildCrossDomainUrl:j,getVisitorId:x,getSessionId:u}};export{g as trackPayment,w as trackPageview,p as trackEvent,P as stopHeartbeat,Y as reset,hn as initFlowsery,H as identify,x as getVisitorId,Q as getTrackingParams,u as getSessionId,j as buildCrossDomainUrl};
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var h=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o)=>{let n=Math.random()*16|0;return(o==="x"?n:n&3|8).toString(16)})},D=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0};var i=()=>{return window.__flowsery_config||null},b=()=>{return document.querySelector("script[data-fl-website-id]")},B=()=>{let o=i();if(o)return o.websiteId;return b()?.getAttribute("data-fl-website-id")||""},d=()=>{let o=i();if(o?.apiBase)return o.apiBase;let n=b();return n?.getAttribute("data-api")||n?.src?.replace(/\/js\/(?:script|main)(?:\.hash)?\.js.*/,"")||""},E=()=>{return"https://analytics.flowsery.com/analytics"},G=()=>{let o=i();if(o?.domain)return o.domain;return b()?.getAttribute("data-domain")||location.hostname},F=()=>{let o=i();if(o)return!!o.cookieless;return b()?.hasAttribute("data-cookieless")??!1},Qo=new Set(["localhost","127.0.0.1","[::1]"]),R=()=>{return Qo.has(location.hostname)||location.hostname.endsWith(".local")},O=()=>{let o=i();if(o)return!!o.local;return b()?.hasAttribute("data-local")??!1},T=()=>{return location.protocol==="file:"},_=()=>{let o=i();if(o)return!!o.allowFileProtocol;return b()?.hasAttribute("data-allow-file-protocol")??!1},S=()=>{try{return window.self!==window.top}catch{return!0}},a=()=>{let o=i();if(o)return!!o.allowIframe;return b()?.hasAttribute("data-debug")??!1};var M=()=>{let o=i();if(o)return!!o.hashMode;return b()?.src?.includes(".hash.js")??!1},oo=()=>{let o=i();if(o?.allowedHostnames)return o.allowedHostnames;let t=b()?.getAttribute("data-allowed-hostnames");return t?t.split(",").map((c)=>c.trim()).filter(Boolean):[]},no=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},to=()=>{let o=new URLSearchParams(window.location.search),n={};for(let t of["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref","source","via"]){let c=o.get(t);if(c)n[t]=c}return n};var l=(o,n)=>{let c=`${d()}/api/track`,r=B(),f=JSON.stringify({...n,websiteId:r,type:o});if(typeof navigator.sendBeacon==="function"){let s=new Blob([f],{type:"application/json"});if(navigator.sendBeacon(c,s))return}fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:f,keepalive:!0}).catch(()=>{})};var W="_fs_vid",$="_fs_sid",j="_fs_sts",Zo=1800000,V="_fs_vid",U="_fs_sid",qo=(o)=>{let n=document.cookie.match(new RegExp(`(?:^|; )${o}=([^;]*)`));return n?decodeURIComponent(n[1]):null},co=(o,n,t)=>{let c=new Date(Date.now()+t*86400000).toUTCString(),r=G(),f=r?`;domain=.${r}`:"";document.cookie=`${o}=${encodeURIComponent(n)};expires=${c};path=/${f};SameSite=Lax;Secure`},go=(o)=>{let n=G(),t=n?`;domain=.${n}`:"";document.cookie=`${o}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${t};SameSite=Lax;Secure`},Xo=()=>{let o=new URLSearchParams(window.location.search),n=o.get(V)||void 0,t=o.get(U)||void 0;if(n||t){o.delete(V),o.delete(U);let c=o.toString(),r=window.location.pathname+(c?`?${c}`:"")+window.location.hash;history.replaceState(null,"",r)}return{vid:n,sid:t}},J=null,ro=()=>{if(J===null)J=Xo();return J},x=()=>{if(F())return;let o=ro();if(o.vid){co(W,o.vid,730);let t=o.vid;return o.vid=void 0,t}let n=qo(W);if(!n)n=h(),co(W,n,730);return n},u=()=>{if(F())return;let o=ro();if(o.sid){let r=o.sid;return sessionStorage.setItem($,r),sessionStorage.setItem(j,Date.now().toString()),o.sid=void 0,r}let n=Date.now(),t=parseInt(sessionStorage.getItem(j)||"0",10),c=sessionStorage.getItem($);if(!c||n-t>Zo)c=h(),sessionStorage.setItem($,c);return sessionStorage.setItem(j,n.toString()),c},fo=()=>{if(F())return;sessionStorage.setItem(j,Date.now().toString())},Q=()=>{let o=x(),n=u();return{...o&&{_fs_vid:o},...n&&{_fs_sid:n}}},m=(o)=>{let n=Q(),t=new URL(o);if(n._fs_vid)t.searchParams.set(V,n._fs_vid);if(n._fs_sid)t.searchParams.set(U,n._fs_sid);return t.toString()},Y=()=>{go(W),sessionStorage.removeItem($),sessionStorage.removeItem(j),J=null};var Ho=5000,N=0,Z=0,q=null,ho=()=>{let o=document.documentElement,n=window.scrollY||o.scrollTop,t=o.scrollHeight-o.clientHeight;if(t<=0)return 100;return Math.min(100,Math.round(n/t*100))},K=()=>{N++},xo=()=>{let o=ho();Z=Math.max(Z,o);let n=x(),t=u();l("heartbeat",{...n&&{visitorUid:n},...t&&{sessionUid:t},path:location.pathname+location.search,scrollDepth:Z,isVisible:document.visibilityState==="visible",interactionCount:N}),fo()},uo=()=>{N=0,Z=0},lo=()=>{document.addEventListener("click",K,{passive:!0}),document.addEventListener("scroll",K,{passive:!0}),document.addEventListener("keydown",K,{passive:!0}),q=setInterval(xo,Ho),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")xo()})},P=()=>{if(q)clearInterval(q),q=null};var eo="",so=!1,w=()=>{let o=M(),n=o?location.href:location.pathname+location.search;if(n===eo)return;eo=n,uo();let t=to(),c=x(),r=u(),f=o?location.pathname+location.search+location.hash:location.pathname+location.search;if(l("pageview",{...c&&{visitorUid:c},...r&&{sessionUid:r},hostname:location.hostname,path:f,referrer:document.referrer||void 0,title:document.title||void 0,screenWidth:window.screen?.width,screenHeight:window.screen?.height,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||void 0,language:navigator.language||void 0,utmSource:t.utm_source,utmMedium:t.utm_medium,utmCampaign:t.utm_campaign,utmTerm:t.utm_term,utmContent:t.utm_content,ref:t.ref,source:t.source,via:t.via}),!so){so=!0;let s=E();if(s){let y=JSON.stringify({type:"geo",websiteId:B(),visitorUid:c||void 0,sessionUid:r||void 0});try{fetch(`${s}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:y,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},io=()=>{w();let{pushState:o,replaceState:n}=history;if(history.pushState=function(...t){o.apply(this,t),w()},history.replaceState=function(...t){n.apply(this,t),w()},window.addEventListener("popstate",()=>w()),M())window.addEventListener("hashchange",()=>w())};var bo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t)return;try{let c=new URL(t);if(c.protocol!=="http:"&&c.protocol!=="https:")return;if(c.hostname===location.hostname)return;let r=x(),f=u();if(!r||!f)return;l("exit_click",{visitorUid:r,sessionUid:f,hostname:location.hostname,url:t})}catch{}})};var Go=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,po=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t||!Go.test(t))return;let c=x(),r=u();l("goal",{...c&&{visitorUid:c},...r&&{sessionUid:r},name:"file_download",metadata:{url:t}})})};var p=(o,n)=>{let t=x(),c=u();l("goal",{...t&&{visitorUid:t},...c&&{sessionUid:c},name:o,metadata:n})};var v="data-fs-goal",wo="data-fs-goal-",Mo=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(wo)&&c.name!==v){let r=c.name.slice(wo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},yo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest(`[${v}]`);if(!n)return;let t=n.getAttribute(v);if(!t)return;let c=Mo(n);p(t,c)})};var g="data-fs-scroll",mo="data-fs-scroll-threshold",L="data-fs-scroll-delay",Bo="data-fs-scroll-",Vo=new Set([g,mo,L]),jo=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(Bo)&&!Vo.has(c.name)){let r=c.name.slice(Bo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},zo=()=>{let o=document.querySelectorAll(`[${g}]`);if(!o.length)return;let n=new Set,t=new IntersectionObserver((c)=>{for(let r of c){let f=r.target;if(!r.isIntersecting||n.has(f))continue;let s=f.getAttribute(g);if(!s)continue;let y=parseInt(f.getAttribute(L)||"0",10)||0,e=()=>{if(n.has(f))return;n.add(f),t.unobserve(f);let z=jo(f);p(s,z)};if(y>0)setTimeout(e,y);else e()}},{threshold:0});for(let c of Array.from(o)){let r=parseFloat(c.getAttribute(mo)||"0.5");if(r!==0.5){let f=new IntersectionObserver((s)=>{for(let y of s){let e=y.target;if(!y.isIntersecting||n.has(e))continue;let z=e.getAttribute(g);if(!z)continue;let C=parseInt(e.getAttribute(L)||"0",10)||0,A=()=>{if(n.has(e))return;n.add(e),f.unobserve(e);let Jo=jo(e);p(z,Jo)};if(C>0)setTimeout(A,C);else A()}},{threshold:r});f.observe(c)}else t.observe(c)}};var k=null,Fo=()=>{if(!k)k=new Set(oo());return k},Uo=(o)=>{let n=Fo();if(!n.size)return!1;for(let t of n)if(o===t||o.endsWith(`.${t}`))return!0;return!1},Wo=()=>{if(!Fo().size)return;document.addEventListener("click",(n)=>{let t=n.target.closest("a");if(!t)return;let c=t.href;if(!c)return;try{let r=new URL(c);if(r.hostname===location.hostname)return;if(!Uo(r.hostname))return;t.href=m(c)}catch{}})};var X=(o)=>{let n=x(),t=u();l("payment",{...n&&{visitorUid:n},...t&&{sessionUid:t},...o.amount!=null&&{amount:o.amount},...o.currency&&{currency:o.currency},...o.transactionId&&{transactionId:o.transactionId},...o.email&&{email:o.email},...o.name&&{name:o.name},...o.customerId&&{customerId:o.customerId},...o.isRenewal!=null&&{isRenewal:o.isRenewal},...o.isRefund!=null&&{isRefund:o.isRefund}})};var H=(o)=>{let n=x();l("identify",{...n&&{visitorUid:n},userId:o.userId,name:o.name,image:o.image,profileData:o.profileData})};var $o=(o)=>{let[n,...t]=o;switch(n){case"identify":H(t[0]);break;case"payment":X(t[0]);break;default:p(n,t[0]);break}},I=()=>{if(D())return;if(!B())return;if(no())return;if(R()&&!O())return;if(T()&&!_())return;if(S()&&!a())return;io(),lo(),bo(),po(),yo(),zo(),Wo();let o=window,n=o.flowsery?.q||[];for(let t of n)$o(t);o.flowsery=function(...t){$o(t)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",I);else I();var hn=async(o)=>{let n=window;return n.__flowsery_config=o,I(),{trackEvent:p,trackPayment:X,trackPageview:w,identify:H,stop:P,reset:Y,getTrackingParams:Q,buildCrossDomainUrl:m,getVisitorId:x,getSessionId:u}};export{X as trackPayment,w as trackPageview,p as trackEvent,P as stopHeartbeat,Y as reset,hn as initFlowsery,H as identify,x as getVisitorId,Q as getTrackingParams,u as getSessionId,m as buildCrossDomainUrl};
|
|
1
|
+
var h=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o)=>{let n=Math.random()*16|0;return(o==="x"?n:n&3|8).toString(16)})},D=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0};var i=()=>{return window.__flowsery_config||null},b=()=>{return document.querySelector("script[data-fl-website-id]")},m=()=>{let o=i();if(o)return o.websiteId;return b()?.getAttribute("data-fl-website-id")||""},E=()=>{let o=i();if(o?.apiBase)return o.apiBase;let n=b();return n?.getAttribute("data-api")||n?.src?.replace(/\/js\/(?:script|main)(?:\.hash)?\.js.*/,"")||""},d=()=>{return"https://analytics.flowsery.com/analytics"},G=()=>{let o=i();if(o?.domain)return o.domain;return b()?.getAttribute("data-domain")||location.hostname},F=()=>{let o=i();if(o)return!!o.cookieless;return b()?.hasAttribute("data-cookieless")??!1},Qo=new Set(["localhost","127.0.0.1","[::1]"]),R=()=>{return Qo.has(location.hostname)||location.hostname.endsWith(".local")},O=()=>{let o=i();if(o)return!!o.local;return b()?.hasAttribute("data-local")??!1},T=()=>{return location.protocol==="file:"},_=()=>{let o=i();if(o)return!!o.allowFileProtocol;return b()?.hasAttribute("data-allow-file-protocol")??!1},S=()=>{try{return window.self!==window.top}catch{return!0}},a=()=>{let o=i();if(o)return!!o.allowIframe;return b()?.hasAttribute("data-allow-iframe")??!1};var M=()=>{let o=i();if(o)return!!o.hashMode;return b()?.src?.includes(".hash.js")??!1},oo=()=>{let o=i();if(o?.allowedHostnames)return o.allowedHostnames;let t=b()?.getAttribute("data-allowed-hostnames");return t?t.split(",").map((c)=>c.trim()).filter(Boolean):[]},no=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},to=()=>{let o=new URLSearchParams(window.location.search),n={};for(let t of["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref","source","via"]){let c=o.get(t);if(c)n[t]=c}return n};var l=(o,n)=>{let c=`${E()}/api/track`,r=m(),f=JSON.stringify({...n,websiteId:r,type:o});if(typeof navigator.sendBeacon==="function"){let s=new Blob([f],{type:"application/json"});if(navigator.sendBeacon(c,s))return}fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:f,keepalive:!0}).catch(()=>{})};var W="_fs_vid",$="_fs_sid",B="_fs_sts",Zo=1800000,V="_fs_vid",U="_fs_sid",qo=(o)=>{let n=document.cookie.match(new RegExp(`(?:^|; )${o}=([^;]*)`));return n?decodeURIComponent(n[1]):null},co=(o,n,t)=>{let c=new Date(Date.now()+t*86400000).toUTCString(),r=G(),f=r?`;domain=.${r}`:"";document.cookie=`${o}=${encodeURIComponent(n)};expires=${c};path=/${f};SameSite=Lax;Secure`},Xo=(o)=>{let n=G(),t=n?`;domain=.${n}`:"";document.cookie=`${o}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${t};SameSite=Lax;Secure`},go=()=>{let o=new URLSearchParams(window.location.search),n=o.get(V)||void 0,t=o.get(U)||void 0;if(n||t){o.delete(V),o.delete(U);let c=o.toString(),r=window.location.pathname+(c?`?${c}`:"")+window.location.hash;history.replaceState(null,"",r)}return{vid:n,sid:t}},J=null,ro=()=>{if(J===null)J=go();return J},x=()=>{if(F())return;let o=ro();if(o.vid){co(W,o.vid,730);let t=o.vid;return o.vid=void 0,t}let n=qo(W);if(!n)n=h(),co(W,n,730);return n},u=()=>{if(F())return;let o=ro();if(o.sid){let r=o.sid;return sessionStorage.setItem($,r),sessionStorage.setItem(B,Date.now().toString()),o.sid=void 0,r}let n=Date.now(),t=parseInt(sessionStorage.getItem(B)||"0",10),c=sessionStorage.getItem($);if(!c||n-t>Zo)c=h(),sessionStorage.setItem($,c);return sessionStorage.setItem(B,n.toString()),c},fo=()=>{if(F())return;sessionStorage.setItem(B,Date.now().toString())},Q=()=>{let o=x(),n=u();return{...o&&{_fs_vid:o},...n&&{_fs_sid:n}}},j=(o)=>{let n=Q(),t=new URL(o);if(n._fs_vid)t.searchParams.set(V,n._fs_vid);if(n._fs_sid)t.searchParams.set(U,n._fs_sid);return t.toString()},Y=()=>{Xo(W),sessionStorage.removeItem($),sessionStorage.removeItem(B),J=null};var Ho=5000,N=0,Z=0,q=null,ho=()=>{let o=document.documentElement,n=window.scrollY||o.scrollTop,t=o.scrollHeight-o.clientHeight;if(t<=0)return 100;return Math.min(100,Math.round(n/t*100))},K=()=>{N++},xo=()=>{let o=ho();Z=Math.max(Z,o);let n=x(),t=u();l("heartbeat",{...n&&{visitorUid:n},...t&&{sessionUid:t},path:location.pathname+location.search,scrollDepth:Z,isVisible:document.visibilityState==="visible",interactionCount:N}),fo()},uo=()=>{N=0,Z=0},lo=()=>{document.addEventListener("click",K,{passive:!0}),document.addEventListener("scroll",K,{passive:!0}),document.addEventListener("keydown",K,{passive:!0}),q=setInterval(xo,Ho),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")xo()})},P=()=>{if(q)clearInterval(q),q=null};var eo="",so=!1,w=()=>{let o=M(),n=o?location.href:location.pathname+location.search;if(n===eo)return;eo=n,uo();let t=to(),c=x(),r=u(),f=o?location.pathname+location.search+location.hash:location.pathname+location.search;if(l("pageview",{...c&&{visitorUid:c},...r&&{sessionUid:r},hostname:location.hostname,path:f,referrer:document.referrer||void 0,title:document.title||void 0,screenWidth:window.screen?.width,screenHeight:window.screen?.height,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||void 0,language:navigator.language||void 0,utmSource:t.utm_source,utmMedium:t.utm_medium,utmCampaign:t.utm_campaign,utmTerm:t.utm_term,utmContent:t.utm_content,ref:t.ref,source:t.source,via:t.via}),!so){so=!0;let s=d();if(s){let y=JSON.stringify({type:"geo",websiteId:m(),visitorUid:c||void 0,sessionUid:r||void 0});try{fetch(`${s}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:y,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},io=()=>{w();let{pushState:o,replaceState:n}=history;if(history.pushState=function(...t){o.apply(this,t),w()},history.replaceState=function(...t){n.apply(this,t),w()},window.addEventListener("popstate",()=>w()),M())window.addEventListener("hashchange",()=>w())};var bo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t)return;try{let c=new URL(t);if(c.protocol!=="http:"&&c.protocol!=="https:")return;if(c.hostname===location.hostname)return;let r=x(),f=u();if(!r||!f)return;l("exit_click",{visitorUid:r,sessionUid:f,hostname:location.hostname,url:t})}catch{}})};var Go=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,po=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t||!Go.test(t))return;let c=x(),r=u();l("goal",{...c&&{visitorUid:c},...r&&{sessionUid:r},name:"file_download",metadata:{url:t}})})};var p=(o,n)=>{let t=x(),c=u();l("goal",{...t&&{visitorUid:t},...c&&{sessionUid:c},name:o,metadata:n})};var v="data-fs-goal",wo="data-fs-goal-",Mo=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(wo)&&c.name!==v){let r=c.name.slice(wo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},yo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest(`[${v}]`);if(!n)return;let t=n.getAttribute(v);if(!t)return;let c=Mo(n);p(t,c)})};var X="data-fs-scroll",jo="data-fs-scroll-threshold",L="data-fs-scroll-delay",mo="data-fs-scroll-",Vo=new Set([X,jo,L]),Bo=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(mo)&&!Vo.has(c.name)){let r=c.name.slice(mo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},zo=()=>{let o=document.querySelectorAll(`[${X}]`);if(!o.length)return;let n=new Set,t=new IntersectionObserver((c)=>{for(let r of c){let f=r.target;if(!r.isIntersecting||n.has(f))continue;let s=f.getAttribute(X);if(!s)continue;let y=parseInt(f.getAttribute(L)||"0",10)||0,e=()=>{if(n.has(f))return;n.add(f),t.unobserve(f);let z=Bo(f);p(s,z)};if(y>0)setTimeout(e,y);else e()}},{threshold:0});for(let c of Array.from(o)){let r=parseFloat(c.getAttribute(jo)||"0.5");if(r!==0.5){let f=new IntersectionObserver((s)=>{for(let y of s){let e=y.target;if(!y.isIntersecting||n.has(e))continue;let z=e.getAttribute(X);if(!z)continue;let C=parseInt(e.getAttribute(L)||"0",10)||0,A=()=>{if(n.has(e))return;n.add(e),f.unobserve(e);let Jo=Bo(e);p(z,Jo)};if(C>0)setTimeout(A,C);else A()}},{threshold:r});f.observe(c)}else t.observe(c)}};var k=null,Fo=()=>{if(!k)k=new Set(oo());return k},Uo=(o)=>{let n=Fo();if(!n.size)return!1;for(let t of n)if(o===t||o.endsWith(`.${t}`))return!0;return!1},Wo=()=>{if(!Fo().size)return;document.addEventListener("click",(n)=>{let t=n.target.closest("a");if(!t)return;let c=t.href;if(!c)return;try{let r=new URL(c);if(r.hostname===location.hostname)return;if(!Uo(r.hostname))return;t.href=j(c)}catch{}})};var g=(o)=>{let n=x(),t=u();l("payment",{...n&&{visitorUid:n},...t&&{sessionUid:t},...o.amount!=null&&{amount:o.amount},...o.currency&&{currency:o.currency},...o.transactionId&&{transactionId:o.transactionId},...o.email&&{email:o.email},...o.name&&{name:o.name},...o.customerId&&{customerId:o.customerId},...o.isRenewal!=null&&{isRenewal:o.isRenewal},...o.isRefund!=null&&{isRefund:o.isRefund}})};var H=(o)=>{let n=x();l("identify",{...n&&{visitorUid:n},userId:o.userId,name:o.name,email:o.email,image:o.image,profileData:o.profileData})};var $o=(o)=>{let[n,...t]=o;switch(n){case"identify":H(t[0]);break;case"payment":g(t[0]);break;default:p(n,t[0]);break}},I=()=>{if(D())return;if(!m())return;if(no())return;if(R()&&!O())return;if(T()&&!_())return;if(S()&&!a())return;io(),lo(),bo(),po(),yo(),zo(),Wo();let o=window,n=o.flowsery?.q||[];for(let t of n)$o(t);o.flowsery=function(...t){$o(t)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",I);else I();var hn=async(o)=>{let n=window;return n.__flowsery_config=o,I(),{trackEvent:p,trackPayment:g,trackPageview:w,identify:H,stop:P,reset:Y,getTrackingParams:Q,buildCrossDomainUrl:j,getVisitorId:x,getSessionId:u}};export{g as trackPayment,w as trackPageview,p as trackEvent,P as stopHeartbeat,Y as reset,hn as initFlowsery,H as identify,x as getVisitorId,Q as getTrackingParams,u as getSessionId,j as buildCrossDomainUrl};
|
package/dist/main.hash.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var{defineProperty:M,getOwnPropertyNames:qo,getOwnPropertyDescriptor:go}=Object,Xo=Object.prototype.hasOwnProperty;function Ho(o){return this[o]}var ho=(o)=>{var n=(d??=new WeakMap).get(o),t;if(n)return n;if(n=M({},"__esModule",{value:!0}),o&&typeof o==="object"||typeof o==="function"){for(var c of qo(o))if(!Xo.call(n,c))M(n,c,{get:Ho.bind(o,c),enumerable:!(t=go(o,c))||t.enumerable})}return d.set(o,n),n},d;var Go=(o)=>o;function Mo(o,n){this[o]=Go.bind(null,n)}var Vo=(o,n)=>{for(var t in n)M(o,t,{get:n[t],enumerable:!0,configurable:!0,set:Mo.bind(n,t)})};var Eo={};Vo(Eo,{trackPayment:()=>F,trackPageview:()=>w,trackEvent:()=>s,stopHeartbeat:()=>h,reset:()=>g,initFlowsery:()=>Do,identify:()=>W,getVisitorId:()=>x,getTrackingParams:()=>z,getSessionId:()=>u,buildCrossDomainUrl:()=>j});var V=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o)=>{let n=Math.random()*16|0;return(o==="x"?n:n&3|8).toString(16)})},E=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0};var b=()=>{return window.__flowsery_config||null},p=()=>{return document.querySelector("script[data-fl-website-id]")},B=()=>{let o=b();if(o)return o.websiteId;return p()?.getAttribute("data-fl-website-id")||""},R=()=>{let o=b();if(o?.apiBase)return o.apiBase;let n=p();return n?.getAttribute("data-api")||n?.src?.replace(/\/js\/(?:script|main)(?:\.hash)?\.js.*/,"")||""},O=()=>{return"https://analytics.flowsery.com/analytics"},U=()=>{let o=b();if(o?.domain)return o.domain;return p()?.getAttribute("data-domain")||location.hostname},J=()=>{let o=b();if(o)return!!o.cookieless;return p()?.hasAttribute("data-cookieless")??!1},Uo=new Set(["localhost","127.0.0.1","[::1]"]),T=()=>{return Uo.has(location.hostname)||location.hostname.endsWith(".local")},_=()=>{let o=b();if(o)return!!o.local;return p()?.hasAttribute("data-local")??!1},S=()=>{return location.protocol==="file:"},a=()=>{let o=b();if(o)return!!o.allowFileProtocol;return p()?.hasAttribute("data-allow-file-protocol")??!1},oo=()=>{try{return window.self!==window.top}catch{return!0}},no=()=>{let o=b();if(o)return!!o.allowIframe;return p()?.hasAttribute("data-debug")??!1};var Y=()=>{let o=b();if(o)return!!o.hashMode;return p()?.src?.includes(".hash.js")??!1},to=()=>{let o=b();if(o?.allowedHostnames)return o.allowedHostnames;let t=p()?.getAttribute("data-allowed-hostnames");return t?t.split(",").map((c)=>c.trim()).filter(Boolean):[]},co=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},ro=()=>{let o=new URLSearchParams(window.location.search),n={};for(let t of["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref","source","via"]){let c=o.get(t);if(c)n[t]=c}return n};var l=(o,n)=>{let c=`${R()}/api/track`,r=B(),f=JSON.stringify({...n,websiteId:r,type:o});if(typeof navigator.sendBeacon==="function"){let i=new Blob([f],{type:"application/json"});if(navigator.sendBeacon(c,i))return}fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:f,keepalive:!0}).catch(()=>{})};var Q="_fs_vid",Z="_fs_sid",m="_fs_sts",Yo=1800000,K="_fs_vid",N="_fs_sid",Ko=(o)=>{let n=document.cookie.match(new RegExp(`(?:^|; )${o}=([^;]*)`));return n?decodeURIComponent(n[1]):null},fo=(o,n,t)=>{let c=new Date(Date.now()+t*86400000).toUTCString(),r=U(),f=r?`;domain=.${r}`:"";document.cookie=`${o}=${encodeURIComponent(n)};expires=${c};path=/${f};SameSite=Lax;Secure`},No=(o)=>{let n=U(),t=n?`;domain=.${n}`:"";document.cookie=`${o}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${t};SameSite=Lax;Secure`},Po=()=>{let o=new URLSearchParams(window.location.search),n=o.get(K)||void 0,t=o.get(N)||void 0;if(n||t){o.delete(K),o.delete(N);let c=o.toString(),r=window.location.pathname+(c?`?${c}`:"")+window.location.hash;history.replaceState(null,"",r)}return{vid:n,sid:t}},q=null,xo=()=>{if(q===null)q=Po();return q},x=()=>{if(J())return;let o=xo();if(o.vid){fo(Q,o.vid,730);let t=o.vid;return o.vid=void 0,t}let n=Ko(Q);if(!n)n=V(),fo(Q,n,730);return n},u=()=>{if(J())return;let o=xo();if(o.sid){let r=o.sid;return sessionStorage.setItem(Z,r),sessionStorage.setItem(m,Date.now().toString()),o.sid=void 0,r}let n=Date.now(),t=parseInt(sessionStorage.getItem(m)||"0",10),c=sessionStorage.getItem(Z);if(!c||n-t>Yo)c=V(),sessionStorage.setItem(Z,c);return sessionStorage.setItem(m,n.toString()),c},uo=()=>{if(J())return;sessionStorage.setItem(m,Date.now().toString())},z=()=>{let o=x(),n=u();return{...o&&{_fs_vid:o},...n&&{_fs_sid:n}}},j=(o)=>{let n=z(),t=new URL(o);if(n._fs_vid)t.searchParams.set(K,n._fs_vid);if(n._fs_sid)t.searchParams.set(N,n._fs_sid);return t.toString()},g=()=>{No(Q),sessionStorage.removeItem(Z),sessionStorage.removeItem(m),q=null};var vo=5000,v=0,X=0,H=null,Lo=()=>{let o=document.documentElement,n=window.scrollY||o.scrollTop,t=o.scrollHeight-o.clientHeight;if(t<=0)return 100;return Math.min(100,Math.round(n/t*100))},P=()=>{v++},lo=()=>{let o=Lo();X=Math.max(X,o);let n=x(),t=u();l("heartbeat",{...n&&{visitorUid:n},...t&&{sessionUid:t},path:location.pathname+location.search,scrollDepth:X,isVisible:document.visibilityState==="visible",interactionCount:v}),uo()},eo=()=>{v=0,X=0},so=()=>{document.addEventListener("click",P,{passive:!0}),document.addEventListener("scroll",P,{passive:!0}),document.addEventListener("keydown",P,{passive:!0}),H=setInterval(lo,vo),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")lo()})},h=()=>{if(H)clearInterval(H),H=null};var io="",bo=!1,w=()=>{let o=Y(),n=o?location.href:location.pathname+location.search;if(n===io)return;io=n,eo();let t=ro(),c=x(),r=u(),f=o?location.pathname+location.search+location.hash:location.pathname+location.search;if(l("pageview",{...c&&{visitorUid:c},...r&&{sessionUid:r},hostname:location.hostname,path:f,referrer:document.referrer||void 0,title:document.title||void 0,screenWidth:window.screen?.width,screenHeight:window.screen?.height,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||void 0,language:navigator.language||void 0,utmSource:t.utm_source,utmMedium:t.utm_medium,utmCampaign:t.utm_campaign,utmTerm:t.utm_term,utmContent:t.utm_content,ref:t.ref,source:t.source,via:t.via}),!bo){bo=!0;let i=O();if(i){let y=JSON.stringify({type:"geo",websiteId:B(),visitorUid:c||void 0,sessionUid:r||void 0});try{fetch(`${i}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:y,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},po=()=>{w();let{pushState:o,replaceState:n}=history;if(history.pushState=function(...t){o.apply(this,t),w()},history.replaceState=function(...t){n.apply(this,t),w()},window.addEventListener("popstate",()=>w()),Y())window.addEventListener("hashchange",()=>w())};var wo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t)return;try{let c=new URL(t);if(c.protocol!=="http:"&&c.protocol!=="https:")return;if(c.hostname===location.hostname)return;let r=x(),f=u();if(!r||!f)return;l("exit_click",{visitorUid:r,sessionUid:f,hostname:location.hostname,url:t})}catch{}})};var ko=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,yo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t||!ko.test(t))return;let c=x(),r=u();l("goal",{...c&&{visitorUid:c},...r&&{sessionUid:r},name:"file_download",metadata:{url:t}})})};var s=(o,n)=>{let t=x(),c=u();l("goal",{...t&&{visitorUid:t},...c&&{sessionUid:c},name:o,metadata:n})};var L="data-fs-goal",Bo="data-fs-goal-",Io=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(Bo)&&c.name!==L){let r=c.name.slice(Bo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},jo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest(`[${L}]`);if(!n)return;let t=n.getAttribute(L);if(!t)return;let c=Io(n);s(t,c)})};var G="data-fs-scroll",Fo="data-fs-scroll-threshold",k="data-fs-scroll-delay",mo="data-fs-scroll-",Co=new Set([G,Fo,k]),zo=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(mo)&&!Co.has(c.name)){let r=c.name.slice(mo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},Wo=()=>{let o=document.querySelectorAll(`[${G}]`);if(!o.length)return;let n=new Set,t=new IntersectionObserver((c)=>{for(let r of c){let f=r.target;if(!r.isIntersecting||n.has(f))continue;let i=f.getAttribute(G);if(!i)continue;let y=parseInt(f.getAttribute(k)||"0",10)||0,e=()=>{if(n.has(f))return;n.add(f),t.unobserve(f);let $=zo(f);s(i,$)};if(y>0)setTimeout(e,y);else e()}},{threshold:0});for(let c of Array.from(o)){let r=parseFloat(c.getAttribute(Fo)||"0.5");if(r!==0.5){let f=new IntersectionObserver((i)=>{for(let y of i){let e=y.target;if(!y.isIntersecting||n.has(e))continue;let $=e.getAttribute(G);if(!$)continue;let A=parseInt(e.getAttribute(k)||"0",10)||0,D=()=>{if(n.has(e))return;n.add(e),f.unobserve(e);let Zo=zo(e);s($,Zo)};if(A>0)setTimeout(D,A);else D()}},{threshold:r});f.observe(c)}else t.observe(c)}};var I=null,$o=()=>{if(!I)I=new Set(to());return I},Ao=(o)=>{let n=$o();if(!n.size)return!1;for(let t of n)if(o===t||o.endsWith(`.${t}`))return!0;return!1},Jo=()=>{if(!$o().size)return;document.addEventListener("click",(n)=>{let t=n.target.closest("a");if(!t)return;let c=t.href;if(!c)return;try{let r=new URL(c);if(r.hostname===location.hostname)return;if(!Ao(r.hostname))return;t.href=j(c)}catch{}})};var F=(o)=>{let n=x(),t=u();l("payment",{...n&&{visitorUid:n},...t&&{sessionUid:t},...o.amount!=null&&{amount:o.amount},...o.currency&&{currency:o.currency},...o.transactionId&&{transactionId:o.transactionId},...o.email&&{email:o.email},...o.name&&{name:o.name},...o.customerId&&{customerId:o.customerId},...o.isRenewal!=null&&{isRenewal:o.isRenewal},...o.isRefund!=null&&{isRefund:o.isRefund}})};var W=(o)=>{let n=x();l("identify",{...n&&{visitorUid:n},userId:o.userId,name:o.name,image:o.image,profileData:o.profileData})};var Qo=(o)=>{let[n,...t]=o;switch(n){case"identify":W(t[0]);break;case"payment":F(t[0]);break;default:s(n,t[0]);break}},C=()=>{if(E())return;if(!B())return;if(co())return;if(T()&&!_())return;if(S()&&!a())return;if(oo()&&!no())return;po(),so(),wo(),yo(),jo(),Wo(),Jo();let o=window,n=o.flowsery?.q||[];for(let t of n)Qo(t);o.flowsery=function(...t){Qo(t)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",C);else C();var Do=async(o)=>{let n=window;return n.__flowsery_config=o,C(),{trackEvent:s,trackPayment:F,trackPageview:w,identify:W,stop:h,reset:g,getTrackingParams:z,buildCrossDomainUrl:j,getVisitorId:x,getSessionId:u}};})();
|
|
1
|
+
(()=>{var{defineProperty:M,getOwnPropertyNames:qo,getOwnPropertyDescriptor:Xo}=Object,go=Object.prototype.hasOwnProperty;function Ho(o){return this[o]}var ho=(o)=>{var n=(E??=new WeakMap).get(o),t;if(n)return n;if(n=M({},"__esModule",{value:!0}),o&&typeof o==="object"||typeof o==="function"){for(var c of qo(o))if(!go.call(n,c))M(n,c,{get:Ho.bind(o,c),enumerable:!(t=Xo(o,c))||t.enumerable})}return E.set(o,n),n},E;var Go=(o)=>o;function Mo(o,n){this[o]=Go.bind(null,n)}var Vo=(o,n)=>{for(var t in n)M(o,t,{get:n[t],enumerable:!0,configurable:!0,set:Mo.bind(n,t)})};var Eo={};Vo(Eo,{trackPayment:()=>F,trackPageview:()=>w,trackEvent:()=>s,stopHeartbeat:()=>h,reset:()=>X,initFlowsery:()=>Do,identify:()=>W,getVisitorId:()=>x,getTrackingParams:()=>z,getSessionId:()=>u,buildCrossDomainUrl:()=>B});var V=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o)=>{let n=Math.random()*16|0;return(o==="x"?n:n&3|8).toString(16)})},d=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0};var b=()=>{return window.__flowsery_config||null},p=()=>{return document.querySelector("script[data-fl-website-id]")},m=()=>{let o=b();if(o)return o.websiteId;return p()?.getAttribute("data-fl-website-id")||""},R=()=>{let o=b();if(o?.apiBase)return o.apiBase;let n=p();return n?.getAttribute("data-api")||n?.src?.replace(/\/js\/(?:script|main)(?:\.hash)?\.js.*/,"")||""},O=()=>{return"https://analytics.flowsery.com/analytics"},U=()=>{let o=b();if(o?.domain)return o.domain;return p()?.getAttribute("data-domain")||location.hostname},J=()=>{let o=b();if(o)return!!o.cookieless;return p()?.hasAttribute("data-cookieless")??!1},Uo=new Set(["localhost","127.0.0.1","[::1]"]),T=()=>{return Uo.has(location.hostname)||location.hostname.endsWith(".local")},_=()=>{let o=b();if(o)return!!o.local;return p()?.hasAttribute("data-local")??!1},S=()=>{return location.protocol==="file:"},a=()=>{let o=b();if(o)return!!o.allowFileProtocol;return p()?.hasAttribute("data-allow-file-protocol")??!1},oo=()=>{try{return window.self!==window.top}catch{return!0}},no=()=>{let o=b();if(o)return!!o.allowIframe;return p()?.hasAttribute("data-allow-iframe")??!1};var Y=()=>{let o=b();if(o)return!!o.hashMode;return p()?.src?.includes(".hash.js")??!1},to=()=>{let o=b();if(o?.allowedHostnames)return o.allowedHostnames;let t=p()?.getAttribute("data-allowed-hostnames");return t?t.split(",").map((c)=>c.trim()).filter(Boolean):[]},co=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},ro=()=>{let o=new URLSearchParams(window.location.search),n={};for(let t of["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref","source","via"]){let c=o.get(t);if(c)n[t]=c}return n};var l=(o,n)=>{let c=`${R()}/api/track`,r=m(),f=JSON.stringify({...n,websiteId:r,type:o});if(typeof navigator.sendBeacon==="function"){let i=new Blob([f],{type:"application/json"});if(navigator.sendBeacon(c,i))return}fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:f,keepalive:!0}).catch(()=>{})};var Q="_fs_vid",Z="_fs_sid",j="_fs_sts",Yo=1800000,K="_fs_vid",N="_fs_sid",Ko=(o)=>{let n=document.cookie.match(new RegExp(`(?:^|; )${o}=([^;]*)`));return n?decodeURIComponent(n[1]):null},fo=(o,n,t)=>{let c=new Date(Date.now()+t*86400000).toUTCString(),r=U(),f=r?`;domain=.${r}`:"";document.cookie=`${o}=${encodeURIComponent(n)};expires=${c};path=/${f};SameSite=Lax;Secure`},No=(o)=>{let n=U(),t=n?`;domain=.${n}`:"";document.cookie=`${o}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${t};SameSite=Lax;Secure`},Po=()=>{let o=new URLSearchParams(window.location.search),n=o.get(K)||void 0,t=o.get(N)||void 0;if(n||t){o.delete(K),o.delete(N);let c=o.toString(),r=window.location.pathname+(c?`?${c}`:"")+window.location.hash;history.replaceState(null,"",r)}return{vid:n,sid:t}},q=null,xo=()=>{if(q===null)q=Po();return q},x=()=>{if(J())return;let o=xo();if(o.vid){fo(Q,o.vid,730);let t=o.vid;return o.vid=void 0,t}let n=Ko(Q);if(!n)n=V(),fo(Q,n,730);return n},u=()=>{if(J())return;let o=xo();if(o.sid){let r=o.sid;return sessionStorage.setItem(Z,r),sessionStorage.setItem(j,Date.now().toString()),o.sid=void 0,r}let n=Date.now(),t=parseInt(sessionStorage.getItem(j)||"0",10),c=sessionStorage.getItem(Z);if(!c||n-t>Yo)c=V(),sessionStorage.setItem(Z,c);return sessionStorage.setItem(j,n.toString()),c},uo=()=>{if(J())return;sessionStorage.setItem(j,Date.now().toString())},z=()=>{let o=x(),n=u();return{...o&&{_fs_vid:o},...n&&{_fs_sid:n}}},B=(o)=>{let n=z(),t=new URL(o);if(n._fs_vid)t.searchParams.set(K,n._fs_vid);if(n._fs_sid)t.searchParams.set(N,n._fs_sid);return t.toString()},X=()=>{No(Q),sessionStorage.removeItem(Z),sessionStorage.removeItem(j),q=null};var vo=5000,v=0,g=0,H=null,Lo=()=>{let o=document.documentElement,n=window.scrollY||o.scrollTop,t=o.scrollHeight-o.clientHeight;if(t<=0)return 100;return Math.min(100,Math.round(n/t*100))},P=()=>{v++},lo=()=>{let o=Lo();g=Math.max(g,o);let n=x(),t=u();l("heartbeat",{...n&&{visitorUid:n},...t&&{sessionUid:t},path:location.pathname+location.search,scrollDepth:g,isVisible:document.visibilityState==="visible",interactionCount:v}),uo()},eo=()=>{v=0,g=0},so=()=>{document.addEventListener("click",P,{passive:!0}),document.addEventListener("scroll",P,{passive:!0}),document.addEventListener("keydown",P,{passive:!0}),H=setInterval(lo,vo),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")lo()})},h=()=>{if(H)clearInterval(H),H=null};var io="",bo=!1,w=()=>{let o=Y(),n=o?location.href:location.pathname+location.search;if(n===io)return;io=n,eo();let t=ro(),c=x(),r=u(),f=o?location.pathname+location.search+location.hash:location.pathname+location.search;if(l("pageview",{...c&&{visitorUid:c},...r&&{sessionUid:r},hostname:location.hostname,path:f,referrer:document.referrer||void 0,title:document.title||void 0,screenWidth:window.screen?.width,screenHeight:window.screen?.height,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||void 0,language:navigator.language||void 0,utmSource:t.utm_source,utmMedium:t.utm_medium,utmCampaign:t.utm_campaign,utmTerm:t.utm_term,utmContent:t.utm_content,ref:t.ref,source:t.source,via:t.via}),!bo){bo=!0;let i=O();if(i){let y=JSON.stringify({type:"geo",websiteId:m(),visitorUid:c||void 0,sessionUid:r||void 0});try{fetch(`${i}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:y,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},po=()=>{w();let{pushState:o,replaceState:n}=history;if(history.pushState=function(...t){o.apply(this,t),w()},history.replaceState=function(...t){n.apply(this,t),w()},window.addEventListener("popstate",()=>w()),Y())window.addEventListener("hashchange",()=>w())};var wo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t)return;try{let c=new URL(t);if(c.protocol!=="http:"&&c.protocol!=="https:")return;if(c.hostname===location.hostname)return;let r=x(),f=u();if(!r||!f)return;l("exit_click",{visitorUid:r,sessionUid:f,hostname:location.hostname,url:t})}catch{}})};var ko=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,yo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t||!ko.test(t))return;let c=x(),r=u();l("goal",{...c&&{visitorUid:c},...r&&{sessionUid:r},name:"file_download",metadata:{url:t}})})};var s=(o,n)=>{let t=x(),c=u();l("goal",{...t&&{visitorUid:t},...c&&{sessionUid:c},name:o,metadata:n})};var L="data-fs-goal",mo="data-fs-goal-",Io=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(mo)&&c.name!==L){let r=c.name.slice(mo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},Bo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest(`[${L}]`);if(!n)return;let t=n.getAttribute(L);if(!t)return;let c=Io(n);s(t,c)})};var G="data-fs-scroll",Fo="data-fs-scroll-threshold",k="data-fs-scroll-delay",jo="data-fs-scroll-",Co=new Set([G,Fo,k]),zo=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(jo)&&!Co.has(c.name)){let r=c.name.slice(jo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},Wo=()=>{let o=document.querySelectorAll(`[${G}]`);if(!o.length)return;let n=new Set,t=new IntersectionObserver((c)=>{for(let r of c){let f=r.target;if(!r.isIntersecting||n.has(f))continue;let i=f.getAttribute(G);if(!i)continue;let y=parseInt(f.getAttribute(k)||"0",10)||0,e=()=>{if(n.has(f))return;n.add(f),t.unobserve(f);let $=zo(f);s(i,$)};if(y>0)setTimeout(e,y);else e()}},{threshold:0});for(let c of Array.from(o)){let r=parseFloat(c.getAttribute(Fo)||"0.5");if(r!==0.5){let f=new IntersectionObserver((i)=>{for(let y of i){let e=y.target;if(!y.isIntersecting||n.has(e))continue;let $=e.getAttribute(G);if(!$)continue;let A=parseInt(e.getAttribute(k)||"0",10)||0,D=()=>{if(n.has(e))return;n.add(e),f.unobserve(e);let Zo=zo(e);s($,Zo)};if(A>0)setTimeout(D,A);else D()}},{threshold:r});f.observe(c)}else t.observe(c)}};var I=null,$o=()=>{if(!I)I=new Set(to());return I},Ao=(o)=>{let n=$o();if(!n.size)return!1;for(let t of n)if(o===t||o.endsWith(`.${t}`))return!0;return!1},Jo=()=>{if(!$o().size)return;document.addEventListener("click",(n)=>{let t=n.target.closest("a");if(!t)return;let c=t.href;if(!c)return;try{let r=new URL(c);if(r.hostname===location.hostname)return;if(!Ao(r.hostname))return;t.href=B(c)}catch{}})};var F=(o)=>{let n=x(),t=u();l("payment",{...n&&{visitorUid:n},...t&&{sessionUid:t},...o.amount!=null&&{amount:o.amount},...o.currency&&{currency:o.currency},...o.transactionId&&{transactionId:o.transactionId},...o.email&&{email:o.email},...o.name&&{name:o.name},...o.customerId&&{customerId:o.customerId},...o.isRenewal!=null&&{isRenewal:o.isRenewal},...o.isRefund!=null&&{isRefund:o.isRefund}})};var W=(o)=>{let n=x();l("identify",{...n&&{visitorUid:n},userId:o.userId,name:o.name,email:o.email,image:o.image,profileData:o.profileData})};var Qo=(o)=>{let[n,...t]=o;switch(n){case"identify":W(t[0]);break;case"payment":F(t[0]);break;default:s(n,t[0]);break}},C=()=>{if(d())return;if(!m())return;if(co())return;if(T()&&!_())return;if(S()&&!a())return;if(oo()&&!no())return;po(),so(),wo(),yo(),Bo(),Wo(),Jo();let o=window,n=o.flowsery?.q||[];for(let t of n)Qo(t);o.flowsery=function(...t){Qo(t)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",C);else C();var Do=async(o)=>{let n=window;return n.__flowsery_config=o,C(),{trackEvent:s,trackPayment:F,trackPageview:w,identify:W,stop:h,reset:X,getTrackingParams:z,buildCrossDomainUrl:B,getVisitorId:x,getSessionId:u}};})();
|
package/dist/main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var{defineProperty:M,getOwnPropertyNames:qo,getOwnPropertyDescriptor:go}=Object,Xo=Object.prototype.hasOwnProperty;function Ho(o){return this[o]}var ho=(o)=>{var n=(d??=new WeakMap).get(o),t;if(n)return n;if(n=M({},"__esModule",{value:!0}),o&&typeof o==="object"||typeof o==="function"){for(var c of qo(o))if(!Xo.call(n,c))M(n,c,{get:Ho.bind(o,c),enumerable:!(t=go(o,c))||t.enumerable})}return d.set(o,n),n},d;var Go=(o)=>o;function Mo(o,n){this[o]=Go.bind(null,n)}var Vo=(o,n)=>{for(var t in n)M(o,t,{get:n[t],enumerable:!0,configurable:!0,set:Mo.bind(n,t)})};var Eo={};Vo(Eo,{trackPayment:()=>F,trackPageview:()=>w,trackEvent:()=>s,stopHeartbeat:()=>h,reset:()=>g,initFlowsery:()=>Do,identify:()=>W,getVisitorId:()=>x,getTrackingParams:()=>z,getSessionId:()=>u,buildCrossDomainUrl:()=>j});var V=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o)=>{let n=Math.random()*16|0;return(o==="x"?n:n&3|8).toString(16)})},E=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0};var b=()=>{return window.__flowsery_config||null},p=()=>{return document.querySelector("script[data-fl-website-id]")},B=()=>{let o=b();if(o)return o.websiteId;return p()?.getAttribute("data-fl-website-id")||""},R=()=>{let o=b();if(o?.apiBase)return o.apiBase;let n=p();return n?.getAttribute("data-api")||n?.src?.replace(/\/js\/(?:script|main)(?:\.hash)?\.js.*/,"")||""},O=()=>{return"https://analytics.flowsery.com/analytics"},U=()=>{let o=b();if(o?.domain)return o.domain;return p()?.getAttribute("data-domain")||location.hostname},J=()=>{let o=b();if(o)return!!o.cookieless;return p()?.hasAttribute("data-cookieless")??!1},Uo=new Set(["localhost","127.0.0.1","[::1]"]),T=()=>{return Uo.has(location.hostname)||location.hostname.endsWith(".local")},_=()=>{let o=b();if(o)return!!o.local;return p()?.hasAttribute("data-local")??!1},S=()=>{return location.protocol==="file:"},a=()=>{let o=b();if(o)return!!o.allowFileProtocol;return p()?.hasAttribute("data-allow-file-protocol")??!1},oo=()=>{try{return window.self!==window.top}catch{return!0}},no=()=>{let o=b();if(o)return!!o.allowIframe;return p()?.hasAttribute("data-debug")??!1};var Y=()=>{let o=b();if(o)return!!o.hashMode;return p()?.src?.includes(".hash.js")??!1},to=()=>{let o=b();if(o?.allowedHostnames)return o.allowedHostnames;let t=p()?.getAttribute("data-allowed-hostnames");return t?t.split(",").map((c)=>c.trim()).filter(Boolean):[]},co=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},ro=()=>{let o=new URLSearchParams(window.location.search),n={};for(let t of["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref","source","via"]){let c=o.get(t);if(c)n[t]=c}return n};var l=(o,n)=>{let c=`${R()}/api/track`,r=B(),f=JSON.stringify({...n,websiteId:r,type:o});if(typeof navigator.sendBeacon==="function"){let i=new Blob([f],{type:"application/json"});if(navigator.sendBeacon(c,i))return}fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:f,keepalive:!0}).catch(()=>{})};var Q="_fs_vid",Z="_fs_sid",m="_fs_sts",Yo=1800000,K="_fs_vid",N="_fs_sid",Ko=(o)=>{let n=document.cookie.match(new RegExp(`(?:^|; )${o}=([^;]*)`));return n?decodeURIComponent(n[1]):null},fo=(o,n,t)=>{let c=new Date(Date.now()+t*86400000).toUTCString(),r=U(),f=r?`;domain=.${r}`:"";document.cookie=`${o}=${encodeURIComponent(n)};expires=${c};path=/${f};SameSite=Lax;Secure`},No=(o)=>{let n=U(),t=n?`;domain=.${n}`:"";document.cookie=`${o}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${t};SameSite=Lax;Secure`},Po=()=>{let o=new URLSearchParams(window.location.search),n=o.get(K)||void 0,t=o.get(N)||void 0;if(n||t){o.delete(K),o.delete(N);let c=o.toString(),r=window.location.pathname+(c?`?${c}`:"")+window.location.hash;history.replaceState(null,"",r)}return{vid:n,sid:t}},q=null,xo=()=>{if(q===null)q=Po();return q},x=()=>{if(J())return;let o=xo();if(o.vid){fo(Q,o.vid,730);let t=o.vid;return o.vid=void 0,t}let n=Ko(Q);if(!n)n=V(),fo(Q,n,730);return n},u=()=>{if(J())return;let o=xo();if(o.sid){let r=o.sid;return sessionStorage.setItem(Z,r),sessionStorage.setItem(m,Date.now().toString()),o.sid=void 0,r}let n=Date.now(),t=parseInt(sessionStorage.getItem(m)||"0",10),c=sessionStorage.getItem(Z);if(!c||n-t>Yo)c=V(),sessionStorage.setItem(Z,c);return sessionStorage.setItem(m,n.toString()),c},uo=()=>{if(J())return;sessionStorage.setItem(m,Date.now().toString())},z=()=>{let o=x(),n=u();return{...o&&{_fs_vid:o},...n&&{_fs_sid:n}}},j=(o)=>{let n=z(),t=new URL(o);if(n._fs_vid)t.searchParams.set(K,n._fs_vid);if(n._fs_sid)t.searchParams.set(N,n._fs_sid);return t.toString()},g=()=>{No(Q),sessionStorage.removeItem(Z),sessionStorage.removeItem(m),q=null};var vo=5000,v=0,X=0,H=null,Lo=()=>{let o=document.documentElement,n=window.scrollY||o.scrollTop,t=o.scrollHeight-o.clientHeight;if(t<=0)return 100;return Math.min(100,Math.round(n/t*100))},P=()=>{v++},lo=()=>{let o=Lo();X=Math.max(X,o);let n=x(),t=u();l("heartbeat",{...n&&{visitorUid:n},...t&&{sessionUid:t},path:location.pathname+location.search,scrollDepth:X,isVisible:document.visibilityState==="visible",interactionCount:v}),uo()},eo=()=>{v=0,X=0},so=()=>{document.addEventListener("click",P,{passive:!0}),document.addEventListener("scroll",P,{passive:!0}),document.addEventListener("keydown",P,{passive:!0}),H=setInterval(lo,vo),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")lo()})},h=()=>{if(H)clearInterval(H),H=null};var io="",bo=!1,w=()=>{let o=Y(),n=o?location.href:location.pathname+location.search;if(n===io)return;io=n,eo();let t=ro(),c=x(),r=u(),f=o?location.pathname+location.search+location.hash:location.pathname+location.search;if(l("pageview",{...c&&{visitorUid:c},...r&&{sessionUid:r},hostname:location.hostname,path:f,referrer:document.referrer||void 0,title:document.title||void 0,screenWidth:window.screen?.width,screenHeight:window.screen?.height,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||void 0,language:navigator.language||void 0,utmSource:t.utm_source,utmMedium:t.utm_medium,utmCampaign:t.utm_campaign,utmTerm:t.utm_term,utmContent:t.utm_content,ref:t.ref,source:t.source,via:t.via}),!bo){bo=!0;let i=O();if(i){let y=JSON.stringify({type:"geo",websiteId:B(),visitorUid:c||void 0,sessionUid:r||void 0});try{fetch(`${i}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:y,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},po=()=>{w();let{pushState:o,replaceState:n}=history;if(history.pushState=function(...t){o.apply(this,t),w()},history.replaceState=function(...t){n.apply(this,t),w()},window.addEventListener("popstate",()=>w()),Y())window.addEventListener("hashchange",()=>w())};var wo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t)return;try{let c=new URL(t);if(c.protocol!=="http:"&&c.protocol!=="https:")return;if(c.hostname===location.hostname)return;let r=x(),f=u();if(!r||!f)return;l("exit_click",{visitorUid:r,sessionUid:f,hostname:location.hostname,url:t})}catch{}})};var ko=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,yo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t||!ko.test(t))return;let c=x(),r=u();l("goal",{...c&&{visitorUid:c},...r&&{sessionUid:r},name:"file_download",metadata:{url:t}})})};var s=(o,n)=>{let t=x(),c=u();l("goal",{...t&&{visitorUid:t},...c&&{sessionUid:c},name:o,metadata:n})};var L="data-fs-goal",Bo="data-fs-goal-",Io=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(Bo)&&c.name!==L){let r=c.name.slice(Bo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},jo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest(`[${L}]`);if(!n)return;let t=n.getAttribute(L);if(!t)return;let c=Io(n);s(t,c)})};var G="data-fs-scroll",Fo="data-fs-scroll-threshold",k="data-fs-scroll-delay",mo="data-fs-scroll-",Co=new Set([G,Fo,k]),zo=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(mo)&&!Co.has(c.name)){let r=c.name.slice(mo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},Wo=()=>{let o=document.querySelectorAll(`[${G}]`);if(!o.length)return;let n=new Set,t=new IntersectionObserver((c)=>{for(let r of c){let f=r.target;if(!r.isIntersecting||n.has(f))continue;let i=f.getAttribute(G);if(!i)continue;let y=parseInt(f.getAttribute(k)||"0",10)||0,e=()=>{if(n.has(f))return;n.add(f),t.unobserve(f);let $=zo(f);s(i,$)};if(y>0)setTimeout(e,y);else e()}},{threshold:0});for(let c of Array.from(o)){let r=parseFloat(c.getAttribute(Fo)||"0.5");if(r!==0.5){let f=new IntersectionObserver((i)=>{for(let y of i){let e=y.target;if(!y.isIntersecting||n.has(e))continue;let $=e.getAttribute(G);if(!$)continue;let A=parseInt(e.getAttribute(k)||"0",10)||0,D=()=>{if(n.has(e))return;n.add(e),f.unobserve(e);let Zo=zo(e);s($,Zo)};if(A>0)setTimeout(D,A);else D()}},{threshold:r});f.observe(c)}else t.observe(c)}};var I=null,$o=()=>{if(!I)I=new Set(to());return I},Ao=(o)=>{let n=$o();if(!n.size)return!1;for(let t of n)if(o===t||o.endsWith(`.${t}`))return!0;return!1},Jo=()=>{if(!$o().size)return;document.addEventListener("click",(n)=>{let t=n.target.closest("a");if(!t)return;let c=t.href;if(!c)return;try{let r=new URL(c);if(r.hostname===location.hostname)return;if(!Ao(r.hostname))return;t.href=j(c)}catch{}})};var F=(o)=>{let n=x(),t=u();l("payment",{...n&&{visitorUid:n},...t&&{sessionUid:t},...o.amount!=null&&{amount:o.amount},...o.currency&&{currency:o.currency},...o.transactionId&&{transactionId:o.transactionId},...o.email&&{email:o.email},...o.name&&{name:o.name},...o.customerId&&{customerId:o.customerId},...o.isRenewal!=null&&{isRenewal:o.isRenewal},...o.isRefund!=null&&{isRefund:o.isRefund}})};var W=(o)=>{let n=x();l("identify",{...n&&{visitorUid:n},userId:o.userId,name:o.name,image:o.image,profileData:o.profileData})};var Qo=(o)=>{let[n,...t]=o;switch(n){case"identify":W(t[0]);break;case"payment":F(t[0]);break;default:s(n,t[0]);break}},C=()=>{if(E())return;if(!B())return;if(co())return;if(T()&&!_())return;if(S()&&!a())return;if(oo()&&!no())return;po(),so(),wo(),yo(),jo(),Wo(),Jo();let o=window,n=o.flowsery?.q||[];for(let t of n)Qo(t);o.flowsery=function(...t){Qo(t)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",C);else C();var Do=async(o)=>{let n=window;return n.__flowsery_config=o,C(),{trackEvent:s,trackPayment:F,trackPageview:w,identify:W,stop:h,reset:g,getTrackingParams:z,buildCrossDomainUrl:j,getVisitorId:x,getSessionId:u}};})();
|
|
1
|
+
(()=>{var{defineProperty:M,getOwnPropertyNames:qo,getOwnPropertyDescriptor:Xo}=Object,go=Object.prototype.hasOwnProperty;function Ho(o){return this[o]}var ho=(o)=>{var n=(E??=new WeakMap).get(o),t;if(n)return n;if(n=M({},"__esModule",{value:!0}),o&&typeof o==="object"||typeof o==="function"){for(var c of qo(o))if(!go.call(n,c))M(n,c,{get:Ho.bind(o,c),enumerable:!(t=Xo(o,c))||t.enumerable})}return E.set(o,n),n},E;var Go=(o)=>o;function Mo(o,n){this[o]=Go.bind(null,n)}var Vo=(o,n)=>{for(var t in n)M(o,t,{get:n[t],enumerable:!0,configurable:!0,set:Mo.bind(n,t)})};var Eo={};Vo(Eo,{trackPayment:()=>F,trackPageview:()=>w,trackEvent:()=>s,stopHeartbeat:()=>h,reset:()=>X,initFlowsery:()=>Do,identify:()=>W,getVisitorId:()=>x,getTrackingParams:()=>z,getSessionId:()=>u,buildCrossDomainUrl:()=>B});var V=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o)=>{let n=Math.random()*16|0;return(o==="x"?n:n&3|8).toString(16)})},d=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0};var b=()=>{return window.__flowsery_config||null},p=()=>{return document.querySelector("script[data-fl-website-id]")},m=()=>{let o=b();if(o)return o.websiteId;return p()?.getAttribute("data-fl-website-id")||""},R=()=>{let o=b();if(o?.apiBase)return o.apiBase;let n=p();return n?.getAttribute("data-api")||n?.src?.replace(/\/js\/(?:script|main)(?:\.hash)?\.js.*/,"")||""},O=()=>{return"https://analytics.flowsery.com/analytics"},U=()=>{let o=b();if(o?.domain)return o.domain;return p()?.getAttribute("data-domain")||location.hostname},J=()=>{let o=b();if(o)return!!o.cookieless;return p()?.hasAttribute("data-cookieless")??!1},Uo=new Set(["localhost","127.0.0.1","[::1]"]),T=()=>{return Uo.has(location.hostname)||location.hostname.endsWith(".local")},_=()=>{let o=b();if(o)return!!o.local;return p()?.hasAttribute("data-local")??!1},S=()=>{return location.protocol==="file:"},a=()=>{let o=b();if(o)return!!o.allowFileProtocol;return p()?.hasAttribute("data-allow-file-protocol")??!1},oo=()=>{try{return window.self!==window.top}catch{return!0}},no=()=>{let o=b();if(o)return!!o.allowIframe;return p()?.hasAttribute("data-allow-iframe")??!1};var Y=()=>{let o=b();if(o)return!!o.hashMode;return p()?.src?.includes(".hash.js")??!1},to=()=>{let o=b();if(o?.allowedHostnames)return o.allowedHostnames;let t=p()?.getAttribute("data-allowed-hostnames");return t?t.split(",").map((c)=>c.trim()).filter(Boolean):[]},co=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},ro=()=>{let o=new URLSearchParams(window.location.search),n={};for(let t of["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref","source","via"]){let c=o.get(t);if(c)n[t]=c}return n};var l=(o,n)=>{let c=`${R()}/api/track`,r=m(),f=JSON.stringify({...n,websiteId:r,type:o});if(typeof navigator.sendBeacon==="function"){let i=new Blob([f],{type:"application/json"});if(navigator.sendBeacon(c,i))return}fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:f,keepalive:!0}).catch(()=>{})};var Q="_fs_vid",Z="_fs_sid",j="_fs_sts",Yo=1800000,K="_fs_vid",N="_fs_sid",Ko=(o)=>{let n=document.cookie.match(new RegExp(`(?:^|; )${o}=([^;]*)`));return n?decodeURIComponent(n[1]):null},fo=(o,n,t)=>{let c=new Date(Date.now()+t*86400000).toUTCString(),r=U(),f=r?`;domain=.${r}`:"";document.cookie=`${o}=${encodeURIComponent(n)};expires=${c};path=/${f};SameSite=Lax;Secure`},No=(o)=>{let n=U(),t=n?`;domain=.${n}`:"";document.cookie=`${o}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${t};SameSite=Lax;Secure`},Po=()=>{let o=new URLSearchParams(window.location.search),n=o.get(K)||void 0,t=o.get(N)||void 0;if(n||t){o.delete(K),o.delete(N);let c=o.toString(),r=window.location.pathname+(c?`?${c}`:"")+window.location.hash;history.replaceState(null,"",r)}return{vid:n,sid:t}},q=null,xo=()=>{if(q===null)q=Po();return q},x=()=>{if(J())return;let o=xo();if(o.vid){fo(Q,o.vid,730);let t=o.vid;return o.vid=void 0,t}let n=Ko(Q);if(!n)n=V(),fo(Q,n,730);return n},u=()=>{if(J())return;let o=xo();if(o.sid){let r=o.sid;return sessionStorage.setItem(Z,r),sessionStorage.setItem(j,Date.now().toString()),o.sid=void 0,r}let n=Date.now(),t=parseInt(sessionStorage.getItem(j)||"0",10),c=sessionStorage.getItem(Z);if(!c||n-t>Yo)c=V(),sessionStorage.setItem(Z,c);return sessionStorage.setItem(j,n.toString()),c},uo=()=>{if(J())return;sessionStorage.setItem(j,Date.now().toString())},z=()=>{let o=x(),n=u();return{...o&&{_fs_vid:o},...n&&{_fs_sid:n}}},B=(o)=>{let n=z(),t=new URL(o);if(n._fs_vid)t.searchParams.set(K,n._fs_vid);if(n._fs_sid)t.searchParams.set(N,n._fs_sid);return t.toString()},X=()=>{No(Q),sessionStorage.removeItem(Z),sessionStorage.removeItem(j),q=null};var vo=5000,v=0,g=0,H=null,Lo=()=>{let o=document.documentElement,n=window.scrollY||o.scrollTop,t=o.scrollHeight-o.clientHeight;if(t<=0)return 100;return Math.min(100,Math.round(n/t*100))},P=()=>{v++},lo=()=>{let o=Lo();g=Math.max(g,o);let n=x(),t=u();l("heartbeat",{...n&&{visitorUid:n},...t&&{sessionUid:t},path:location.pathname+location.search,scrollDepth:g,isVisible:document.visibilityState==="visible",interactionCount:v}),uo()},eo=()=>{v=0,g=0},so=()=>{document.addEventListener("click",P,{passive:!0}),document.addEventListener("scroll",P,{passive:!0}),document.addEventListener("keydown",P,{passive:!0}),H=setInterval(lo,vo),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")lo()})},h=()=>{if(H)clearInterval(H),H=null};var io="",bo=!1,w=()=>{let o=Y(),n=o?location.href:location.pathname+location.search;if(n===io)return;io=n,eo();let t=ro(),c=x(),r=u(),f=o?location.pathname+location.search+location.hash:location.pathname+location.search;if(l("pageview",{...c&&{visitorUid:c},...r&&{sessionUid:r},hostname:location.hostname,path:f,referrer:document.referrer||void 0,title:document.title||void 0,screenWidth:window.screen?.width,screenHeight:window.screen?.height,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||void 0,language:navigator.language||void 0,utmSource:t.utm_source,utmMedium:t.utm_medium,utmCampaign:t.utm_campaign,utmTerm:t.utm_term,utmContent:t.utm_content,ref:t.ref,source:t.source,via:t.via}),!bo){bo=!0;let i=O();if(i){let y=JSON.stringify({type:"geo",websiteId:m(),visitorUid:c||void 0,sessionUid:r||void 0});try{fetch(`${i}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:y,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},po=()=>{w();let{pushState:o,replaceState:n}=history;if(history.pushState=function(...t){o.apply(this,t),w()},history.replaceState=function(...t){n.apply(this,t),w()},window.addEventListener("popstate",()=>w()),Y())window.addEventListener("hashchange",()=>w())};var wo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t)return;try{let c=new URL(t);if(c.protocol!=="http:"&&c.protocol!=="https:")return;if(c.hostname===location.hostname)return;let r=x(),f=u();if(!r||!f)return;l("exit_click",{visitorUid:r,sessionUid:f,hostname:location.hostname,url:t})}catch{}})};var ko=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,yo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t||!ko.test(t))return;let c=x(),r=u();l("goal",{...c&&{visitorUid:c},...r&&{sessionUid:r},name:"file_download",metadata:{url:t}})})};var s=(o,n)=>{let t=x(),c=u();l("goal",{...t&&{visitorUid:t},...c&&{sessionUid:c},name:o,metadata:n})};var L="data-fs-goal",mo="data-fs-goal-",Io=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(mo)&&c.name!==L){let r=c.name.slice(mo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},Bo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest(`[${L}]`);if(!n)return;let t=n.getAttribute(L);if(!t)return;let c=Io(n);s(t,c)})};var G="data-fs-scroll",Fo="data-fs-scroll-threshold",k="data-fs-scroll-delay",jo="data-fs-scroll-",Co=new Set([G,Fo,k]),zo=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(jo)&&!Co.has(c.name)){let r=c.name.slice(jo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},Wo=()=>{let o=document.querySelectorAll(`[${G}]`);if(!o.length)return;let n=new Set,t=new IntersectionObserver((c)=>{for(let r of c){let f=r.target;if(!r.isIntersecting||n.has(f))continue;let i=f.getAttribute(G);if(!i)continue;let y=parseInt(f.getAttribute(k)||"0",10)||0,e=()=>{if(n.has(f))return;n.add(f),t.unobserve(f);let $=zo(f);s(i,$)};if(y>0)setTimeout(e,y);else e()}},{threshold:0});for(let c of Array.from(o)){let r=parseFloat(c.getAttribute(Fo)||"0.5");if(r!==0.5){let f=new IntersectionObserver((i)=>{for(let y of i){let e=y.target;if(!y.isIntersecting||n.has(e))continue;let $=e.getAttribute(G);if(!$)continue;let A=parseInt(e.getAttribute(k)||"0",10)||0,D=()=>{if(n.has(e))return;n.add(e),f.unobserve(e);let Zo=zo(e);s($,Zo)};if(A>0)setTimeout(D,A);else D()}},{threshold:r});f.observe(c)}else t.observe(c)}};var I=null,$o=()=>{if(!I)I=new Set(to());return I},Ao=(o)=>{let n=$o();if(!n.size)return!1;for(let t of n)if(o===t||o.endsWith(`.${t}`))return!0;return!1},Jo=()=>{if(!$o().size)return;document.addEventListener("click",(n)=>{let t=n.target.closest("a");if(!t)return;let c=t.href;if(!c)return;try{let r=new URL(c);if(r.hostname===location.hostname)return;if(!Ao(r.hostname))return;t.href=B(c)}catch{}})};var F=(o)=>{let n=x(),t=u();l("payment",{...n&&{visitorUid:n},...t&&{sessionUid:t},...o.amount!=null&&{amount:o.amount},...o.currency&&{currency:o.currency},...o.transactionId&&{transactionId:o.transactionId},...o.email&&{email:o.email},...o.name&&{name:o.name},...o.customerId&&{customerId:o.customerId},...o.isRenewal!=null&&{isRenewal:o.isRenewal},...o.isRefund!=null&&{isRefund:o.isRefund}})};var W=(o)=>{let n=x();l("identify",{...n&&{visitorUid:n},userId:o.userId,name:o.name,email:o.email,image:o.image,profileData:o.profileData})};var Qo=(o)=>{let[n,...t]=o;switch(n){case"identify":W(t[0]);break;case"payment":F(t[0]);break;default:s(n,t[0]);break}},C=()=>{if(d())return;if(!m())return;if(co())return;if(T()&&!_())return;if(S()&&!a())return;if(oo()&&!no())return;po(),so(),wo(),yo(),Bo(),Wo(),Jo();let o=window,n=o.flowsery?.q||[];for(let t of n)Qo(t);o.flowsery=function(...t){Qo(t)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",C);else C();var Do=async(o)=>{let n=window;return n.__flowsery_config=o,C(),{trackEvent:s,trackPayment:F,trackPageview:w,identify:W,stop:h,reset:X,getTrackingParams:z,buildCrossDomainUrl:B,getVisitorId:x,getSessionId:u}};})();
|
package/dist/script.hash.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var{defineProperty:M,getOwnPropertyNames:qo,getOwnPropertyDescriptor:go}=Object,Xo=Object.prototype.hasOwnProperty;function Ho(o){return this[o]}var ho=(o)=>{var n=(d??=new WeakMap).get(o),t;if(n)return n;if(n=M({},"__esModule",{value:!0}),o&&typeof o==="object"||typeof o==="function"){for(var c of qo(o))if(!Xo.call(n,c))M(n,c,{get:Ho.bind(o,c),enumerable:!(t=go(o,c))||t.enumerable})}return d.set(o,n),n},d;var Go=(o)=>o;function Mo(o,n){this[o]=Go.bind(null,n)}var Vo=(o,n)=>{for(var t in n)M(o,t,{get:n[t],enumerable:!0,configurable:!0,set:Mo.bind(n,t)})};var Eo={};Vo(Eo,{trackPayment:()=>F,trackPageview:()=>w,trackEvent:()=>s,stopHeartbeat:()=>h,reset:()=>g,initFlowsery:()=>Do,identify:()=>W,getVisitorId:()=>x,getTrackingParams:()=>z,getSessionId:()=>u,buildCrossDomainUrl:()=>j});var V=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o)=>{let n=Math.random()*16|0;return(o==="x"?n:n&3|8).toString(16)})},E=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0};var b=()=>{return window.__flowsery_config||null},p=()=>{return document.querySelector("script[data-fl-website-id]")},B=()=>{let o=b();if(o)return o.websiteId;return p()?.getAttribute("data-fl-website-id")||""},R=()=>{let o=b();if(o?.apiBase)return o.apiBase;let n=p();return n?.getAttribute("data-api")||n?.src?.replace(/\/js\/(?:script|main)(?:\.hash)?\.js.*/,"")||""},O=()=>{return"https://analytics.flowsery.com/analytics"},U=()=>{let o=b();if(o?.domain)return o.domain;return p()?.getAttribute("data-domain")||location.hostname},J=()=>{let o=b();if(o)return!!o.cookieless;return p()?.hasAttribute("data-cookieless")??!1},Uo=new Set(["localhost","127.0.0.1","[::1]"]),T=()=>{return Uo.has(location.hostname)||location.hostname.endsWith(".local")},_=()=>{let o=b();if(o)return!!o.local;return p()?.hasAttribute("data-local")??!1},S=()=>{return location.protocol==="file:"},a=()=>{let o=b();if(o)return!!o.allowFileProtocol;return p()?.hasAttribute("data-allow-file-protocol")??!1},oo=()=>{try{return window.self!==window.top}catch{return!0}},no=()=>{let o=b();if(o)return!!o.allowIframe;return p()?.hasAttribute("data-debug")??!1};var Y=()=>{let o=b();if(o)return!!o.hashMode;return p()?.src?.includes(".hash.js")??!1},to=()=>{let o=b();if(o?.allowedHostnames)return o.allowedHostnames;let t=p()?.getAttribute("data-allowed-hostnames");return t?t.split(",").map((c)=>c.trim()).filter(Boolean):[]},co=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},ro=()=>{let o=new URLSearchParams(window.location.search),n={};for(let t of["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref","source","via"]){let c=o.get(t);if(c)n[t]=c}return n};var l=(o,n)=>{let c=`${R()}/api/track`,r=B(),f=JSON.stringify({...n,websiteId:r,type:o});if(typeof navigator.sendBeacon==="function"){let i=new Blob([f],{type:"application/json"});if(navigator.sendBeacon(c,i))return}fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:f,keepalive:!0}).catch(()=>{})};var Q="_fs_vid",Z="_fs_sid",m="_fs_sts",Yo=1800000,K="_fs_vid",N="_fs_sid",Ko=(o)=>{let n=document.cookie.match(new RegExp(`(?:^|; )${o}=([^;]*)`));return n?decodeURIComponent(n[1]):null},fo=(o,n,t)=>{let c=new Date(Date.now()+t*86400000).toUTCString(),r=U(),f=r?`;domain=.${r}`:"";document.cookie=`${o}=${encodeURIComponent(n)};expires=${c};path=/${f};SameSite=Lax;Secure`},No=(o)=>{let n=U(),t=n?`;domain=.${n}`:"";document.cookie=`${o}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${t};SameSite=Lax;Secure`},Po=()=>{let o=new URLSearchParams(window.location.search),n=o.get(K)||void 0,t=o.get(N)||void 0;if(n||t){o.delete(K),o.delete(N);let c=o.toString(),r=window.location.pathname+(c?`?${c}`:"")+window.location.hash;history.replaceState(null,"",r)}return{vid:n,sid:t}},q=null,xo=()=>{if(q===null)q=Po();return q},x=()=>{if(J())return;let o=xo();if(o.vid){fo(Q,o.vid,730);let t=o.vid;return o.vid=void 0,t}let n=Ko(Q);if(!n)n=V(),fo(Q,n,730);return n},u=()=>{if(J())return;let o=xo();if(o.sid){let r=o.sid;return sessionStorage.setItem(Z,r),sessionStorage.setItem(m,Date.now().toString()),o.sid=void 0,r}let n=Date.now(),t=parseInt(sessionStorage.getItem(m)||"0",10),c=sessionStorage.getItem(Z);if(!c||n-t>Yo)c=V(),sessionStorage.setItem(Z,c);return sessionStorage.setItem(m,n.toString()),c},uo=()=>{if(J())return;sessionStorage.setItem(m,Date.now().toString())},z=()=>{let o=x(),n=u();return{...o&&{_fs_vid:o},...n&&{_fs_sid:n}}},j=(o)=>{let n=z(),t=new URL(o);if(n._fs_vid)t.searchParams.set(K,n._fs_vid);if(n._fs_sid)t.searchParams.set(N,n._fs_sid);return t.toString()},g=()=>{No(Q),sessionStorage.removeItem(Z),sessionStorage.removeItem(m),q=null};var vo=5000,v=0,X=0,H=null,Lo=()=>{let o=document.documentElement,n=window.scrollY||o.scrollTop,t=o.scrollHeight-o.clientHeight;if(t<=0)return 100;return Math.min(100,Math.round(n/t*100))},P=()=>{v++},lo=()=>{let o=Lo();X=Math.max(X,o);let n=x(),t=u();l("heartbeat",{...n&&{visitorUid:n},...t&&{sessionUid:t},path:location.pathname+location.search,scrollDepth:X,isVisible:document.visibilityState==="visible",interactionCount:v}),uo()},eo=()=>{v=0,X=0},so=()=>{document.addEventListener("click",P,{passive:!0}),document.addEventListener("scroll",P,{passive:!0}),document.addEventListener("keydown",P,{passive:!0}),H=setInterval(lo,vo),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")lo()})},h=()=>{if(H)clearInterval(H),H=null};var io="",bo=!1,w=()=>{let o=Y(),n=o?location.href:location.pathname+location.search;if(n===io)return;io=n,eo();let t=ro(),c=x(),r=u(),f=o?location.pathname+location.search+location.hash:location.pathname+location.search;if(l("pageview",{...c&&{visitorUid:c},...r&&{sessionUid:r},hostname:location.hostname,path:f,referrer:document.referrer||void 0,title:document.title||void 0,screenWidth:window.screen?.width,screenHeight:window.screen?.height,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||void 0,language:navigator.language||void 0,utmSource:t.utm_source,utmMedium:t.utm_medium,utmCampaign:t.utm_campaign,utmTerm:t.utm_term,utmContent:t.utm_content,ref:t.ref,source:t.source,via:t.via}),!bo){bo=!0;let i=O();if(i){let y=JSON.stringify({type:"geo",websiteId:B(),visitorUid:c||void 0,sessionUid:r||void 0});try{fetch(`${i}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:y,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},po=()=>{w();let{pushState:o,replaceState:n}=history;if(history.pushState=function(...t){o.apply(this,t),w()},history.replaceState=function(...t){n.apply(this,t),w()},window.addEventListener("popstate",()=>w()),Y())window.addEventListener("hashchange",()=>w())};var wo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t)return;try{let c=new URL(t);if(c.protocol!=="http:"&&c.protocol!=="https:")return;if(c.hostname===location.hostname)return;let r=x(),f=u();if(!r||!f)return;l("exit_click",{visitorUid:r,sessionUid:f,hostname:location.hostname,url:t})}catch{}})};var ko=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,yo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t||!ko.test(t))return;let c=x(),r=u();l("goal",{...c&&{visitorUid:c},...r&&{sessionUid:r},name:"file_download",metadata:{url:t}})})};var s=(o,n)=>{let t=x(),c=u();l("goal",{...t&&{visitorUid:t},...c&&{sessionUid:c},name:o,metadata:n})};var L="data-fs-goal",Bo="data-fs-goal-",Io=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(Bo)&&c.name!==L){let r=c.name.slice(Bo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},jo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest(`[${L}]`);if(!n)return;let t=n.getAttribute(L);if(!t)return;let c=Io(n);s(t,c)})};var G="data-fs-scroll",Fo="data-fs-scroll-threshold",k="data-fs-scroll-delay",mo="data-fs-scroll-",Co=new Set([G,Fo,k]),zo=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(mo)&&!Co.has(c.name)){let r=c.name.slice(mo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},Wo=()=>{let o=document.querySelectorAll(`[${G}]`);if(!o.length)return;let n=new Set,t=new IntersectionObserver((c)=>{for(let r of c){let f=r.target;if(!r.isIntersecting||n.has(f))continue;let i=f.getAttribute(G);if(!i)continue;let y=parseInt(f.getAttribute(k)||"0",10)||0,e=()=>{if(n.has(f))return;n.add(f),t.unobserve(f);let $=zo(f);s(i,$)};if(y>0)setTimeout(e,y);else e()}},{threshold:0});for(let c of Array.from(o)){let r=parseFloat(c.getAttribute(Fo)||"0.5");if(r!==0.5){let f=new IntersectionObserver((i)=>{for(let y of i){let e=y.target;if(!y.isIntersecting||n.has(e))continue;let $=e.getAttribute(G);if(!$)continue;let A=parseInt(e.getAttribute(k)||"0",10)||0,D=()=>{if(n.has(e))return;n.add(e),f.unobserve(e);let Zo=zo(e);s($,Zo)};if(A>0)setTimeout(D,A);else D()}},{threshold:r});f.observe(c)}else t.observe(c)}};var I=null,$o=()=>{if(!I)I=new Set(to());return I},Ao=(o)=>{let n=$o();if(!n.size)return!1;for(let t of n)if(o===t||o.endsWith(`.${t}`))return!0;return!1},Jo=()=>{if(!$o().size)return;document.addEventListener("click",(n)=>{let t=n.target.closest("a");if(!t)return;let c=t.href;if(!c)return;try{let r=new URL(c);if(r.hostname===location.hostname)return;if(!Ao(r.hostname))return;t.href=j(c)}catch{}})};var F=(o)=>{let n=x(),t=u();l("payment",{...n&&{visitorUid:n},...t&&{sessionUid:t},...o.amount!=null&&{amount:o.amount},...o.currency&&{currency:o.currency},...o.transactionId&&{transactionId:o.transactionId},...o.email&&{email:o.email},...o.name&&{name:o.name},...o.customerId&&{customerId:o.customerId},...o.isRenewal!=null&&{isRenewal:o.isRenewal},...o.isRefund!=null&&{isRefund:o.isRefund}})};var W=(o)=>{let n=x();l("identify",{...n&&{visitorUid:n},userId:o.userId,name:o.name,image:o.image,profileData:o.profileData})};var Qo=(o)=>{let[n,...t]=o;switch(n){case"identify":W(t[0]);break;case"payment":F(t[0]);break;default:s(n,t[0]);break}},C=()=>{if(E())return;if(!B())return;if(co())return;if(T()&&!_())return;if(S()&&!a())return;if(oo()&&!no())return;po(),so(),wo(),yo(),jo(),Wo(),Jo();let o=window,n=o.flowsery?.q||[];for(let t of n)Qo(t);o.flowsery=function(...t){Qo(t)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",C);else C();var Do=async(o)=>{let n=window;return n.__flowsery_config=o,C(),{trackEvent:s,trackPayment:F,trackPageview:w,identify:W,stop:h,reset:g,getTrackingParams:z,buildCrossDomainUrl:j,getVisitorId:x,getSessionId:u}};})();
|
|
1
|
+
(()=>{var{defineProperty:M,getOwnPropertyNames:qo,getOwnPropertyDescriptor:Xo}=Object,go=Object.prototype.hasOwnProperty;function Ho(o){return this[o]}var ho=(o)=>{var n=(E??=new WeakMap).get(o),t;if(n)return n;if(n=M({},"__esModule",{value:!0}),o&&typeof o==="object"||typeof o==="function"){for(var c of qo(o))if(!go.call(n,c))M(n,c,{get:Ho.bind(o,c),enumerable:!(t=Xo(o,c))||t.enumerable})}return E.set(o,n),n},E;var Go=(o)=>o;function Mo(o,n){this[o]=Go.bind(null,n)}var Vo=(o,n)=>{for(var t in n)M(o,t,{get:n[t],enumerable:!0,configurable:!0,set:Mo.bind(n,t)})};var Eo={};Vo(Eo,{trackPayment:()=>F,trackPageview:()=>w,trackEvent:()=>s,stopHeartbeat:()=>h,reset:()=>X,initFlowsery:()=>Do,identify:()=>W,getVisitorId:()=>x,getTrackingParams:()=>z,getSessionId:()=>u,buildCrossDomainUrl:()=>B});var V=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o)=>{let n=Math.random()*16|0;return(o==="x"?n:n&3|8).toString(16)})},d=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0};var b=()=>{return window.__flowsery_config||null},p=()=>{return document.querySelector("script[data-fl-website-id]")},m=()=>{let o=b();if(o)return o.websiteId;return p()?.getAttribute("data-fl-website-id")||""},R=()=>{let o=b();if(o?.apiBase)return o.apiBase;let n=p();return n?.getAttribute("data-api")||n?.src?.replace(/\/js\/(?:script|main)(?:\.hash)?\.js.*/,"")||""},O=()=>{return"https://analytics.flowsery.com/analytics"},U=()=>{let o=b();if(o?.domain)return o.domain;return p()?.getAttribute("data-domain")||location.hostname},J=()=>{let o=b();if(o)return!!o.cookieless;return p()?.hasAttribute("data-cookieless")??!1},Uo=new Set(["localhost","127.0.0.1","[::1]"]),T=()=>{return Uo.has(location.hostname)||location.hostname.endsWith(".local")},_=()=>{let o=b();if(o)return!!o.local;return p()?.hasAttribute("data-local")??!1},S=()=>{return location.protocol==="file:"},a=()=>{let o=b();if(o)return!!o.allowFileProtocol;return p()?.hasAttribute("data-allow-file-protocol")??!1},oo=()=>{try{return window.self!==window.top}catch{return!0}},no=()=>{let o=b();if(o)return!!o.allowIframe;return p()?.hasAttribute("data-allow-iframe")??!1};var Y=()=>{let o=b();if(o)return!!o.hashMode;return p()?.src?.includes(".hash.js")??!1},to=()=>{let o=b();if(o?.allowedHostnames)return o.allowedHostnames;let t=p()?.getAttribute("data-allowed-hostnames");return t?t.split(",").map((c)=>c.trim()).filter(Boolean):[]},co=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},ro=()=>{let o=new URLSearchParams(window.location.search),n={};for(let t of["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref","source","via"]){let c=o.get(t);if(c)n[t]=c}return n};var l=(o,n)=>{let c=`${R()}/api/track`,r=m(),f=JSON.stringify({...n,websiteId:r,type:o});if(typeof navigator.sendBeacon==="function"){let i=new Blob([f],{type:"application/json"});if(navigator.sendBeacon(c,i))return}fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:f,keepalive:!0}).catch(()=>{})};var Q="_fs_vid",Z="_fs_sid",j="_fs_sts",Yo=1800000,K="_fs_vid",N="_fs_sid",Ko=(o)=>{let n=document.cookie.match(new RegExp(`(?:^|; )${o}=([^;]*)`));return n?decodeURIComponent(n[1]):null},fo=(o,n,t)=>{let c=new Date(Date.now()+t*86400000).toUTCString(),r=U(),f=r?`;domain=.${r}`:"";document.cookie=`${o}=${encodeURIComponent(n)};expires=${c};path=/${f};SameSite=Lax;Secure`},No=(o)=>{let n=U(),t=n?`;domain=.${n}`:"";document.cookie=`${o}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${t};SameSite=Lax;Secure`},Po=()=>{let o=new URLSearchParams(window.location.search),n=o.get(K)||void 0,t=o.get(N)||void 0;if(n||t){o.delete(K),o.delete(N);let c=o.toString(),r=window.location.pathname+(c?`?${c}`:"")+window.location.hash;history.replaceState(null,"",r)}return{vid:n,sid:t}},q=null,xo=()=>{if(q===null)q=Po();return q},x=()=>{if(J())return;let o=xo();if(o.vid){fo(Q,o.vid,730);let t=o.vid;return o.vid=void 0,t}let n=Ko(Q);if(!n)n=V(),fo(Q,n,730);return n},u=()=>{if(J())return;let o=xo();if(o.sid){let r=o.sid;return sessionStorage.setItem(Z,r),sessionStorage.setItem(j,Date.now().toString()),o.sid=void 0,r}let n=Date.now(),t=parseInt(sessionStorage.getItem(j)||"0",10),c=sessionStorage.getItem(Z);if(!c||n-t>Yo)c=V(),sessionStorage.setItem(Z,c);return sessionStorage.setItem(j,n.toString()),c},uo=()=>{if(J())return;sessionStorage.setItem(j,Date.now().toString())},z=()=>{let o=x(),n=u();return{...o&&{_fs_vid:o},...n&&{_fs_sid:n}}},B=(o)=>{let n=z(),t=new URL(o);if(n._fs_vid)t.searchParams.set(K,n._fs_vid);if(n._fs_sid)t.searchParams.set(N,n._fs_sid);return t.toString()},X=()=>{No(Q),sessionStorage.removeItem(Z),sessionStorage.removeItem(j),q=null};var vo=5000,v=0,g=0,H=null,Lo=()=>{let o=document.documentElement,n=window.scrollY||o.scrollTop,t=o.scrollHeight-o.clientHeight;if(t<=0)return 100;return Math.min(100,Math.round(n/t*100))},P=()=>{v++},lo=()=>{let o=Lo();g=Math.max(g,o);let n=x(),t=u();l("heartbeat",{...n&&{visitorUid:n},...t&&{sessionUid:t},path:location.pathname+location.search,scrollDepth:g,isVisible:document.visibilityState==="visible",interactionCount:v}),uo()},eo=()=>{v=0,g=0},so=()=>{document.addEventListener("click",P,{passive:!0}),document.addEventListener("scroll",P,{passive:!0}),document.addEventListener("keydown",P,{passive:!0}),H=setInterval(lo,vo),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")lo()})},h=()=>{if(H)clearInterval(H),H=null};var io="",bo=!1,w=()=>{let o=Y(),n=o?location.href:location.pathname+location.search;if(n===io)return;io=n,eo();let t=ro(),c=x(),r=u(),f=o?location.pathname+location.search+location.hash:location.pathname+location.search;if(l("pageview",{...c&&{visitorUid:c},...r&&{sessionUid:r},hostname:location.hostname,path:f,referrer:document.referrer||void 0,title:document.title||void 0,screenWidth:window.screen?.width,screenHeight:window.screen?.height,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||void 0,language:navigator.language||void 0,utmSource:t.utm_source,utmMedium:t.utm_medium,utmCampaign:t.utm_campaign,utmTerm:t.utm_term,utmContent:t.utm_content,ref:t.ref,source:t.source,via:t.via}),!bo){bo=!0;let i=O();if(i){let y=JSON.stringify({type:"geo",websiteId:m(),visitorUid:c||void 0,sessionUid:r||void 0});try{fetch(`${i}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:y,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},po=()=>{w();let{pushState:o,replaceState:n}=history;if(history.pushState=function(...t){o.apply(this,t),w()},history.replaceState=function(...t){n.apply(this,t),w()},window.addEventListener("popstate",()=>w()),Y())window.addEventListener("hashchange",()=>w())};var wo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t)return;try{let c=new URL(t);if(c.protocol!=="http:"&&c.protocol!=="https:")return;if(c.hostname===location.hostname)return;let r=x(),f=u();if(!r||!f)return;l("exit_click",{visitorUid:r,sessionUid:f,hostname:location.hostname,url:t})}catch{}})};var ko=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,yo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t||!ko.test(t))return;let c=x(),r=u();l("goal",{...c&&{visitorUid:c},...r&&{sessionUid:r},name:"file_download",metadata:{url:t}})})};var s=(o,n)=>{let t=x(),c=u();l("goal",{...t&&{visitorUid:t},...c&&{sessionUid:c},name:o,metadata:n})};var L="data-fs-goal",mo="data-fs-goal-",Io=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(mo)&&c.name!==L){let r=c.name.slice(mo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},Bo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest(`[${L}]`);if(!n)return;let t=n.getAttribute(L);if(!t)return;let c=Io(n);s(t,c)})};var G="data-fs-scroll",Fo="data-fs-scroll-threshold",k="data-fs-scroll-delay",jo="data-fs-scroll-",Co=new Set([G,Fo,k]),zo=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(jo)&&!Co.has(c.name)){let r=c.name.slice(jo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},Wo=()=>{let o=document.querySelectorAll(`[${G}]`);if(!o.length)return;let n=new Set,t=new IntersectionObserver((c)=>{for(let r of c){let f=r.target;if(!r.isIntersecting||n.has(f))continue;let i=f.getAttribute(G);if(!i)continue;let y=parseInt(f.getAttribute(k)||"0",10)||0,e=()=>{if(n.has(f))return;n.add(f),t.unobserve(f);let $=zo(f);s(i,$)};if(y>0)setTimeout(e,y);else e()}},{threshold:0});for(let c of Array.from(o)){let r=parseFloat(c.getAttribute(Fo)||"0.5");if(r!==0.5){let f=new IntersectionObserver((i)=>{for(let y of i){let e=y.target;if(!y.isIntersecting||n.has(e))continue;let $=e.getAttribute(G);if(!$)continue;let A=parseInt(e.getAttribute(k)||"0",10)||0,D=()=>{if(n.has(e))return;n.add(e),f.unobserve(e);let Zo=zo(e);s($,Zo)};if(A>0)setTimeout(D,A);else D()}},{threshold:r});f.observe(c)}else t.observe(c)}};var I=null,$o=()=>{if(!I)I=new Set(to());return I},Ao=(o)=>{let n=$o();if(!n.size)return!1;for(let t of n)if(o===t||o.endsWith(`.${t}`))return!0;return!1},Jo=()=>{if(!$o().size)return;document.addEventListener("click",(n)=>{let t=n.target.closest("a");if(!t)return;let c=t.href;if(!c)return;try{let r=new URL(c);if(r.hostname===location.hostname)return;if(!Ao(r.hostname))return;t.href=B(c)}catch{}})};var F=(o)=>{let n=x(),t=u();l("payment",{...n&&{visitorUid:n},...t&&{sessionUid:t},...o.amount!=null&&{amount:o.amount},...o.currency&&{currency:o.currency},...o.transactionId&&{transactionId:o.transactionId},...o.email&&{email:o.email},...o.name&&{name:o.name},...o.customerId&&{customerId:o.customerId},...o.isRenewal!=null&&{isRenewal:o.isRenewal},...o.isRefund!=null&&{isRefund:o.isRefund}})};var W=(o)=>{let n=x();l("identify",{...n&&{visitorUid:n},userId:o.userId,name:o.name,email:o.email,image:o.image,profileData:o.profileData})};var Qo=(o)=>{let[n,...t]=o;switch(n){case"identify":W(t[0]);break;case"payment":F(t[0]);break;default:s(n,t[0]);break}},C=()=>{if(d())return;if(!m())return;if(co())return;if(T()&&!_())return;if(S()&&!a())return;if(oo()&&!no())return;po(),so(),wo(),yo(),Bo(),Wo(),Jo();let o=window,n=o.flowsery?.q||[];for(let t of n)Qo(t);o.flowsery=function(...t){Qo(t)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",C);else C();var Do=async(o)=>{let n=window;return n.__flowsery_config=o,C(),{trackEvent:s,trackPayment:F,trackPageview:w,identify:W,stop:h,reset:X,getTrackingParams:z,buildCrossDomainUrl:B,getVisitorId:x,getSessionId:u}};})();
|
package/dist/script.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var{defineProperty:M,getOwnPropertyNames:qo,getOwnPropertyDescriptor:go}=Object,Xo=Object.prototype.hasOwnProperty;function Ho(o){return this[o]}var ho=(o)=>{var n=(d??=new WeakMap).get(o),t;if(n)return n;if(n=M({},"__esModule",{value:!0}),o&&typeof o==="object"||typeof o==="function"){for(var c of qo(o))if(!Xo.call(n,c))M(n,c,{get:Ho.bind(o,c),enumerable:!(t=go(o,c))||t.enumerable})}return d.set(o,n),n},d;var Go=(o)=>o;function Mo(o,n){this[o]=Go.bind(null,n)}var Vo=(o,n)=>{for(var t in n)M(o,t,{get:n[t],enumerable:!0,configurable:!0,set:Mo.bind(n,t)})};var Eo={};Vo(Eo,{trackPayment:()=>F,trackPageview:()=>w,trackEvent:()=>s,stopHeartbeat:()=>h,reset:()=>g,initFlowsery:()=>Do,identify:()=>W,getVisitorId:()=>x,getTrackingParams:()=>z,getSessionId:()=>u,buildCrossDomainUrl:()=>j});var V=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o)=>{let n=Math.random()*16|0;return(o==="x"?n:n&3|8).toString(16)})},E=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0};var b=()=>{return window.__flowsery_config||null},p=()=>{return document.querySelector("script[data-fl-website-id]")},B=()=>{let o=b();if(o)return o.websiteId;return p()?.getAttribute("data-fl-website-id")||""},R=()=>{let o=b();if(o?.apiBase)return o.apiBase;let n=p();return n?.getAttribute("data-api")||n?.src?.replace(/\/js\/(?:script|main)(?:\.hash)?\.js.*/,"")||""},O=()=>{return"https://analytics.flowsery.com/analytics"},U=()=>{let o=b();if(o?.domain)return o.domain;return p()?.getAttribute("data-domain")||location.hostname},J=()=>{let o=b();if(o)return!!o.cookieless;return p()?.hasAttribute("data-cookieless")??!1},Uo=new Set(["localhost","127.0.0.1","[::1]"]),T=()=>{return Uo.has(location.hostname)||location.hostname.endsWith(".local")},_=()=>{let o=b();if(o)return!!o.local;return p()?.hasAttribute("data-local")??!1},S=()=>{return location.protocol==="file:"},a=()=>{let o=b();if(o)return!!o.allowFileProtocol;return p()?.hasAttribute("data-allow-file-protocol")??!1},oo=()=>{try{return window.self!==window.top}catch{return!0}},no=()=>{let o=b();if(o)return!!o.allowIframe;return p()?.hasAttribute("data-debug")??!1};var Y=()=>{let o=b();if(o)return!!o.hashMode;return p()?.src?.includes(".hash.js")??!1},to=()=>{let o=b();if(o?.allowedHostnames)return o.allowedHostnames;let t=p()?.getAttribute("data-allowed-hostnames");return t?t.split(",").map((c)=>c.trim()).filter(Boolean):[]},co=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},ro=()=>{let o=new URLSearchParams(window.location.search),n={};for(let t of["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref","source","via"]){let c=o.get(t);if(c)n[t]=c}return n};var l=(o,n)=>{let c=`${R()}/api/track`,r=B(),f=JSON.stringify({...n,websiteId:r,type:o});if(typeof navigator.sendBeacon==="function"){let i=new Blob([f],{type:"application/json"});if(navigator.sendBeacon(c,i))return}fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:f,keepalive:!0}).catch(()=>{})};var Q="_fs_vid",Z="_fs_sid",m="_fs_sts",Yo=1800000,K="_fs_vid",N="_fs_sid",Ko=(o)=>{let n=document.cookie.match(new RegExp(`(?:^|; )${o}=([^;]*)`));return n?decodeURIComponent(n[1]):null},fo=(o,n,t)=>{let c=new Date(Date.now()+t*86400000).toUTCString(),r=U(),f=r?`;domain=.${r}`:"";document.cookie=`${o}=${encodeURIComponent(n)};expires=${c};path=/${f};SameSite=Lax;Secure`},No=(o)=>{let n=U(),t=n?`;domain=.${n}`:"";document.cookie=`${o}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${t};SameSite=Lax;Secure`},Po=()=>{let o=new URLSearchParams(window.location.search),n=o.get(K)||void 0,t=o.get(N)||void 0;if(n||t){o.delete(K),o.delete(N);let c=o.toString(),r=window.location.pathname+(c?`?${c}`:"")+window.location.hash;history.replaceState(null,"",r)}return{vid:n,sid:t}},q=null,xo=()=>{if(q===null)q=Po();return q},x=()=>{if(J())return;let o=xo();if(o.vid){fo(Q,o.vid,730);let t=o.vid;return o.vid=void 0,t}let n=Ko(Q);if(!n)n=V(),fo(Q,n,730);return n},u=()=>{if(J())return;let o=xo();if(o.sid){let r=o.sid;return sessionStorage.setItem(Z,r),sessionStorage.setItem(m,Date.now().toString()),o.sid=void 0,r}let n=Date.now(),t=parseInt(sessionStorage.getItem(m)||"0",10),c=sessionStorage.getItem(Z);if(!c||n-t>Yo)c=V(),sessionStorage.setItem(Z,c);return sessionStorage.setItem(m,n.toString()),c},uo=()=>{if(J())return;sessionStorage.setItem(m,Date.now().toString())},z=()=>{let o=x(),n=u();return{...o&&{_fs_vid:o},...n&&{_fs_sid:n}}},j=(o)=>{let n=z(),t=new URL(o);if(n._fs_vid)t.searchParams.set(K,n._fs_vid);if(n._fs_sid)t.searchParams.set(N,n._fs_sid);return t.toString()},g=()=>{No(Q),sessionStorage.removeItem(Z),sessionStorage.removeItem(m),q=null};var vo=5000,v=0,X=0,H=null,Lo=()=>{let o=document.documentElement,n=window.scrollY||o.scrollTop,t=o.scrollHeight-o.clientHeight;if(t<=0)return 100;return Math.min(100,Math.round(n/t*100))},P=()=>{v++},lo=()=>{let o=Lo();X=Math.max(X,o);let n=x(),t=u();l("heartbeat",{...n&&{visitorUid:n},...t&&{sessionUid:t},path:location.pathname+location.search,scrollDepth:X,isVisible:document.visibilityState==="visible",interactionCount:v}),uo()},eo=()=>{v=0,X=0},so=()=>{document.addEventListener("click",P,{passive:!0}),document.addEventListener("scroll",P,{passive:!0}),document.addEventListener("keydown",P,{passive:!0}),H=setInterval(lo,vo),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")lo()})},h=()=>{if(H)clearInterval(H),H=null};var io="",bo=!1,w=()=>{let o=Y(),n=o?location.href:location.pathname+location.search;if(n===io)return;io=n,eo();let t=ro(),c=x(),r=u(),f=o?location.pathname+location.search+location.hash:location.pathname+location.search;if(l("pageview",{...c&&{visitorUid:c},...r&&{sessionUid:r},hostname:location.hostname,path:f,referrer:document.referrer||void 0,title:document.title||void 0,screenWidth:window.screen?.width,screenHeight:window.screen?.height,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||void 0,language:navigator.language||void 0,utmSource:t.utm_source,utmMedium:t.utm_medium,utmCampaign:t.utm_campaign,utmTerm:t.utm_term,utmContent:t.utm_content,ref:t.ref,source:t.source,via:t.via}),!bo){bo=!0;let i=O();if(i){let y=JSON.stringify({type:"geo",websiteId:B(),visitorUid:c||void 0,sessionUid:r||void 0});try{fetch(`${i}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:y,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},po=()=>{w();let{pushState:o,replaceState:n}=history;if(history.pushState=function(...t){o.apply(this,t),w()},history.replaceState=function(...t){n.apply(this,t),w()},window.addEventListener("popstate",()=>w()),Y())window.addEventListener("hashchange",()=>w())};var wo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t)return;try{let c=new URL(t);if(c.protocol!=="http:"&&c.protocol!=="https:")return;if(c.hostname===location.hostname)return;let r=x(),f=u();if(!r||!f)return;l("exit_click",{visitorUid:r,sessionUid:f,hostname:location.hostname,url:t})}catch{}})};var ko=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,yo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t||!ko.test(t))return;let c=x(),r=u();l("goal",{...c&&{visitorUid:c},...r&&{sessionUid:r},name:"file_download",metadata:{url:t}})})};var s=(o,n)=>{let t=x(),c=u();l("goal",{...t&&{visitorUid:t},...c&&{sessionUid:c},name:o,metadata:n})};var L="data-fs-goal",Bo="data-fs-goal-",Io=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(Bo)&&c.name!==L){let r=c.name.slice(Bo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},jo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest(`[${L}]`);if(!n)return;let t=n.getAttribute(L);if(!t)return;let c=Io(n);s(t,c)})};var G="data-fs-scroll",Fo="data-fs-scroll-threshold",k="data-fs-scroll-delay",mo="data-fs-scroll-",Co=new Set([G,Fo,k]),zo=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(mo)&&!Co.has(c.name)){let r=c.name.slice(mo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},Wo=()=>{let o=document.querySelectorAll(`[${G}]`);if(!o.length)return;let n=new Set,t=new IntersectionObserver((c)=>{for(let r of c){let f=r.target;if(!r.isIntersecting||n.has(f))continue;let i=f.getAttribute(G);if(!i)continue;let y=parseInt(f.getAttribute(k)||"0",10)||0,e=()=>{if(n.has(f))return;n.add(f),t.unobserve(f);let $=zo(f);s(i,$)};if(y>0)setTimeout(e,y);else e()}},{threshold:0});for(let c of Array.from(o)){let r=parseFloat(c.getAttribute(Fo)||"0.5");if(r!==0.5){let f=new IntersectionObserver((i)=>{for(let y of i){let e=y.target;if(!y.isIntersecting||n.has(e))continue;let $=e.getAttribute(G);if(!$)continue;let A=parseInt(e.getAttribute(k)||"0",10)||0,D=()=>{if(n.has(e))return;n.add(e),f.unobserve(e);let Zo=zo(e);s($,Zo)};if(A>0)setTimeout(D,A);else D()}},{threshold:r});f.observe(c)}else t.observe(c)}};var I=null,$o=()=>{if(!I)I=new Set(to());return I},Ao=(o)=>{let n=$o();if(!n.size)return!1;for(let t of n)if(o===t||o.endsWith(`.${t}`))return!0;return!1},Jo=()=>{if(!$o().size)return;document.addEventListener("click",(n)=>{let t=n.target.closest("a");if(!t)return;let c=t.href;if(!c)return;try{let r=new URL(c);if(r.hostname===location.hostname)return;if(!Ao(r.hostname))return;t.href=j(c)}catch{}})};var F=(o)=>{let n=x(),t=u();l("payment",{...n&&{visitorUid:n},...t&&{sessionUid:t},...o.amount!=null&&{amount:o.amount},...o.currency&&{currency:o.currency},...o.transactionId&&{transactionId:o.transactionId},...o.email&&{email:o.email},...o.name&&{name:o.name},...o.customerId&&{customerId:o.customerId},...o.isRenewal!=null&&{isRenewal:o.isRenewal},...o.isRefund!=null&&{isRefund:o.isRefund}})};var W=(o)=>{let n=x();l("identify",{...n&&{visitorUid:n},userId:o.userId,name:o.name,image:o.image,profileData:o.profileData})};var Qo=(o)=>{let[n,...t]=o;switch(n){case"identify":W(t[0]);break;case"payment":F(t[0]);break;default:s(n,t[0]);break}},C=()=>{if(E())return;if(!B())return;if(co())return;if(T()&&!_())return;if(S()&&!a())return;if(oo()&&!no())return;po(),so(),wo(),yo(),jo(),Wo(),Jo();let o=window,n=o.flowsery?.q||[];for(let t of n)Qo(t);o.flowsery=function(...t){Qo(t)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",C);else C();var Do=async(o)=>{let n=window;return n.__flowsery_config=o,C(),{trackEvent:s,trackPayment:F,trackPageview:w,identify:W,stop:h,reset:g,getTrackingParams:z,buildCrossDomainUrl:j,getVisitorId:x,getSessionId:u}};})();
|
|
1
|
+
(()=>{var{defineProperty:M,getOwnPropertyNames:qo,getOwnPropertyDescriptor:Xo}=Object,go=Object.prototype.hasOwnProperty;function Ho(o){return this[o]}var ho=(o)=>{var n=(E??=new WeakMap).get(o),t;if(n)return n;if(n=M({},"__esModule",{value:!0}),o&&typeof o==="object"||typeof o==="function"){for(var c of qo(o))if(!go.call(n,c))M(n,c,{get:Ho.bind(o,c),enumerable:!(t=Xo(o,c))||t.enumerable})}return E.set(o,n),n},E;var Go=(o)=>o;function Mo(o,n){this[o]=Go.bind(null,n)}var Vo=(o,n)=>{for(var t in n)M(o,t,{get:n[t],enumerable:!0,configurable:!0,set:Mo.bind(n,t)})};var Eo={};Vo(Eo,{trackPayment:()=>F,trackPageview:()=>w,trackEvent:()=>s,stopHeartbeat:()=>h,reset:()=>X,initFlowsery:()=>Do,identify:()=>W,getVisitorId:()=>x,getTrackingParams:()=>z,getSessionId:()=>u,buildCrossDomainUrl:()=>B});var V=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o)=>{let n=Math.random()*16|0;return(o==="x"?n:n&3|8).toString(16)})},d=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0};var b=()=>{return window.__flowsery_config||null},p=()=>{return document.querySelector("script[data-fl-website-id]")},m=()=>{let o=b();if(o)return o.websiteId;return p()?.getAttribute("data-fl-website-id")||""},R=()=>{let o=b();if(o?.apiBase)return o.apiBase;let n=p();return n?.getAttribute("data-api")||n?.src?.replace(/\/js\/(?:script|main)(?:\.hash)?\.js.*/,"")||""},O=()=>{return"https://analytics.flowsery.com/analytics"},U=()=>{let o=b();if(o?.domain)return o.domain;return p()?.getAttribute("data-domain")||location.hostname},J=()=>{let o=b();if(o)return!!o.cookieless;return p()?.hasAttribute("data-cookieless")??!1},Uo=new Set(["localhost","127.0.0.1","[::1]"]),T=()=>{return Uo.has(location.hostname)||location.hostname.endsWith(".local")},_=()=>{let o=b();if(o)return!!o.local;return p()?.hasAttribute("data-local")??!1},S=()=>{return location.protocol==="file:"},a=()=>{let o=b();if(o)return!!o.allowFileProtocol;return p()?.hasAttribute("data-allow-file-protocol")??!1},oo=()=>{try{return window.self!==window.top}catch{return!0}},no=()=>{let o=b();if(o)return!!o.allowIframe;return p()?.hasAttribute("data-allow-iframe")??!1};var Y=()=>{let o=b();if(o)return!!o.hashMode;return p()?.src?.includes(".hash.js")??!1},to=()=>{let o=b();if(o?.allowedHostnames)return o.allowedHostnames;let t=p()?.getAttribute("data-allowed-hostnames");return t?t.split(",").map((c)=>c.trim()).filter(Boolean):[]},co=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},ro=()=>{let o=new URLSearchParams(window.location.search),n={};for(let t of["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref","source","via"]){let c=o.get(t);if(c)n[t]=c}return n};var l=(o,n)=>{let c=`${R()}/api/track`,r=m(),f=JSON.stringify({...n,websiteId:r,type:o});if(typeof navigator.sendBeacon==="function"){let i=new Blob([f],{type:"application/json"});if(navigator.sendBeacon(c,i))return}fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:f,keepalive:!0}).catch(()=>{})};var Q="_fs_vid",Z="_fs_sid",j="_fs_sts",Yo=1800000,K="_fs_vid",N="_fs_sid",Ko=(o)=>{let n=document.cookie.match(new RegExp(`(?:^|; )${o}=([^;]*)`));return n?decodeURIComponent(n[1]):null},fo=(o,n,t)=>{let c=new Date(Date.now()+t*86400000).toUTCString(),r=U(),f=r?`;domain=.${r}`:"";document.cookie=`${o}=${encodeURIComponent(n)};expires=${c};path=/${f};SameSite=Lax;Secure`},No=(o)=>{let n=U(),t=n?`;domain=.${n}`:"";document.cookie=`${o}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${t};SameSite=Lax;Secure`},Po=()=>{let o=new URLSearchParams(window.location.search),n=o.get(K)||void 0,t=o.get(N)||void 0;if(n||t){o.delete(K),o.delete(N);let c=o.toString(),r=window.location.pathname+(c?`?${c}`:"")+window.location.hash;history.replaceState(null,"",r)}return{vid:n,sid:t}},q=null,xo=()=>{if(q===null)q=Po();return q},x=()=>{if(J())return;let o=xo();if(o.vid){fo(Q,o.vid,730);let t=o.vid;return o.vid=void 0,t}let n=Ko(Q);if(!n)n=V(),fo(Q,n,730);return n},u=()=>{if(J())return;let o=xo();if(o.sid){let r=o.sid;return sessionStorage.setItem(Z,r),sessionStorage.setItem(j,Date.now().toString()),o.sid=void 0,r}let n=Date.now(),t=parseInt(sessionStorage.getItem(j)||"0",10),c=sessionStorage.getItem(Z);if(!c||n-t>Yo)c=V(),sessionStorage.setItem(Z,c);return sessionStorage.setItem(j,n.toString()),c},uo=()=>{if(J())return;sessionStorage.setItem(j,Date.now().toString())},z=()=>{let o=x(),n=u();return{...o&&{_fs_vid:o},...n&&{_fs_sid:n}}},B=(o)=>{let n=z(),t=new URL(o);if(n._fs_vid)t.searchParams.set(K,n._fs_vid);if(n._fs_sid)t.searchParams.set(N,n._fs_sid);return t.toString()},X=()=>{No(Q),sessionStorage.removeItem(Z),sessionStorage.removeItem(j),q=null};var vo=5000,v=0,g=0,H=null,Lo=()=>{let o=document.documentElement,n=window.scrollY||o.scrollTop,t=o.scrollHeight-o.clientHeight;if(t<=0)return 100;return Math.min(100,Math.round(n/t*100))},P=()=>{v++},lo=()=>{let o=Lo();g=Math.max(g,o);let n=x(),t=u();l("heartbeat",{...n&&{visitorUid:n},...t&&{sessionUid:t},path:location.pathname+location.search,scrollDepth:g,isVisible:document.visibilityState==="visible",interactionCount:v}),uo()},eo=()=>{v=0,g=0},so=()=>{document.addEventListener("click",P,{passive:!0}),document.addEventListener("scroll",P,{passive:!0}),document.addEventListener("keydown",P,{passive:!0}),H=setInterval(lo,vo),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")lo()})},h=()=>{if(H)clearInterval(H),H=null};var io="",bo=!1,w=()=>{let o=Y(),n=o?location.href:location.pathname+location.search;if(n===io)return;io=n,eo();let t=ro(),c=x(),r=u(),f=o?location.pathname+location.search+location.hash:location.pathname+location.search;if(l("pageview",{...c&&{visitorUid:c},...r&&{sessionUid:r},hostname:location.hostname,path:f,referrer:document.referrer||void 0,title:document.title||void 0,screenWidth:window.screen?.width,screenHeight:window.screen?.height,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||void 0,language:navigator.language||void 0,utmSource:t.utm_source,utmMedium:t.utm_medium,utmCampaign:t.utm_campaign,utmTerm:t.utm_term,utmContent:t.utm_content,ref:t.ref,source:t.source,via:t.via}),!bo){bo=!0;let i=O();if(i){let y=JSON.stringify({type:"geo",websiteId:m(),visitorUid:c||void 0,sessionUid:r||void 0});try{fetch(`${i}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:y,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},po=()=>{w();let{pushState:o,replaceState:n}=history;if(history.pushState=function(...t){o.apply(this,t),w()},history.replaceState=function(...t){n.apply(this,t),w()},window.addEventListener("popstate",()=>w()),Y())window.addEventListener("hashchange",()=>w())};var wo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t)return;try{let c=new URL(t);if(c.protocol!=="http:"&&c.protocol!=="https:")return;if(c.hostname===location.hostname)return;let r=x(),f=u();if(!r||!f)return;l("exit_click",{visitorUid:r,sessionUid:f,hostname:location.hostname,url:t})}catch{}})};var ko=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,yo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t||!ko.test(t))return;let c=x(),r=u();l("goal",{...c&&{visitorUid:c},...r&&{sessionUid:r},name:"file_download",metadata:{url:t}})})};var s=(o,n)=>{let t=x(),c=u();l("goal",{...t&&{visitorUid:t},...c&&{sessionUid:c},name:o,metadata:n})};var L="data-fs-goal",mo="data-fs-goal-",Io=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(mo)&&c.name!==L){let r=c.name.slice(mo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},Bo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest(`[${L}]`);if(!n)return;let t=n.getAttribute(L);if(!t)return;let c=Io(n);s(t,c)})};var G="data-fs-scroll",Fo="data-fs-scroll-threshold",k="data-fs-scroll-delay",jo="data-fs-scroll-",Co=new Set([G,Fo,k]),zo=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(jo)&&!Co.has(c.name)){let r=c.name.slice(jo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},Wo=()=>{let o=document.querySelectorAll(`[${G}]`);if(!o.length)return;let n=new Set,t=new IntersectionObserver((c)=>{for(let r of c){let f=r.target;if(!r.isIntersecting||n.has(f))continue;let i=f.getAttribute(G);if(!i)continue;let y=parseInt(f.getAttribute(k)||"0",10)||0,e=()=>{if(n.has(f))return;n.add(f),t.unobserve(f);let $=zo(f);s(i,$)};if(y>0)setTimeout(e,y);else e()}},{threshold:0});for(let c of Array.from(o)){let r=parseFloat(c.getAttribute(Fo)||"0.5");if(r!==0.5){let f=new IntersectionObserver((i)=>{for(let y of i){let e=y.target;if(!y.isIntersecting||n.has(e))continue;let $=e.getAttribute(G);if(!$)continue;let A=parseInt(e.getAttribute(k)||"0",10)||0,D=()=>{if(n.has(e))return;n.add(e),f.unobserve(e);let Zo=zo(e);s($,Zo)};if(A>0)setTimeout(D,A);else D()}},{threshold:r});f.observe(c)}else t.observe(c)}};var I=null,$o=()=>{if(!I)I=new Set(to());return I},Ao=(o)=>{let n=$o();if(!n.size)return!1;for(let t of n)if(o===t||o.endsWith(`.${t}`))return!0;return!1},Jo=()=>{if(!$o().size)return;document.addEventListener("click",(n)=>{let t=n.target.closest("a");if(!t)return;let c=t.href;if(!c)return;try{let r=new URL(c);if(r.hostname===location.hostname)return;if(!Ao(r.hostname))return;t.href=B(c)}catch{}})};var F=(o)=>{let n=x(),t=u();l("payment",{...n&&{visitorUid:n},...t&&{sessionUid:t},...o.amount!=null&&{amount:o.amount},...o.currency&&{currency:o.currency},...o.transactionId&&{transactionId:o.transactionId},...o.email&&{email:o.email},...o.name&&{name:o.name},...o.customerId&&{customerId:o.customerId},...o.isRenewal!=null&&{isRenewal:o.isRenewal},...o.isRefund!=null&&{isRefund:o.isRefund}})};var W=(o)=>{let n=x();l("identify",{...n&&{visitorUid:n},userId:o.userId,name:o.name,email:o.email,image:o.image,profileData:o.profileData})};var Qo=(o)=>{let[n,...t]=o;switch(n){case"identify":W(t[0]);break;case"payment":F(t[0]);break;default:s(n,t[0]);break}},C=()=>{if(d())return;if(!m())return;if(co())return;if(T()&&!_())return;if(S()&&!a())return;if(oo()&&!no())return;po(),so(),wo(),yo(),Bo(),Wo(),Jo();let o=window,n=o.flowsery?.q||[];for(let t of n)Qo(t);o.flowsery=function(...t){Qo(t)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",C);else C();var Do=async(o)=>{let n=window;return n.__flowsery_config=o,C(),{trackEvent:s,trackPayment:F,trackPageview:w,identify:W,stop:h,reset:X,getTrackingParams:z,buildCrossDomainUrl:B,getVisitorId:x,getSessionId:u}};})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flowsery",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Flowsery analytics tracking script",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"build:cjs": "bun build src/index.ts --outfile dist/index.cjs --minify --target node",
|
|
27
27
|
"dev": "bun build src/index.ts --outfile dist/script.js --watch --target browser",
|
|
28
28
|
"prepublishOnly": "bun run build",
|
|
29
|
-
"
|
|
29
|
+
"release": "npm publish",
|
|
30
30
|
"publish:patch": "npm version patch && npm publish",
|
|
31
31
|
"publish:minor": "npm version minor && npm publish",
|
|
32
32
|
"publish:major": "npm version major && npm publish"
|