flowsery 1.0.6 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -13
- 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/recording.hash.js +73 -0
- package/dist/recording.js +73 -0
- package/dist/script.hash.js +1 -1
- package/dist/script.js +1 -1
- package/package.json +10 -3
package/README.md
CHANGED
|
@@ -74,6 +74,42 @@ Typical proxy setup:
|
|
|
74
74
|
|
|
75
75
|
- `/js/main.js` serves the Flowsery browser bundle
|
|
76
76
|
- `/api/track` proxies to `https://analytics.flowsery.com/analytics/events`
|
|
77
|
+
|
|
78
|
+
## Session Recordings
|
|
79
|
+
|
|
80
|
+
Flowsery can capture session recordings (rrweb-based DOM replays, plus console
|
|
81
|
+
errors, failed network requests, and rage clicks). Recording ships as a separate
|
|
82
|
+
bundle so the core tracker stays small — it is only fetched when you opt in.
|
|
83
|
+
|
|
84
|
+
### Via npm
|
|
85
|
+
|
|
86
|
+
Set `recording: true` and Flowsery lazy-loads the recording bundle for you:
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import { initFlowsery } from 'flowsery';
|
|
90
|
+
|
|
91
|
+
const flowsery = await initFlowsery({
|
|
92
|
+
websiteId: 'flid_******',
|
|
93
|
+
recording: true,
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The recording bundle reuses the same visitor and session IDs as the main tracker,
|
|
98
|
+
so it respects `cookieless` mode and never records if the visitor is excluded.
|
|
99
|
+
|
|
100
|
+
### Via script tag
|
|
101
|
+
|
|
102
|
+
Add the `data-recording` attribute and Flowsery injects the recording bundle:
|
|
103
|
+
|
|
104
|
+
```html
|
|
105
|
+
<script
|
|
106
|
+
defer
|
|
107
|
+
data-fl-website-id="flid_******"
|
|
108
|
+
data-recording
|
|
109
|
+
src="https://cdn.flowsery.com/main.js"
|
|
110
|
+
></script>
|
|
111
|
+
```
|
|
112
|
+
|
|
77
113
|
## Script Tag
|
|
78
114
|
|
|
79
115
|
If you prefer not to use npm, you can install Flowsery with a script tag.
|
|
@@ -91,11 +127,12 @@ If you prefer not to use npm, you can install Flowsery with a script tag.
|
|
|
91
127
|
<script
|
|
92
128
|
defer
|
|
93
129
|
data-fl-website-id="flid_******"
|
|
94
|
-
data-domain="example.com"
|
|
95
130
|
src="https://cdn.flowsery.com/main.js"
|
|
96
131
|
></script>
|
|
97
132
|
```
|
|
98
133
|
|
|
134
|
+
`data-fl-website-id` is the only required attribute. See [script-configuration](https://flowsery.com/docs/script-configuration) for the full list of optional attributes — including `data-domain`, which only matters when you want a single visitor cookie shared across subdomains.
|
|
135
|
+
|
|
99
136
|
### Proxy install
|
|
100
137
|
|
|
101
138
|
```html
|
|
@@ -109,18 +146,6 @@ If you prefer not to use npm, you can install Flowsery with a script tag.
|
|
|
109
146
|
<script
|
|
110
147
|
defer
|
|
111
148
|
data-fl-website-id="flid_******"
|
|
112
|
-
data-domain="example.com"
|
|
113
|
-
src="https://example.com/js/main.js"
|
|
114
|
-
></script>
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
To improve geo accuracy in a proxied setup:
|
|
118
|
-
|
|
119
|
-
```html
|
|
120
|
-
<script
|
|
121
|
-
defer
|
|
122
|
-
data-fl-website-id="flid_******"
|
|
123
|
-
data-domain="example.com"
|
|
124
149
|
src="https://example.com/js/main.js"
|
|
125
150
|
></script>
|
|
126
151
|
```
|
|
@@ -164,6 +189,7 @@ type FlowseryConfig = {
|
|
|
164
189
|
disableConsole?: boolean;
|
|
165
190
|
allowedHostnames?: string[];
|
|
166
191
|
hashMode?: boolean;
|
|
192
|
+
recording?: boolean;
|
|
167
193
|
};
|
|
168
194
|
```
|
|
169
195
|
|
|
@@ -180,6 +206,8 @@ Build output:
|
|
|
180
206
|
- `dist/main.hash.js`
|
|
181
207
|
- `dist/script.js`
|
|
182
208
|
- `dist/script.hash.js`
|
|
209
|
+
- `dist/recording.js`
|
|
210
|
+
- `dist/recording.hash.js`
|
|
183
211
|
- `dist/index.mjs`
|
|
184
212
|
- `dist/index.cjs`
|
|
185
213
|
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var M=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(n)=>{let o=Math.random()*16|0;return(n==="x"?o:o&3|8).toString(16)})},E=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0};var p=()=>{return window.__flowsery_config||null},w=()=>{return document.querySelector("script[data-fl-website-id]")},m=()=>{let n=p();if(n)return n.websiteId;return w()?.getAttribute("data-fl-website-id")||""},R=()=>{return p()?.apiUrl??null},d=()=>{let n=p();if(n?.apiBase)return n.apiBase;let o=w(),t=o?.getAttribute("data-api");if(t)return t;let c=o?.src??"",r=c.replace(/\/js\/(?:script|main)(?:\.hash)?\.js.*/,"");return r===c?"":r},F=()=>{return"https://analytics.flowsery.com/analytics"},V=()=>{let n=p();if(n?.domain)return n.domain;return w()?.getAttribute("data-domain")||location.hostname},W=()=>{let n=p();if(n)return!!n.cookieless;return w()?.hasAttribute("data-cookieless")??!1},qn=new Set(["localhost","127.0.0.1","[::1]"]),O=()=>{return qn.has(location.hostname)||location.hostname.endsWith(".local")},T=()=>{let n=p();if(n)return!!n.local;return w()?.hasAttribute("data-local")??!1},_=()=>{return location.protocol==="file:"},S=()=>{let n=p();if(n)return!!n.allowFileProtocol;return w()?.hasAttribute("data-allow-file-protocol")??!1},a=()=>{try{return window.self!==window.top}catch{return!0}},nn=()=>{let n=p();if(n)return!!n.allowIframe;return w()?.hasAttribute("data-allow-iframe")??!1};var U=()=>{let n=p();if(n)return!!n.hashMode;return w()?.src?.includes(".hash.js")??!1},on=()=>{let n=p();if(n?.allowedHostnames)return n.allowedHostnames;let t=w()?.getAttribute("data-allowed-hostnames");return t?t.split(",").map((c)=>c.trim()).filter(Boolean):[]},tn=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},cn=()=>{let n=new URLSearchParams(window.location.search),o={};for(let t of["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref","source","via"]){let c=n.get(t);if(c)o[t]=c}return o};var rn=R(),s=(n,o)=>{let t=d(),c=!!t,r=rn??(c?`${t}/api/track`:`${F()}/events`),f=m(),e=JSON.stringify({...o,websiteId:f,type:n});if(rn||!c){try{let l=new XMLHttpRequest;l.open("POST",r,!0),l.setRequestHeader("Content-Type","application/json"),l.send(e)}catch(l){}return}if(typeof navigator.sendBeacon==="function"){let l=new Blob([e],{type:"application/json"});if(navigator.sendBeacon(r,l))return}fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:e,keepalive:!0}).catch(()=>{})};var $="_fs_vid",J="_fs_sid",B="_fs_sts",Xn=1800000,h="_fs_vid",Y="_fs_sid",Gn=(n)=>{let o=document.cookie.match(new RegExp(`(?:^|; )${n}=([^;]*)`));return o?decodeURIComponent(o[1]):null},fn=(n,o,t)=>{let c=new Date(Date.now()+t*86400000).toUTCString(),r=V(),f=r?`;domain=.${r}`:"";document.cookie=`${n}=${encodeURIComponent(o)};expires=${c};path=/${f};SameSite=Lax;Secure`},Hn=(n)=>{let o=V(),t=o?`;domain=.${o}`:"";document.cookie=`${n}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${t};SameSite=Lax;Secure`},Mn=()=>{let n=new URLSearchParams(window.location.search),o=n.get(h)||void 0,t=n.get(Y)||void 0;if(o||t){n.delete(h),n.delete(Y);let c=n.toString(),r=window.location.pathname+(c?`?${c}`:"")+window.location.hash;history.replaceState(null,"",r)}return{vid:o,sid:t}},Q=null,un=()=>{if(Q===null)Q=Mn();return Q},u=()=>{if(W())return;let n=un();if(n.vid){fn($,n.vid,730);let t=n.vid;return n.vid=void 0,t}let o=Gn($);if(!o)o=M(),fn($,o,730);return o},x=()=>{if(W())return;let n=un();if(n.sid){let r=n.sid;return sessionStorage.setItem(J,r),sessionStorage.setItem(B,Date.now().toString()),n.sid=void 0,r}let o=Date.now(),t=parseInt(sessionStorage.getItem(B)||"0",10),c=sessionStorage.getItem(J);if(!c||o-t>Xn)c=M(),sessionStorage.setItem(J,c);return sessionStorage.setItem(B,o.toString()),c},xn=()=>{if(W())return;sessionStorage.setItem(B,Date.now().toString())},Z=()=>{let n=u(),o=x();return{...n&&{_fs_vid:n},...o&&{_fs_sid:o}}},j=(n)=>{let o=Z(),t=new URL(n);if(o._fs_vid)t.searchParams.set(h,o._fs_vid);if(o._fs_sid)t.searchParams.set(Y,o._fs_sid);return t.toString()},K=()=>{Hn($),sessionStorage.removeItem(J),sessionStorage.removeItem(B),Q=null};var Vn=5000,v=0,g=0,q=null,Un=()=>{let n=document.documentElement,o=window.scrollY||n.scrollTop,t=n.scrollHeight-n.clientHeight;if(t<=0)return 100;return Math.min(100,Math.round(o/t*100))},N=()=>{v++},ln=()=>{let n=Un();g=Math.max(g,n);let o=u(),t=x();s("heartbeat",{...o&&{visitorUid:o},...t&&{sessionUid:t},path:location.pathname,scrollDepth:g,isVisible:document.visibilityState==="visible",interactionCount:v}),xn()},sn=()=>{v=0,g=0},en=()=>{document.addEventListener("click",N,{passive:!0}),document.addEventListener("scroll",N,{passive:!0}),document.addEventListener("keydown",N,{passive:!0}),q=setInterval(ln,Vn),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")ln()})},L=()=>{if(q)clearInterval(q),q=null};var pn="",wn=!1,y=()=>{let n=U(),o=n?location.href:location.pathname+location.search;if(o===pn)return;pn=o,sn();let t=cn(),c=u(),r=x(),f=n?location.pathname+location.hash:location.pathname;if(s("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}),!wn){wn=!0;let e=F();if(e){let l=JSON.stringify({type:"geo",websiteId:m(),visitorUid:c||void 0,sessionUid:r||void 0});try{fetch(`${e}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:l,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},bn=()=>{y();let{pushState:n,replaceState:o}=history;if(history.pushState=function(...t){n.apply(this,t),y()},history.replaceState=function(...t){o.apply(this,t),y()},window.addEventListener("popstate",()=>y()),U())window.addEventListener("hashchange",()=>y())};var yn=()=>{document.addEventListener("click",(n)=>{let o=n.target.closest("a");if(!o)return;let t=o.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=u(),f=x();if(!r||!f)return;s("exit_click",{visitorUid:r,sessionUid:f,hostname:location.hostname,url:t})}catch{}})};var hn=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,mn=()=>{document.addEventListener("click",(n)=>{let o=n.target.closest("a");if(!o)return;let t=o.href;if(!t||!hn.test(t))return;let c=u(),r=x();s("goal",{...c&&{visitorUid:c},...r&&{sessionUid:r},name:"file_download",metadata:{url:t}})})};var b=(n,o)=>{let t=u(),c=x();s("goal",{...t&&{visitorUid:t},...c&&{sessionUid:c},name:n,metadata:o})};var P="data-fs-goal",Bn="data-fs-goal-",Yn=(n)=>{let o={},t=0;for(let c of Array.from(n.attributes))if(c.name.startsWith(Bn)&&c.name!==P){let r=c.name.slice(Bn.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)o[r]=f,t++}return t>0?o:void 0},jn=()=>{document.addEventListener("click",(n)=>{let o=n.target.closest(`[${P}]`);if(!o)return;let t=o.getAttribute(P);if(!t)return;let c=Yn(o);b(t,c)})};var X="data-fs-scroll",Wn="data-fs-scroll-threshold",k="data-fs-scroll-delay",zn="data-fs-scroll-",Kn=new Set([X,Wn,k]),Fn=(n)=>{let o={},t=0;for(let c of Array.from(n.attributes))if(c.name.startsWith(zn)&&!Kn.has(c.name)){let r=c.name.slice(zn.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)o[r]=f,t++}return t>0?o:void 0},$n=()=>{let n=document.querySelectorAll(`[${X}]`);if(!n.length)return;let o=new Set,t=new IntersectionObserver((c)=>{for(let r of c){let f=r.target;if(!r.isIntersecting||o.has(f))continue;let e=f.getAttribute(X);if(!e)continue;let l=parseInt(f.getAttribute(k)||"0",10)||0,i=()=>{if(o.has(f))return;o.add(f),t.unobserve(f);let z=Fn(f);b(e,z)};if(l>0)setTimeout(i,l);else i()}},{threshold:0});for(let c of Array.from(n)){let r=parseFloat(c.getAttribute(Wn)||"0.5");if(r!==0.5){let f=new IntersectionObserver((e)=>{for(let l of e){let i=l.target;if(!l.isIntersecting||o.has(i))continue;let z=i.getAttribute(X);if(!z)continue;let D=parseInt(i.getAttribute(k)||"0",10)||0,A=()=>{if(o.has(i))return;o.add(i),f.unobserve(i);let gn=Fn(i);b(z,gn)};if(D>0)setTimeout(A,D);else A()}},{threshold:r});f.observe(c)}else t.observe(c)}};var I=null,Jn=()=>{if(!I)I=new Set(on());return I},Nn=(n)=>{let o=Jn();if(!o.size)return!1;for(let t of o)if(n===t||n.endsWith(`.${t}`))return!0;return!1},Qn=()=>{if(!Jn().size)return;document.addEventListener("click",(o)=>{let t=o.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(!Nn(r.hostname))return;t.href=j(c)}catch{}})};var G=(n)=>{let o=u(),t=x();s("payment",{...o&&{visitorUid:o},...t&&{sessionUid:t},...n.amount!=null&&{amount:n.amount},...n.currency&&{currency:n.currency},...n.transactionId&&{transactionId:n.transactionId},...n.email&&{email:n.email},...n.name&&{name:n.name},...n.customerId&&{customerId:n.customerId},...n.isRenewal!=null&&{isRenewal:n.isRenewal},...n.isRefund!=null&&{isRefund:n.isRefund}})};var H=(n)=>{let o=u();s("identify",{...o&&{visitorUid:o},userId:n.userId,name:n.name,email:n.email,image:n.image,profileData:n.profileData})};var Zn=(n)=>{let[o,...t]=n;switch(o){case"identify":H(t[0]);break;case"payment":G(t[0]);break;default:b(o,t[0]);break}},C=()=>{if(E())return;if(!m())return;if(tn())return;if(O()&&!T())return;if(_()&&!S())return;if(a()&&!nn())return;bn(),en(),yn(),mn(),jn(),$n(),Qn();let n=window,o=n.flowsery?.q||[];for(let t of o)Zn(t);n.flowsery=function(...t){Zn(t)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",C);else C();var Mo=async(n)=>{let o=window;return o.__flowsery_config=n,C(),{trackEvent:b,trackPayment:G,trackPageview:y,identify:H,stop:L,reset:K,getTrackingParams:Z,buildCrossDomainUrl:j,getVisitorId:u,getSessionId:x}};export{G as trackPayment,y as trackPageview,b as trackEvent,L as stopHeartbeat,K as reset,Mo as initFlowsery,H as identify,u as getVisitorId,Z as getTrackingParams,x as getSessionId,j as buildCrossDomainUrl};
|
|
1
|
+
var P=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(z)=>{let $=Math.random()*16|0;return(z==="x"?$:$&3|8).toString(16)})},l=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0};var X=()=>{return window.__flowsery_config||null},F=()=>{return document.querySelector("script[data-fl-website-id]")},Y=()=>{let z=X();if(z)return z.websiteId;return F()?.getAttribute("data-fl-website-id")||""},o=()=>{return X()?.apiUrl??null},s=()=>{let z=X();if(z?.apiBase)return z.apiBase;let $=F(),j=$?.getAttribute("data-api");if(j)return j;let J=$?.src??"",Q=J.replace(/\/js\/(?:script|main|recording)(?:\.hash)?\.js.*/,"");return Q===J?"":Q},N=()=>{return"https://analytics.flowsery.com/analytics"},C=()=>{let z=X();if(z?.domain)return z.domain;return F()?.getAttribute("data-domain")||location.hostname},w=()=>{let z=X();if(z)return!!z.cookieless;return F()?.hasAttribute("data-cookieless")??!1},Iz=new Set(["localhost","127.0.0.1","[::1]"]),r=()=>{return Iz.has(location.hostname)||location.hostname.endsWith(".local")},i=()=>{let z=X();if(z)return!!z.local;return F()?.hasAttribute("data-local")??!1},t=()=>{return location.protocol==="file:"},a=()=>{let z=X();if(z)return!!z.allowFileProtocol;return F()?.hasAttribute("data-allow-file-protocol")??!1},e=()=>{try{return window.self!==window.top}catch{return!0}},zz=()=>{let z=X();if(z)return!!z.allowIframe;return F()?.hasAttribute("data-allow-iframe")??!1};var u=()=>{let z=X();if(z)return!!z.hashMode;return F()?.src?.includes(".hash.js")??!1},$z=()=>{let z=X();if(z)return!!z.recording;return F()?.hasAttribute("data-recording")??!1},jz=()=>{let z=`recording${u()?".hash":""}.js`,$=F()?.src;if($)return $.replace(/(?:script|main)(?:\.hash)?\.js(?:\?.*)?$/,z);return`https://cdn.flowsery.com/${z}`},Jz=()=>{let z=X();if(z?.allowedHostnames)return z.allowedHostnames;let j=F()?.getAttribute("data-allowed-hostnames");return j?j.split(",").map((J)=>J.trim()).filter(Boolean):[]},Qz=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},Zz=()=>{let z=new URLSearchParams(window.location.search),$={};for(let j of["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref","source","via"]){let J=z.get(j);if(J)$[j]=J}return $};var qz=o(),Oz=61440,xz=(z,$)=>{try{let j=new XMLHttpRequest;j.open("POST",z,!0),j.setRequestHeader("Content-Type","application/json"),j.send($)}catch(j){}},W=(z,$)=>{let j=s(),J=!!j,Q=qz??(J?`${j}/api/track`:`${N()}/events`),Z=Y(),B=JSON.stringify({...$,websiteId:Z,type:z});if(qz||!J){xz(Q,B);return}if(B.length>Oz){xz(Q,B);return}if(typeof navigator.sendBeacon==="function"){let V=new Blob([B],{type:"application/json"});if(navigator.sendBeacon(Q,V))return}fetch(Q,{method:"POST",headers:{"Content-Type":"application/json"},body:B,keepalive:!0}).catch(()=>{})};var D="_fs_vid",v="_fs_sid",U="_fs_sts",Pz=1800000,T="_fs_vid",E="_fs_sid",Cz=(z)=>{let $=document.cookie.match(new RegExp(`(?:^|; )${z}=([^;]*)`));return $?decodeURIComponent($[1]):null},Wz=(z,$,j)=>{let J=new Date(Date.now()+j*86400000).toUTCString(),Q=C(),Z=Q?`;domain=.${Q}`:"";document.cookie=`${z}=${encodeURIComponent($)};expires=${J};path=/${Z};SameSite=Lax;Secure`},Tz=(z)=>{let $=C(),j=$?`;domain=.${$}`:"";document.cookie=`${z}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${j};SameSite=Lax;Secure`},Ez=()=>{let z=new URLSearchParams(window.location.search),$=z.get(T)||void 0,j=z.get(E)||void 0;if($||j){z.delete(T),z.delete(E);let J=z.toString(),Q=window.location.pathname+(J?`?${J}`:"")+window.location.hash;history.replaceState(null,"",Q)}return{vid:$,sid:j}},L=null,Bz=()=>{if(L===null)L=Ez();return L},q=()=>{if(w())return;let z=Bz();if(z.vid){Wz(D,z.vid,730);let j=z.vid;return z.vid=void 0,j}let $=Cz(D);if(!$)$=P(),Wz(D,$,730);return $},x=()=>{if(w())return;let z=Bz();if(z.sid){let Q=z.sid;return sessionStorage.setItem(v,Q),sessionStorage.setItem(U,Date.now().toString()),z.sid=void 0,Q}let $=Date.now(),j=parseInt(sessionStorage.getItem(U)||"0",10),J=sessionStorage.getItem(v);if(!J||$-j>Pz)J=P(),sessionStorage.setItem(v,J);return sessionStorage.setItem(U,$.toString()),J},Xz=()=>{if(w())return;sessionStorage.setItem(U,Date.now().toString())},b=()=>{let z=q(),$=x();return{...z&&{_fs_vid:z},...$&&{_fs_sid:$}}},H=(z)=>{let $=b(),j=new URL(z);if($._fs_vid)j.searchParams.set(T,$._fs_vid);if($._fs_sid)j.searchParams.set(E,$._fs_sid);return j.toString()},h=()=>{Tz(D),sessionStorage.removeItem(v),sessionStorage.removeItem(U),L=null};var hz=5000,_=0,k=0,f=null,Az=()=>{let z=document.documentElement,$=window.scrollY||z.scrollTop,j=z.scrollHeight-z.clientHeight;if(j<=0)return 100;return Math.min(100,Math.round($/j*100))},A=()=>{_++},Fz=()=>{let z=Az();k=Math.max(k,z);let $=q(),j=x();W("heartbeat",{...$&&{visitorUid:$},...j&&{sessionUid:j},path:location.pathname,scrollDepth:k,isVisible:document.visibilityState==="visible",interactionCount:_}),Xz()},Gz=()=>{_=0,k=0},Vz=()=>{document.addEventListener("click",A,{passive:!0}),document.addEventListener("scroll",A,{passive:!0}),document.addEventListener("keydown",A,{passive:!0}),f=setInterval(Fz,hz),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")Fz()})},p=()=>{if(f)clearInterval(f),f=null};var Kz="",Mz=!1,M=()=>{let z=u(),$=z?location.href:location.pathname+location.search;if($===Kz)return;Kz=$,Gz();let j=Zz(),J=q(),Q=x(),Z=z?location.pathname+location.hash:location.pathname;if(W("pageview",{...J&&{visitorUid:J},...Q&&{sessionUid:Q},hostname:location.hostname,path:Z,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:j.utm_source,utmMedium:j.utm_medium,utmCampaign:j.utm_campaign,utmTerm:j.utm_term,utmContent:j.utm_content,ref:j.ref,source:j.source,via:j.via}),!Mz){Mz=!0;let B=N();if(B){let V=JSON.stringify({type:"geo",websiteId:Y(),visitorUid:J||void 0,sessionUid:Q||void 0});try{fetch(`${B}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:V,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},Yz=()=>{M();let{pushState:z,replaceState:$}=history;if(history.pushState=function(...j){z.apply(this,j),M()},history.replaceState=function(...j){$.apply(this,j),M()},window.addEventListener("popstate",()=>M()),u())window.addEventListener("hashchange",()=>M())};var Uz=()=>{document.addEventListener("click",(z)=>{let $=z.target.closest("a");if(!$)return;let j=$.href;if(!j)return;try{let J=new URL(j);if(J.protocol!=="http:"&&J.protocol!=="https:")return;if(J.hostname===location.hostname)return;let Q=q(),Z=x();if(!Q||!Z)return;W("exit_click",{visitorUid:Q,sessionUid:Z,hostname:location.hostname,url:j})}catch{}})};var _z=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,Hz=()=>{document.addEventListener("click",(z)=>{let $=z.target.closest("a");if(!$)return;let j=$.href;if(!j||!_z.test(j))return;let J=q(),Q=x();W("goal",{...J&&{visitorUid:J},...Q&&{sessionUid:Q},name:"file_download",metadata:{url:j}})})};var K=(z,$)=>{let j=q(),J=x();W("goal",{...j&&{visitorUid:j},...J&&{sessionUid:J},name:z,metadata:$})};var m="data-fs-goal",yz="data-fs-goal-",pz=(z)=>{let $={},j=0;for(let J of Array.from(z.attributes))if(J.name.startsWith(yz)&&J.name!==m){let Q=J.name.slice(yz.length).replace(/-/g,"_"),Z=(J.value||"").slice(0,255);if(Q&&j<10)$[Q]=Z,j++}return j>0?$:void 0},Nz=()=>{document.addEventListener("click",(z)=>{let $=z.target.closest(`[${m}]`);if(!$)return;let j=$.getAttribute(m);if(!j)return;let J=pz($);K(j,J)})};var R="data-fs-scroll",Dz="data-fs-scroll-threshold",S="data-fs-scroll-delay",wz="data-fs-scroll-",mz=new Set([R,Dz,S]),uz=(z)=>{let $={},j=0;for(let J of Array.from(z.attributes))if(J.name.startsWith(wz)&&!mz.has(J.name)){let Q=J.name.slice(wz.length).replace(/-/g,"_"),Z=(J.value||"").slice(0,255);if(Q&&j<10)$[Q]=Z,j++}return j>0?$:void 0},vz=()=>{let z=document.querySelectorAll(`[${R}]`);if(!z.length)return;let $=new Set,j=new IntersectionObserver((J)=>{for(let Q of J){let Z=Q.target;if(!Q.isIntersecting||$.has(Z))continue;let B=Z.getAttribute(R);if(!B)continue;let V=parseInt(Z.getAttribute(S)||"0",10)||0,G=()=>{if($.has(Z))return;$.add(Z),j.unobserve(Z);let y=uz(Z);K(B,y)};if(V>0)setTimeout(G,V);else G()}},{threshold:0});for(let J of Array.from(z)){let Q=parseFloat(J.getAttribute(Dz)||"0.5");if(Q!==0.5){let Z=new IntersectionObserver((B)=>{for(let V of B){let G=V.target;if(!V.isIntersecting||$.has(G))continue;let y=G.getAttribute(R);if(!y)continue;let n=parseInt(G.getAttribute(S)||"0",10)||0,g=()=>{if($.has(G))return;$.add(G),Z.unobserve(G);let Rz=uz(G);K(y,Rz)};if(n>0)setTimeout(g,n);else g()}},{threshold:Q});Z.observe(J)}else j.observe(J)}};var c=null,Lz=()=>{if(!c)c=new Set(Jz());return c},Sz=(z)=>{let $=Lz();if(!$.size)return!1;for(let j of $)if(z===j||z.endsWith(`.${j}`))return!0;return!1},bz=()=>{if(!Lz().size)return;document.addEventListener("click",($)=>{let j=$.target.closest("a");if(!j)return;let J=j.href;if(!J)return;try{let Q=new URL(J);if(Q.hostname===location.hostname)return;if(!Sz(Q.hostname))return;j.href=H(J)}catch{}})};var cz="buy.stripe.com",dz=(z,$)=>{try{let j=new URL(z);if(j.hostname!==cz)return z;if(j.searchParams.has("client_reference_id"))return z;return j.searchParams.set("client_reference_id",$),j.toString()}catch{return z}},kz=()=>{document.addEventListener("click",(z)=>{let $=z.target.closest("a");if(!$||!$.href)return;let j=q();if(!j)return;$.href=dz($.href,j)})};var I=(z)=>{let $=q(),j=x();W("payment",{...$&&{visitorUid:$},...j&&{sessionUid:j},...z.amount!=null&&{amount:z.amount},...z.currency&&{currency:z.currency},...z.transactionId&&{transactionId:z.transactionId},...z.email&&{email:z.email},...z.name&&{name:z.name},...z.customerId&&{customerId:z.customerId},...z.isRenewal!=null&&{isRenewal:z.isRenewal},...z.isRefund!=null&&{isRefund:z.isRefund}})};var O=(z)=>{let $=q();W("identify",{...$&&{visitorUid:$},userId:z.userId,name:z.name,email:z.email,image:z.image,profileData:z.profileData})};var nz=()=>{if(typeof document>"u")return;if(document.querySelector("script[data-fl-recording]"))return;let z=document.createElement("script");z.src=jz(),z.defer=!0,z.setAttribute("data-fl-recording",""),(document.head||document.documentElement).appendChild(z)},fz=(z)=>{let[$,...j]=z;switch($){case"identify":O(j[0]);break;case"payment":I(j[0]);break;default:K($,j[0]);break}},d=()=>{if(l())return;if(!Y())return;if(Qz())return;if(r()&&!i())return;if(t()&&!a())return;if(e()&&!zz())return;if(Yz(),Vz(),Uz(),Hz(),Nz(),vz(),bz(),kz(),$z())nz();let z=window,$=z.flowsery?.q||[];for(let j of $)fz(j);z.flowsery=function(...j){fz(j)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",d);else d();var S3=async(z)=>{let $=window;return $.__flowsery_config=z,d(),{trackEvent:K,trackPayment:I,trackPageview:M,identify:O,stop:p,reset:h,getTrackingParams:b,buildCrossDomainUrl:H,getVisitorId:q,getSessionId:x}};export{I as trackPayment,M as trackPageview,K as trackEvent,p as stopHeartbeat,h as reset,S3 as initFlowsery,O as identify,q as getVisitorId,b as getTrackingParams,x as getSessionId,H as buildCrossDomainUrl};
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var M=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(n)=>{let o=Math.random()*16|0;return(n==="x"?o:o&3|8).toString(16)})},E=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0};var p=()=>{return window.__flowsery_config||null},w=()=>{return document.querySelector("script[data-fl-website-id]")},m=()=>{let n=p();if(n)return n.websiteId;return w()?.getAttribute("data-fl-website-id")||""},R=()=>{return p()?.apiUrl??null},d=()=>{let n=p();if(n?.apiBase)return n.apiBase;let o=w(),t=o?.getAttribute("data-api");if(t)return t;let c=o?.src??"",r=c.replace(/\/js\/(?:script|main)(?:\.hash)?\.js.*/,"");return r===c?"":r},F=()=>{return"https://analytics.flowsery.com/analytics"},V=()=>{let n=p();if(n?.domain)return n.domain;return w()?.getAttribute("data-domain")||location.hostname},W=()=>{let n=p();if(n)return!!n.cookieless;return w()?.hasAttribute("data-cookieless")??!1},qn=new Set(["localhost","127.0.0.1","[::1]"]),O=()=>{return qn.has(location.hostname)||location.hostname.endsWith(".local")},T=()=>{let n=p();if(n)return!!n.local;return w()?.hasAttribute("data-local")??!1},_=()=>{return location.protocol==="file:"},S=()=>{let n=p();if(n)return!!n.allowFileProtocol;return w()?.hasAttribute("data-allow-file-protocol")??!1},a=()=>{try{return window.self!==window.top}catch{return!0}},nn=()=>{let n=p();if(n)return!!n.allowIframe;return w()?.hasAttribute("data-allow-iframe")??!1};var U=()=>{let n=p();if(n)return!!n.hashMode;return w()?.src?.includes(".hash.js")??!1},on=()=>{let n=p();if(n?.allowedHostnames)return n.allowedHostnames;let t=w()?.getAttribute("data-allowed-hostnames");return t?t.split(",").map((c)=>c.trim()).filter(Boolean):[]},tn=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},cn=()=>{let n=new URLSearchParams(window.location.search),o={};for(let t of["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref","source","via"]){let c=n.get(t);if(c)o[t]=c}return o};var rn=R(),s=(n,o)=>{let t=d(),c=!!t,r=rn??(c?`${t}/api/track`:`${F()}/events`),f=m(),e=JSON.stringify({...o,websiteId:f,type:n});if(rn||!c){try{let l=new XMLHttpRequest;l.open("POST",r,!0),l.setRequestHeader("Content-Type","application/json"),l.send(e)}catch(l){}return}if(typeof navigator.sendBeacon==="function"){let l=new Blob([e],{type:"application/json"});if(navigator.sendBeacon(r,l))return}fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:e,keepalive:!0}).catch(()=>{})};var $="_fs_vid",J="_fs_sid",B="_fs_sts",Xn=1800000,h="_fs_vid",Y="_fs_sid",Gn=(n)=>{let o=document.cookie.match(new RegExp(`(?:^|; )${n}=([^;]*)`));return o?decodeURIComponent(o[1]):null},fn=(n,o,t)=>{let c=new Date(Date.now()+t*86400000).toUTCString(),r=V(),f=r?`;domain=.${r}`:"";document.cookie=`${n}=${encodeURIComponent(o)};expires=${c};path=/${f};SameSite=Lax;Secure`},Hn=(n)=>{let o=V(),t=o?`;domain=.${o}`:"";document.cookie=`${n}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${t};SameSite=Lax;Secure`},Mn=()=>{let n=new URLSearchParams(window.location.search),o=n.get(h)||void 0,t=n.get(Y)||void 0;if(o||t){n.delete(h),n.delete(Y);let c=n.toString(),r=window.location.pathname+(c?`?${c}`:"")+window.location.hash;history.replaceState(null,"",r)}return{vid:o,sid:t}},Q=null,un=()=>{if(Q===null)Q=Mn();return Q},u=()=>{if(W())return;let n=un();if(n.vid){fn($,n.vid,730);let t=n.vid;return n.vid=void 0,t}let o=Gn($);if(!o)o=M(),fn($,o,730);return o},x=()=>{if(W())return;let n=un();if(n.sid){let r=n.sid;return sessionStorage.setItem(J,r),sessionStorage.setItem(B,Date.now().toString()),n.sid=void 0,r}let o=Date.now(),t=parseInt(sessionStorage.getItem(B)||"0",10),c=sessionStorage.getItem(J);if(!c||o-t>Xn)c=M(),sessionStorage.setItem(J,c);return sessionStorage.setItem(B,o.toString()),c},xn=()=>{if(W())return;sessionStorage.setItem(B,Date.now().toString())},Z=()=>{let n=u(),o=x();return{...n&&{_fs_vid:n},...o&&{_fs_sid:o}}},j=(n)=>{let o=Z(),t=new URL(n);if(o._fs_vid)t.searchParams.set(h,o._fs_vid);if(o._fs_sid)t.searchParams.set(Y,o._fs_sid);return t.toString()},K=()=>{Hn($),sessionStorage.removeItem(J),sessionStorage.removeItem(B),Q=null};var Vn=5000,v=0,g=0,q=null,Un=()=>{let n=document.documentElement,o=window.scrollY||n.scrollTop,t=n.scrollHeight-n.clientHeight;if(t<=0)return 100;return Math.min(100,Math.round(o/t*100))},N=()=>{v++},ln=()=>{let n=Un();g=Math.max(g,n);let o=u(),t=x();s("heartbeat",{...o&&{visitorUid:o},...t&&{sessionUid:t},path:location.pathname,scrollDepth:g,isVisible:document.visibilityState==="visible",interactionCount:v}),xn()},sn=()=>{v=0,g=0},en=()=>{document.addEventListener("click",N,{passive:!0}),document.addEventListener("scroll",N,{passive:!0}),document.addEventListener("keydown",N,{passive:!0}),q=setInterval(ln,Vn),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")ln()})},L=()=>{if(q)clearInterval(q),q=null};var pn="",wn=!1,y=()=>{let n=U(),o=n?location.href:location.pathname+location.search;if(o===pn)return;pn=o,sn();let t=cn(),c=u(),r=x(),f=n?location.pathname+location.hash:location.pathname;if(s("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}),!wn){wn=!0;let e=F();if(e){let l=JSON.stringify({type:"geo",websiteId:m(),visitorUid:c||void 0,sessionUid:r||void 0});try{fetch(`${e}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:l,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},bn=()=>{y();let{pushState:n,replaceState:o}=history;if(history.pushState=function(...t){n.apply(this,t),y()},history.replaceState=function(...t){o.apply(this,t),y()},window.addEventListener("popstate",()=>y()),U())window.addEventListener("hashchange",()=>y())};var yn=()=>{document.addEventListener("click",(n)=>{let o=n.target.closest("a");if(!o)return;let t=o.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=u(),f=x();if(!r||!f)return;s("exit_click",{visitorUid:r,sessionUid:f,hostname:location.hostname,url:t})}catch{}})};var hn=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,mn=()=>{document.addEventListener("click",(n)=>{let o=n.target.closest("a");if(!o)return;let t=o.href;if(!t||!hn.test(t))return;let c=u(),r=x();s("goal",{...c&&{visitorUid:c},...r&&{sessionUid:r},name:"file_download",metadata:{url:t}})})};var b=(n,o)=>{let t=u(),c=x();s("goal",{...t&&{visitorUid:t},...c&&{sessionUid:c},name:n,metadata:o})};var P="data-fs-goal",Bn="data-fs-goal-",Yn=(n)=>{let o={},t=0;for(let c of Array.from(n.attributes))if(c.name.startsWith(Bn)&&c.name!==P){let r=c.name.slice(Bn.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)o[r]=f,t++}return t>0?o:void 0},jn=()=>{document.addEventListener("click",(n)=>{let o=n.target.closest(`[${P}]`);if(!o)return;let t=o.getAttribute(P);if(!t)return;let c=Yn(o);b(t,c)})};var X="data-fs-scroll",Wn="data-fs-scroll-threshold",k="data-fs-scroll-delay",zn="data-fs-scroll-",Kn=new Set([X,Wn,k]),Fn=(n)=>{let o={},t=0;for(let c of Array.from(n.attributes))if(c.name.startsWith(zn)&&!Kn.has(c.name)){let r=c.name.slice(zn.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)o[r]=f,t++}return t>0?o:void 0},$n=()=>{let n=document.querySelectorAll(`[${X}]`);if(!n.length)return;let o=new Set,t=new IntersectionObserver((c)=>{for(let r of c){let f=r.target;if(!r.isIntersecting||o.has(f))continue;let e=f.getAttribute(X);if(!e)continue;let l=parseInt(f.getAttribute(k)||"0",10)||0,i=()=>{if(o.has(f))return;o.add(f),t.unobserve(f);let z=Fn(f);b(e,z)};if(l>0)setTimeout(i,l);else i()}},{threshold:0});for(let c of Array.from(n)){let r=parseFloat(c.getAttribute(Wn)||"0.5");if(r!==0.5){let f=new IntersectionObserver((e)=>{for(let l of e){let i=l.target;if(!l.isIntersecting||o.has(i))continue;let z=i.getAttribute(X);if(!z)continue;let D=parseInt(i.getAttribute(k)||"0",10)||0,A=()=>{if(o.has(i))return;o.add(i),f.unobserve(i);let gn=Fn(i);b(z,gn)};if(D>0)setTimeout(A,D);else A()}},{threshold:r});f.observe(c)}else t.observe(c)}};var I=null,Jn=()=>{if(!I)I=new Set(on());return I},Nn=(n)=>{let o=Jn();if(!o.size)return!1;for(let t of o)if(n===t||n.endsWith(`.${t}`))return!0;return!1},Qn=()=>{if(!Jn().size)return;document.addEventListener("click",(o)=>{let t=o.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(!Nn(r.hostname))return;t.href=j(c)}catch{}})};var G=(n)=>{let o=u(),t=x();s("payment",{...o&&{visitorUid:o},...t&&{sessionUid:t},...n.amount!=null&&{amount:n.amount},...n.currency&&{currency:n.currency},...n.transactionId&&{transactionId:n.transactionId},...n.email&&{email:n.email},...n.name&&{name:n.name},...n.customerId&&{customerId:n.customerId},...n.isRenewal!=null&&{isRenewal:n.isRenewal},...n.isRefund!=null&&{isRefund:n.isRefund}})};var H=(n)=>{let o=u();s("identify",{...o&&{visitorUid:o},userId:n.userId,name:n.name,email:n.email,image:n.image,profileData:n.profileData})};var Zn=(n)=>{let[o,...t]=n;switch(o){case"identify":H(t[0]);break;case"payment":G(t[0]);break;default:b(o,t[0]);break}},C=()=>{if(E())return;if(!m())return;if(tn())return;if(O()&&!T())return;if(_()&&!S())return;if(a()&&!nn())return;bn(),en(),yn(),mn(),jn(),$n(),Qn();let n=window,o=n.flowsery?.q||[];for(let t of o)Zn(t);n.flowsery=function(...t){Zn(t)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",C);else C();var Mo=async(n)=>{let o=window;return o.__flowsery_config=n,C(),{trackEvent:b,trackPayment:G,trackPageview:y,identify:H,stop:L,reset:K,getTrackingParams:Z,buildCrossDomainUrl:j,getVisitorId:u,getSessionId:x}};export{G as trackPayment,y as trackPageview,b as trackEvent,L as stopHeartbeat,K as reset,Mo as initFlowsery,H as identify,u as getVisitorId,Z as getTrackingParams,x as getSessionId,j as buildCrossDomainUrl};
|
|
1
|
+
var P=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(z)=>{let $=Math.random()*16|0;return(z==="x"?$:$&3|8).toString(16)})},l=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0};var X=()=>{return window.__flowsery_config||null},F=()=>{return document.querySelector("script[data-fl-website-id]")},Y=()=>{let z=X();if(z)return z.websiteId;return F()?.getAttribute("data-fl-website-id")||""},o=()=>{return X()?.apiUrl??null},s=()=>{let z=X();if(z?.apiBase)return z.apiBase;let $=F(),j=$?.getAttribute("data-api");if(j)return j;let J=$?.src??"",Q=J.replace(/\/js\/(?:script|main|recording)(?:\.hash)?\.js.*/,"");return Q===J?"":Q},N=()=>{return"https://analytics.flowsery.com/analytics"},C=()=>{let z=X();if(z?.domain)return z.domain;return F()?.getAttribute("data-domain")||location.hostname},w=()=>{let z=X();if(z)return!!z.cookieless;return F()?.hasAttribute("data-cookieless")??!1},Iz=new Set(["localhost","127.0.0.1","[::1]"]),r=()=>{return Iz.has(location.hostname)||location.hostname.endsWith(".local")},i=()=>{let z=X();if(z)return!!z.local;return F()?.hasAttribute("data-local")??!1},t=()=>{return location.protocol==="file:"},a=()=>{let z=X();if(z)return!!z.allowFileProtocol;return F()?.hasAttribute("data-allow-file-protocol")??!1},e=()=>{try{return window.self!==window.top}catch{return!0}},zz=()=>{let z=X();if(z)return!!z.allowIframe;return F()?.hasAttribute("data-allow-iframe")??!1};var u=()=>{let z=X();if(z)return!!z.hashMode;return F()?.src?.includes(".hash.js")??!1},$z=()=>{let z=X();if(z)return!!z.recording;return F()?.hasAttribute("data-recording")??!1},jz=()=>{let z=`recording${u()?".hash":""}.js`,$=F()?.src;if($)return $.replace(/(?:script|main)(?:\.hash)?\.js(?:\?.*)?$/,z);return`https://cdn.flowsery.com/${z}`},Jz=()=>{let z=X();if(z?.allowedHostnames)return z.allowedHostnames;let j=F()?.getAttribute("data-allowed-hostnames");return j?j.split(",").map((J)=>J.trim()).filter(Boolean):[]},Qz=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},Zz=()=>{let z=new URLSearchParams(window.location.search),$={};for(let j of["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref","source","via"]){let J=z.get(j);if(J)$[j]=J}return $};var qz=o(),Oz=61440,xz=(z,$)=>{try{let j=new XMLHttpRequest;j.open("POST",z,!0),j.setRequestHeader("Content-Type","application/json"),j.send($)}catch(j){}},W=(z,$)=>{let j=s(),J=!!j,Q=qz??(J?`${j}/api/track`:`${N()}/events`),Z=Y(),B=JSON.stringify({...$,websiteId:Z,type:z});if(qz||!J){xz(Q,B);return}if(B.length>Oz){xz(Q,B);return}if(typeof navigator.sendBeacon==="function"){let V=new Blob([B],{type:"application/json"});if(navigator.sendBeacon(Q,V))return}fetch(Q,{method:"POST",headers:{"Content-Type":"application/json"},body:B,keepalive:!0}).catch(()=>{})};var D="_fs_vid",v="_fs_sid",U="_fs_sts",Pz=1800000,T="_fs_vid",E="_fs_sid",Cz=(z)=>{let $=document.cookie.match(new RegExp(`(?:^|; )${z}=([^;]*)`));return $?decodeURIComponent($[1]):null},Wz=(z,$,j)=>{let J=new Date(Date.now()+j*86400000).toUTCString(),Q=C(),Z=Q?`;domain=.${Q}`:"";document.cookie=`${z}=${encodeURIComponent($)};expires=${J};path=/${Z};SameSite=Lax;Secure`},Tz=(z)=>{let $=C(),j=$?`;domain=.${$}`:"";document.cookie=`${z}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${j};SameSite=Lax;Secure`},Ez=()=>{let z=new URLSearchParams(window.location.search),$=z.get(T)||void 0,j=z.get(E)||void 0;if($||j){z.delete(T),z.delete(E);let J=z.toString(),Q=window.location.pathname+(J?`?${J}`:"")+window.location.hash;history.replaceState(null,"",Q)}return{vid:$,sid:j}},L=null,Bz=()=>{if(L===null)L=Ez();return L},q=()=>{if(w())return;let z=Bz();if(z.vid){Wz(D,z.vid,730);let j=z.vid;return z.vid=void 0,j}let $=Cz(D);if(!$)$=P(),Wz(D,$,730);return $},x=()=>{if(w())return;let z=Bz();if(z.sid){let Q=z.sid;return sessionStorage.setItem(v,Q),sessionStorage.setItem(U,Date.now().toString()),z.sid=void 0,Q}let $=Date.now(),j=parseInt(sessionStorage.getItem(U)||"0",10),J=sessionStorage.getItem(v);if(!J||$-j>Pz)J=P(),sessionStorage.setItem(v,J);return sessionStorage.setItem(U,$.toString()),J},Xz=()=>{if(w())return;sessionStorage.setItem(U,Date.now().toString())},b=()=>{let z=q(),$=x();return{...z&&{_fs_vid:z},...$&&{_fs_sid:$}}},H=(z)=>{let $=b(),j=new URL(z);if($._fs_vid)j.searchParams.set(T,$._fs_vid);if($._fs_sid)j.searchParams.set(E,$._fs_sid);return j.toString()},h=()=>{Tz(D),sessionStorage.removeItem(v),sessionStorage.removeItem(U),L=null};var hz=5000,_=0,k=0,f=null,Az=()=>{let z=document.documentElement,$=window.scrollY||z.scrollTop,j=z.scrollHeight-z.clientHeight;if(j<=0)return 100;return Math.min(100,Math.round($/j*100))},A=()=>{_++},Fz=()=>{let z=Az();k=Math.max(k,z);let $=q(),j=x();W("heartbeat",{...$&&{visitorUid:$},...j&&{sessionUid:j},path:location.pathname,scrollDepth:k,isVisible:document.visibilityState==="visible",interactionCount:_}),Xz()},Gz=()=>{_=0,k=0},Vz=()=>{document.addEventListener("click",A,{passive:!0}),document.addEventListener("scroll",A,{passive:!0}),document.addEventListener("keydown",A,{passive:!0}),f=setInterval(Fz,hz),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")Fz()})},p=()=>{if(f)clearInterval(f),f=null};var Kz="",Mz=!1,M=()=>{let z=u(),$=z?location.href:location.pathname+location.search;if($===Kz)return;Kz=$,Gz();let j=Zz(),J=q(),Q=x(),Z=z?location.pathname+location.hash:location.pathname;if(W("pageview",{...J&&{visitorUid:J},...Q&&{sessionUid:Q},hostname:location.hostname,path:Z,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:j.utm_source,utmMedium:j.utm_medium,utmCampaign:j.utm_campaign,utmTerm:j.utm_term,utmContent:j.utm_content,ref:j.ref,source:j.source,via:j.via}),!Mz){Mz=!0;let B=N();if(B){let V=JSON.stringify({type:"geo",websiteId:Y(),visitorUid:J||void 0,sessionUid:Q||void 0});try{fetch(`${B}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:V,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},Yz=()=>{M();let{pushState:z,replaceState:$}=history;if(history.pushState=function(...j){z.apply(this,j),M()},history.replaceState=function(...j){$.apply(this,j),M()},window.addEventListener("popstate",()=>M()),u())window.addEventListener("hashchange",()=>M())};var Uz=()=>{document.addEventListener("click",(z)=>{let $=z.target.closest("a");if(!$)return;let j=$.href;if(!j)return;try{let J=new URL(j);if(J.protocol!=="http:"&&J.protocol!=="https:")return;if(J.hostname===location.hostname)return;let Q=q(),Z=x();if(!Q||!Z)return;W("exit_click",{visitorUid:Q,sessionUid:Z,hostname:location.hostname,url:j})}catch{}})};var _z=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,Hz=()=>{document.addEventListener("click",(z)=>{let $=z.target.closest("a");if(!$)return;let j=$.href;if(!j||!_z.test(j))return;let J=q(),Q=x();W("goal",{...J&&{visitorUid:J},...Q&&{sessionUid:Q},name:"file_download",metadata:{url:j}})})};var K=(z,$)=>{let j=q(),J=x();W("goal",{...j&&{visitorUid:j},...J&&{sessionUid:J},name:z,metadata:$})};var m="data-fs-goal",yz="data-fs-goal-",pz=(z)=>{let $={},j=0;for(let J of Array.from(z.attributes))if(J.name.startsWith(yz)&&J.name!==m){let Q=J.name.slice(yz.length).replace(/-/g,"_"),Z=(J.value||"").slice(0,255);if(Q&&j<10)$[Q]=Z,j++}return j>0?$:void 0},Nz=()=>{document.addEventListener("click",(z)=>{let $=z.target.closest(`[${m}]`);if(!$)return;let j=$.getAttribute(m);if(!j)return;let J=pz($);K(j,J)})};var R="data-fs-scroll",Dz="data-fs-scroll-threshold",S="data-fs-scroll-delay",wz="data-fs-scroll-",mz=new Set([R,Dz,S]),uz=(z)=>{let $={},j=0;for(let J of Array.from(z.attributes))if(J.name.startsWith(wz)&&!mz.has(J.name)){let Q=J.name.slice(wz.length).replace(/-/g,"_"),Z=(J.value||"").slice(0,255);if(Q&&j<10)$[Q]=Z,j++}return j>0?$:void 0},vz=()=>{let z=document.querySelectorAll(`[${R}]`);if(!z.length)return;let $=new Set,j=new IntersectionObserver((J)=>{for(let Q of J){let Z=Q.target;if(!Q.isIntersecting||$.has(Z))continue;let B=Z.getAttribute(R);if(!B)continue;let V=parseInt(Z.getAttribute(S)||"0",10)||0,G=()=>{if($.has(Z))return;$.add(Z),j.unobserve(Z);let y=uz(Z);K(B,y)};if(V>0)setTimeout(G,V);else G()}},{threshold:0});for(let J of Array.from(z)){let Q=parseFloat(J.getAttribute(Dz)||"0.5");if(Q!==0.5){let Z=new IntersectionObserver((B)=>{for(let V of B){let G=V.target;if(!V.isIntersecting||$.has(G))continue;let y=G.getAttribute(R);if(!y)continue;let n=parseInt(G.getAttribute(S)||"0",10)||0,g=()=>{if($.has(G))return;$.add(G),Z.unobserve(G);let Rz=uz(G);K(y,Rz)};if(n>0)setTimeout(g,n);else g()}},{threshold:Q});Z.observe(J)}else j.observe(J)}};var c=null,Lz=()=>{if(!c)c=new Set(Jz());return c},Sz=(z)=>{let $=Lz();if(!$.size)return!1;for(let j of $)if(z===j||z.endsWith(`.${j}`))return!0;return!1},bz=()=>{if(!Lz().size)return;document.addEventListener("click",($)=>{let j=$.target.closest("a");if(!j)return;let J=j.href;if(!J)return;try{let Q=new URL(J);if(Q.hostname===location.hostname)return;if(!Sz(Q.hostname))return;j.href=H(J)}catch{}})};var cz="buy.stripe.com",dz=(z,$)=>{try{let j=new URL(z);if(j.hostname!==cz)return z;if(j.searchParams.has("client_reference_id"))return z;return j.searchParams.set("client_reference_id",$),j.toString()}catch{return z}},kz=()=>{document.addEventListener("click",(z)=>{let $=z.target.closest("a");if(!$||!$.href)return;let j=q();if(!j)return;$.href=dz($.href,j)})};var I=(z)=>{let $=q(),j=x();W("payment",{...$&&{visitorUid:$},...j&&{sessionUid:j},...z.amount!=null&&{amount:z.amount},...z.currency&&{currency:z.currency},...z.transactionId&&{transactionId:z.transactionId},...z.email&&{email:z.email},...z.name&&{name:z.name},...z.customerId&&{customerId:z.customerId},...z.isRenewal!=null&&{isRenewal:z.isRenewal},...z.isRefund!=null&&{isRefund:z.isRefund}})};var O=(z)=>{let $=q();W("identify",{...$&&{visitorUid:$},userId:z.userId,name:z.name,email:z.email,image:z.image,profileData:z.profileData})};var nz=()=>{if(typeof document>"u")return;if(document.querySelector("script[data-fl-recording]"))return;let z=document.createElement("script");z.src=jz(),z.defer=!0,z.setAttribute("data-fl-recording",""),(document.head||document.documentElement).appendChild(z)},fz=(z)=>{let[$,...j]=z;switch($){case"identify":O(j[0]);break;case"payment":I(j[0]);break;default:K($,j[0]);break}},d=()=>{if(l())return;if(!Y())return;if(Qz())return;if(r()&&!i())return;if(t()&&!a())return;if(e()&&!zz())return;if(Yz(),Vz(),Uz(),Hz(),Nz(),vz(),bz(),kz(),$z())nz();let z=window,$=z.flowsery?.q||[];for(let j of $)fz(j);z.flowsery=function(...j){fz(j)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",d);else d();var S3=async(z)=>{let $=window;return $.__flowsery_config=z,d(),{trackEvent:K,trackPayment:I,trackPageview:M,identify:O,stop:p,reset:h,getTrackingParams:b,buildCrossDomainUrl:H,getVisitorId:q,getSessionId:x}};export{I as trackPayment,M as trackPageview,K as trackEvent,p as stopHeartbeat,h as reset,S3 as initFlowsery,O as identify,q as getVisitorId,b as getTrackingParams,x as getSessionId,H as buildCrossDomainUrl};
|
package/dist/main.hash.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var{defineProperty:U,getOwnPropertyNames:Gn,getOwnPropertyDescriptor:Hn}=Object,Mn=Object.prototype.hasOwnProperty;function Vn(n){return this[n]}var Un=(n)=>{var o=(R??=new WeakMap).get(n),t;if(o)return o;if(o=U({},"__esModule",{value:!0}),n&&typeof n==="object"||typeof n==="function"){for(var c of Gn(n))if(!Mn.call(o,c))U(o,c,{get:Vn.bind(n,c),enumerable:!(t=Hn(n,c))||t.enumerable})}return R.set(n,o),o},R;var hn=(n)=>n;function Yn(n,o){this[n]=hn.bind(null,o)}var Kn=(n,o)=>{for(var t in o)U(n,t,{get:o[t],enumerable:!0,configurable:!0,set:Yn.bind(o,t)})};var On={};Kn(On,{trackPayment:()=>F,trackPageview:()=>y,trackEvent:()=>w,stopHeartbeat:()=>M,reset:()=>X,initFlowsery:()=>dn,identify:()=>W,getVisitorId:()=>u,getTrackingParams:()=>z,getSessionId:()=>x,buildCrossDomainUrl:()=>B});var h=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(n)=>{let o=Math.random()*16|0;return(n==="x"?o:o&3|8).toString(16)})},d=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0};var p=()=>{return window.__flowsery_config||null},b=()=>{return document.querySelector("script[data-fl-website-id]")},m=()=>{let n=p();if(n)return n.websiteId;return b()?.getAttribute("data-fl-website-id")||""},O=()=>{return p()?.apiUrl??null},T=()=>{let n=p();if(n?.apiBase)return n.apiBase;let o=b(),t=o?.getAttribute("data-api");if(t)return t;let c=o?.src??"",r=c.replace(/\/js\/(?:script|main)(?:\.hash)?\.js.*/,"");return r===c?"":r},J=()=>{return"https://analytics.flowsery.com/analytics"},Y=()=>{let n=p();if(n?.domain)return n.domain;return b()?.getAttribute("data-domain")||location.hostname},Q=()=>{let n=p();if(n)return!!n.cookieless;return b()?.hasAttribute("data-cookieless")??!1},Nn=new Set(["localhost","127.0.0.1","[::1]"]),_=()=>{return Nn.has(location.hostname)||location.hostname.endsWith(".local")},S=()=>{let n=p();if(n)return!!n.local;return b()?.hasAttribute("data-local")??!1},a=()=>{return location.protocol==="file:"},nn=()=>{let n=p();if(n)return!!n.allowFileProtocol;return b()?.hasAttribute("data-allow-file-protocol")??!1},on=()=>{try{return window.self!==window.top}catch{return!0}},tn=()=>{let n=p();if(n)return!!n.allowIframe;return b()?.hasAttribute("data-allow-iframe")??!1};var K=()=>{let n=p();if(n)return!!n.hashMode;return b()?.src?.includes(".hash.js")??!1},cn=()=>{let n=p();if(n?.allowedHostnames)return n.allowedHostnames;let t=b()?.getAttribute("data-allowed-hostnames");return t?t.split(",").map((c)=>c.trim()).filter(Boolean):[]},rn=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},fn=()=>{let n=new URLSearchParams(window.location.search),o={};for(let t of["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref","source","via"]){let c=n.get(t);if(c)o[t]=c}return o};var un=O(),s=(n,o)=>{let t=T(),c=!!t,r=un??(c?`${t}/api/track`:`${J()}/events`),f=m(),e=JSON.stringify({...o,websiteId:f,type:n});if(un||!c){try{let l=new XMLHttpRequest;l.open("POST",r,!0),l.setRequestHeader("Content-Type","application/json"),l.send(e)}catch(l){}return}if(typeof navigator.sendBeacon==="function"){let l=new Blob([e],{type:"application/json"});if(navigator.sendBeacon(r,l))return}fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:e,keepalive:!0}).catch(()=>{})};var Z="_fs_vid",g="_fs_sid",j="_fs_sts",vn=1800000,N="_fs_vid",v="_fs_sid",Ln=(n)=>{let o=document.cookie.match(new RegExp(`(?:^|; )${n}=([^;]*)`));return o?decodeURIComponent(o[1]):null},xn=(n,o,t)=>{let c=new Date(Date.now()+t*86400000).toUTCString(),r=Y(),f=r?`;domain=.${r}`:"";document.cookie=`${n}=${encodeURIComponent(o)};expires=${c};path=/${f};SameSite=Lax;Secure`},Pn=(n)=>{let o=Y(),t=o?`;domain=.${o}`:"";document.cookie=`${n}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${t};SameSite=Lax;Secure`},kn=()=>{let n=new URLSearchParams(window.location.search),o=n.get(N)||void 0,t=n.get(v)||void 0;if(o||t){n.delete(N),n.delete(v);let c=n.toString(),r=window.location.pathname+(c?`?${c}`:"")+window.location.hash;history.replaceState(null,"",r)}return{vid:o,sid:t}},q=null,ln=()=>{if(q===null)q=kn();return q},u=()=>{if(Q())return;let n=ln();if(n.vid){xn(Z,n.vid,730);let t=n.vid;return n.vid=void 0,t}let o=Ln(Z);if(!o)o=h(),xn(Z,o,730);return o},x=()=>{if(Q())return;let n=ln();if(n.sid){let r=n.sid;return sessionStorage.setItem(g,r),sessionStorage.setItem(j,Date.now().toString()),n.sid=void 0,r}let o=Date.now(),t=parseInt(sessionStorage.getItem(j)||"0",10),c=sessionStorage.getItem(g);if(!c||o-t>vn)c=h(),sessionStorage.setItem(g,c);return sessionStorage.setItem(j,o.toString()),c},sn=()=>{if(Q())return;sessionStorage.setItem(j,Date.now().toString())},z=()=>{let n=u(),o=x();return{...n&&{_fs_vid:n},...o&&{_fs_sid:o}}},B=(n)=>{let o=z(),t=new URL(n);if(o._fs_vid)t.searchParams.set(N,o._fs_vid);if(o._fs_sid)t.searchParams.set(v,o._fs_sid);return t.toString()},X=()=>{Pn(Z),sessionStorage.removeItem(g),sessionStorage.removeItem(j),q=null};var In=5000,P=0,G=0,H=null,Cn=()=>{let n=document.documentElement,o=window.scrollY||n.scrollTop,t=n.scrollHeight-n.clientHeight;if(t<=0)return 100;return Math.min(100,Math.round(o/t*100))},L=()=>{P++},en=()=>{let n=Cn();G=Math.max(G,n);let o=u(),t=x();s("heartbeat",{...o&&{visitorUid:o},...t&&{sessionUid:t},path:location.pathname,scrollDepth:G,isVisible:document.visibilityState==="visible",interactionCount:P}),sn()},pn=()=>{P=0,G=0},wn=()=>{document.addEventListener("click",L,{passive:!0}),document.addEventListener("scroll",L,{passive:!0}),document.addEventListener("keydown",L,{passive:!0}),H=setInterval(en,In),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")en()})},M=()=>{if(H)clearInterval(H),H=null};var bn="",yn=!1,y=()=>{let n=K(),o=n?location.href:location.pathname+location.search;if(o===bn)return;bn=o,pn();let t=fn(),c=u(),r=x(),f=n?location.pathname+location.hash:location.pathname;if(s("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}),!yn){yn=!0;let e=J();if(e){let l=JSON.stringify({type:"geo",websiteId:m(),visitorUid:c||void 0,sessionUid:r||void 0});try{fetch(`${e}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:l,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},mn=()=>{y();let{pushState:n,replaceState:o}=history;if(history.pushState=function(...t){n.apply(this,t),y()},history.replaceState=function(...t){o.apply(this,t),y()},window.addEventListener("popstate",()=>y()),K())window.addEventListener("hashchange",()=>y())};var Bn=()=>{document.addEventListener("click",(n)=>{let o=n.target.closest("a");if(!o)return;let t=o.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=u(),f=x();if(!r||!f)return;s("exit_click",{visitorUid:r,sessionUid:f,hostname:location.hostname,url:t})}catch{}})};var Dn=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,jn=()=>{document.addEventListener("click",(n)=>{let o=n.target.closest("a");if(!o)return;let t=o.href;if(!t||!Dn.test(t))return;let c=u(),r=x();s("goal",{...c&&{visitorUid:c},...r&&{sessionUid:r},name:"file_download",metadata:{url:t}})})};var w=(n,o)=>{let t=u(),c=x();s("goal",{...t&&{visitorUid:t},...c&&{sessionUid:c},name:n,metadata:o})};var k="data-fs-goal",zn="data-fs-goal-",An=(n)=>{let o={},t=0;for(let c of Array.from(n.attributes))if(c.name.startsWith(zn)&&c.name!==k){let r=c.name.slice(zn.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)o[r]=f,t++}return t>0?o:void 0},Fn=()=>{document.addEventListener("click",(n)=>{let o=n.target.closest(`[${k}]`);if(!o)return;let t=o.getAttribute(k);if(!t)return;let c=An(o);w(t,c)})};var V="data-fs-scroll",Jn="data-fs-scroll-threshold",I="data-fs-scroll-delay",Wn="data-fs-scroll-",En=new Set([V,Jn,I]),$n=(n)=>{let o={},t=0;for(let c of Array.from(n.attributes))if(c.name.startsWith(Wn)&&!En.has(c.name)){let r=c.name.slice(Wn.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)o[r]=f,t++}return t>0?o:void 0},Qn=()=>{let n=document.querySelectorAll(`[${V}]`);if(!n.length)return;let o=new Set,t=new IntersectionObserver((c)=>{for(let r of c){let f=r.target;if(!r.isIntersecting||o.has(f))continue;let e=f.getAttribute(V);if(!e)continue;let l=parseInt(f.getAttribute(I)||"0",10)||0,i=()=>{if(o.has(f))return;o.add(f),t.unobserve(f);let $=$n(f);w(e,$)};if(l>0)setTimeout(i,l);else i()}},{threshold:0});for(let c of Array.from(n)){let r=parseFloat(c.getAttribute(Jn)||"0.5");if(r!==0.5){let f=new IntersectionObserver((e)=>{for(let l of e){let i=l.target;if(!l.isIntersecting||o.has(i))continue;let $=i.getAttribute(V);if(!$)continue;let A=parseInt(i.getAttribute(I)||"0",10)||0,E=()=>{if(o.has(i))return;o.add(i),f.unobserve(i);let Xn=$n(i);w($,Xn)};if(A>0)setTimeout(E,A);else E()}},{threshold:r});f.observe(c)}else t.observe(c)}};var C=null,Zn=()=>{if(!C)C=new Set(cn());return C},Rn=(n)=>{let o=Zn();if(!o.size)return!1;for(let t of o)if(n===t||n.endsWith(`.${t}`))return!0;return!1},gn=()=>{if(!Zn().size)return;document.addEventListener("click",(o)=>{let t=o.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(!Rn(r.hostname))return;t.href=B(c)}catch{}})};var F=(n)=>{let o=u(),t=x();s("payment",{...o&&{visitorUid:o},...t&&{sessionUid:t},...n.amount!=null&&{amount:n.amount},...n.currency&&{currency:n.currency},...n.transactionId&&{transactionId:n.transactionId},...n.email&&{email:n.email},...n.name&&{name:n.name},...n.customerId&&{customerId:n.customerId},...n.isRenewal!=null&&{isRenewal:n.isRenewal},...n.isRefund!=null&&{isRefund:n.isRefund}})};var W=(n)=>{let o=u();s("identify",{...o&&{visitorUid:o},userId:n.userId,name:n.name,email:n.email,image:n.image,profileData:n.profileData})};var qn=(n)=>{let[o,...t]=n;switch(o){case"identify":W(t[0]);break;case"payment":F(t[0]);break;default:w(o,t[0]);break}},D=()=>{if(d())return;if(!m())return;if(rn())return;if(_()&&!S())return;if(a()&&!nn())return;if(on()&&!tn())return;mn(),wn(),Bn(),jn(),Fn(),Qn(),gn();let n=window,o=n.flowsery?.q||[];for(let t of o)qn(t);n.flowsery=function(...t){qn(t)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",D);else D();var dn=async(n)=>{let o=window;return o.__flowsery_config=n,D(),{trackEvent:w,trackPayment:F,trackPageview:y,identify:W,stop:M,reset:X,getTrackingParams:z,buildCrossDomainUrl:B,getVisitorId:u,getSessionId:x}};})();
|
|
1
|
+
(()=>{var{defineProperty:T,getOwnPropertyNames:Pz,getOwnPropertyDescriptor:Cz}=Object,Tz=Object.prototype.hasOwnProperty;function Ez(z){return this[z]}var hz=(z)=>{var $=(o??=new WeakMap).get(z),j;if($)return $;if($=T({},"__esModule",{value:!0}),z&&typeof z==="object"||typeof z==="function"){for(var J of Pz(z))if(!Tz.call($,J))T($,J,{get:Ez.bind(z,J),enumerable:!(j=Cz(z,J))||j.enumerable})}return o.set(z,$),$},o;var Az=(z)=>z;function _z(z,$){this[z]=Az.bind(null,$)}var pz=(z,$)=>{for(var j in $)T(z,j,{get:$[j],enumerable:!0,configurable:!0,set:_z.bind($,j)})};var j3={};pz(j3,{trackPayment:()=>N,trackPageview:()=>M,trackEvent:()=>V,stopHeartbeat:()=>P,reset:()=>R,initFlowsery:()=>$3,identify:()=>w,getVisitorId:()=>q,getTrackingParams:()=>y,getSessionId:()=>x,buildCrossDomainUrl:()=>U});var E=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(z)=>{let $=Math.random()*16|0;return(z==="x"?$:$&3|8).toString(16)})},s=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0};var X=()=>{return window.__flowsery_config||null},F=()=>{return document.querySelector("script[data-fl-website-id]")},Y=()=>{let z=X();if(z)return z.websiteId;return F()?.getAttribute("data-fl-website-id")||""},r=()=>{return X()?.apiUrl??null},i=()=>{let z=X();if(z?.apiBase)return z.apiBase;let $=F(),j=$?.getAttribute("data-api");if(j)return j;let J=$?.src??"",Q=J.replace(/\/js\/(?:script|main|recording)(?:\.hash)?\.js.*/,"");return Q===J?"":Q},D=()=>{return"https://analytics.flowsery.com/analytics"},h=()=>{let z=X();if(z?.domain)return z.domain;return F()?.getAttribute("data-domain")||location.hostname},v=()=>{let z=X();if(z)return!!z.cookieless;return F()?.hasAttribute("data-cookieless")??!1},mz=new Set(["localhost","127.0.0.1","[::1]"]),t=()=>{return mz.has(location.hostname)||location.hostname.endsWith(".local")},a=()=>{let z=X();if(z)return!!z.local;return F()?.hasAttribute("data-local")??!1},e=()=>{return location.protocol==="file:"},zz=()=>{let z=X();if(z)return!!z.allowFileProtocol;return F()?.hasAttribute("data-allow-file-protocol")??!1},$z=()=>{try{return window.self!==window.top}catch{return!0}},jz=()=>{let z=X();if(z)return!!z.allowIframe;return F()?.hasAttribute("data-allow-iframe")??!1};var L=()=>{let z=X();if(z)return!!z.hashMode;return F()?.src?.includes(".hash.js")??!1},Jz=()=>{let z=X();if(z)return!!z.recording;return F()?.hasAttribute("data-recording")??!1},Qz=()=>{let z=`recording${L()?".hash":""}.js`,$=F()?.src;if($)return $.replace(/(?:script|main)(?:\.hash)?\.js(?:\?.*)?$/,z);return`https://cdn.flowsery.com/${z}`},Zz=()=>{let z=X();if(z?.allowedHostnames)return z.allowedHostnames;let j=F()?.getAttribute("data-allowed-hostnames");return j?j.split(",").map((J)=>J.trim()).filter(Boolean):[]},qz=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},xz=()=>{let z=new URLSearchParams(window.location.search),$={};for(let j of["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref","source","via"]){let J=z.get(j);if(J)$[j]=J}return $};var Wz=r(),Sz=61440,Bz=(z,$)=>{try{let j=new XMLHttpRequest;j.open("POST",z,!0),j.setRequestHeader("Content-Type","application/json"),j.send($)}catch(j){}},W=(z,$)=>{let j=i(),J=!!j,Q=Wz??(J?`${j}/api/track`:`${D()}/events`),Z=Y(),B=JSON.stringify({...$,websiteId:Z,type:z});if(Wz||!J){Bz(Q,B);return}if(B.length>Sz){Bz(Q,B);return}if(typeof navigator.sendBeacon==="function"){let K=new Blob([B],{type:"application/json"});if(navigator.sendBeacon(Q,K))return}fetch(Q,{method:"POST",headers:{"Content-Type":"application/json"},body:B,keepalive:!0}).catch(()=>{})};var b="_fs_vid",k="_fs_sid",H="_fs_sts",cz=1800000,A="_fs_vid",_="_fs_sid",dz=(z)=>{let $=document.cookie.match(new RegExp(`(?:^|; )${z}=([^;]*)`));return $?decodeURIComponent($[1]):null},Xz=(z,$,j)=>{let J=new Date(Date.now()+j*86400000).toUTCString(),Q=h(),Z=Q?`;domain=.${Q}`:"";document.cookie=`${z}=${encodeURIComponent($)};expires=${J};path=/${Z};SameSite=Lax;Secure`},nz=(z)=>{let $=h(),j=$?`;domain=.${$}`:"";document.cookie=`${z}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${j};SameSite=Lax;Secure`},gz=()=>{let z=new URLSearchParams(window.location.search),$=z.get(A)||void 0,j=z.get(_)||void 0;if($||j){z.delete(A),z.delete(_);let J=z.toString(),Q=window.location.pathname+(J?`?${J}`:"")+window.location.hash;history.replaceState(null,"",Q)}return{vid:$,sid:j}},f=null,Fz=()=>{if(f===null)f=gz();return f},q=()=>{if(v())return;let z=Fz();if(z.vid){Xz(b,z.vid,730);let j=z.vid;return z.vid=void 0,j}let $=dz(b);if(!$)$=E(),Xz(b,$,730);return $},x=()=>{if(v())return;let z=Fz();if(z.sid){let Q=z.sid;return sessionStorage.setItem(k,Q),sessionStorage.setItem(H,Date.now().toString()),z.sid=void 0,Q}let $=Date.now(),j=parseInt(sessionStorage.getItem(H)||"0",10),J=sessionStorage.getItem(k);if(!J||$-j>cz)J=E(),sessionStorage.setItem(k,J);return sessionStorage.setItem(H,$.toString()),J},Gz=()=>{if(v())return;sessionStorage.setItem(H,Date.now().toString())},y=()=>{let z=q(),$=x();return{...z&&{_fs_vid:z},...$&&{_fs_sid:$}}},U=(z)=>{let $=y(),j=new URL(z);if($._fs_vid)j.searchParams.set(A,$._fs_vid);if($._fs_sid)j.searchParams.set(_,$._fs_sid);return j.toString()},R=()=>{nz(b),sessionStorage.removeItem(k),sessionStorage.removeItem(H),f=null};var lz=5000,m=0,I=0,O=null,oz=()=>{let z=document.documentElement,$=window.scrollY||z.scrollTop,j=z.scrollHeight-z.clientHeight;if(j<=0)return 100;return Math.min(100,Math.round($/j*100))},p=()=>{m++},Vz=()=>{let z=oz();I=Math.max(I,z);let $=q(),j=x();W("heartbeat",{...$&&{visitorUid:$},...j&&{sessionUid:j},path:location.pathname,scrollDepth:I,isVisible:document.visibilityState==="visible",interactionCount:m}),Gz()},Kz=()=>{m=0,I=0},Mz=()=>{document.addEventListener("click",p,{passive:!0}),document.addEventListener("scroll",p,{passive:!0}),document.addEventListener("keydown",p,{passive:!0}),O=setInterval(Vz,lz),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")Vz()})},P=()=>{if(O)clearInterval(O),O=null};var Yz="",Uz=!1,M=()=>{let z=L(),$=z?location.href:location.pathname+location.search;if($===Yz)return;Yz=$,Kz();let j=xz(),J=q(),Q=x(),Z=z?location.pathname+location.hash:location.pathname;if(W("pageview",{...J&&{visitorUid:J},...Q&&{sessionUid:Q},hostname:location.hostname,path:Z,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:j.utm_source,utmMedium:j.utm_medium,utmCampaign:j.utm_campaign,utmTerm:j.utm_term,utmContent:j.utm_content,ref:j.ref,source:j.source,via:j.via}),!Uz){Uz=!0;let B=D();if(B){let K=JSON.stringify({type:"geo",websiteId:Y(),visitorUid:J||void 0,sessionUid:Q||void 0});try{fetch(`${B}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:K,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},Hz=()=>{M();let{pushState:z,replaceState:$}=history;if(history.pushState=function(...j){z.apply(this,j),M()},history.replaceState=function(...j){$.apply(this,j),M()},window.addEventListener("popstate",()=>M()),L())window.addEventListener("hashchange",()=>M())};var yz=()=>{document.addEventListener("click",(z)=>{let $=z.target.closest("a");if(!$)return;let j=$.href;if(!j)return;try{let J=new URL(j);if(J.protocol!=="http:"&&J.protocol!=="https:")return;if(J.hostname===location.hostname)return;let Q=q(),Z=x();if(!Q||!Z)return;W("exit_click",{visitorUid:Q,sessionUid:Z,hostname:location.hostname,url:j})}catch{}})};var sz=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,Nz=()=>{document.addEventListener("click",(z)=>{let $=z.target.closest("a");if(!$)return;let j=$.href;if(!j||!sz.test(j))return;let J=q(),Q=x();W("goal",{...J&&{visitorUid:J},...Q&&{sessionUid:Q},name:"file_download",metadata:{url:j}})})};var V=(z,$)=>{let j=q(),J=x();W("goal",{...j&&{visitorUid:j},...J&&{sessionUid:J},name:z,metadata:$})};var S="data-fs-goal",wz="data-fs-goal-",rz=(z)=>{let $={},j=0;for(let J of Array.from(z.attributes))if(J.name.startsWith(wz)&&J.name!==S){let Q=J.name.slice(wz.length).replace(/-/g,"_"),Z=(J.value||"").slice(0,255);if(Q&&j<10)$[Q]=Z,j++}return j>0?$:void 0},uz=()=>{document.addEventListener("click",(z)=>{let $=z.target.closest(`[${S}]`);if(!$)return;let j=$.getAttribute(S);if(!j)return;let J=rz($);V(j,J)})};var C="data-fs-scroll",Lz="data-fs-scroll-threshold",c="data-fs-scroll-delay",Dz="data-fs-scroll-",iz=new Set([C,Lz,c]),vz=(z)=>{let $={},j=0;for(let J of Array.from(z.attributes))if(J.name.startsWith(Dz)&&!iz.has(J.name)){let Q=J.name.slice(Dz.length).replace(/-/g,"_"),Z=(J.value||"").slice(0,255);if(Q&&j<10)$[Q]=Z,j++}return j>0?$:void 0},bz=()=>{let z=document.querySelectorAll(`[${C}]`);if(!z.length)return;let $=new Set,j=new IntersectionObserver((J)=>{for(let Q of J){let Z=Q.target;if(!Q.isIntersecting||$.has(Z))continue;let B=Z.getAttribute(C);if(!B)continue;let K=parseInt(Z.getAttribute(c)||"0",10)||0,G=()=>{if($.has(Z))return;$.add(Z),j.unobserve(Z);let u=vz(Z);V(B,u)};if(K>0)setTimeout(G,K);else G()}},{threshold:0});for(let J of Array.from(z)){let Q=parseFloat(J.getAttribute(Lz)||"0.5");if(Q!==0.5){let Z=new IntersectionObserver((B)=>{for(let K of B){let G=K.target;if(!K.isIntersecting||$.has(G))continue;let u=G.getAttribute(C);if(!u)continue;let g=parseInt(G.getAttribute(c)||"0",10)||0,l=()=>{if($.has(G))return;$.add(G),Z.unobserve(G);let Oz=vz(G);V(u,Oz)};if(g>0)setTimeout(l,g);else l()}},{threshold:Q});Z.observe(J)}else j.observe(J)}};var d=null,kz=()=>{if(!d)d=new Set(Zz());return d},tz=(z)=>{let $=kz();if(!$.size)return!1;for(let j of $)if(z===j||z.endsWith(`.${j}`))return!0;return!1},fz=()=>{if(!kz().size)return;document.addEventListener("click",($)=>{let j=$.target.closest("a");if(!j)return;let J=j.href;if(!J)return;try{let Q=new URL(J);if(Q.hostname===location.hostname)return;if(!tz(Q.hostname))return;j.href=U(J)}catch{}})};var az="buy.stripe.com",ez=(z,$)=>{try{let j=new URL(z);if(j.hostname!==az)return z;if(j.searchParams.has("client_reference_id"))return z;return j.searchParams.set("client_reference_id",$),j.toString()}catch{return z}},Rz=()=>{document.addEventListener("click",(z)=>{let $=z.target.closest("a");if(!$||!$.href)return;let j=q();if(!j)return;$.href=ez($.href,j)})};var N=(z)=>{let $=q(),j=x();W("payment",{...$&&{visitorUid:$},...j&&{sessionUid:j},...z.amount!=null&&{amount:z.amount},...z.currency&&{currency:z.currency},...z.transactionId&&{transactionId:z.transactionId},...z.email&&{email:z.email},...z.name&&{name:z.name},...z.customerId&&{customerId:z.customerId},...z.isRenewal!=null&&{isRenewal:z.isRenewal},...z.isRefund!=null&&{isRefund:z.isRefund}})};var w=(z)=>{let $=q();W("identify",{...$&&{visitorUid:$},userId:z.userId,name:z.name,email:z.email,image:z.image,profileData:z.profileData})};var z3=()=>{if(typeof document>"u")return;if(document.querySelector("script[data-fl-recording]"))return;let z=document.createElement("script");z.src=Qz(),z.defer=!0,z.setAttribute("data-fl-recording",""),(document.head||document.documentElement).appendChild(z)},Iz=(z)=>{let[$,...j]=z;switch($){case"identify":w(j[0]);break;case"payment":N(j[0]);break;default:V($,j[0]);break}},n=()=>{if(s())return;if(!Y())return;if(qz())return;if(t()&&!a())return;if(e()&&!zz())return;if($z()&&!jz())return;if(Hz(),Mz(),yz(),Nz(),uz(),bz(),fz(),Rz(),Jz())z3();let z=window,$=z.flowsery?.q||[];for(let j of $)Iz(j);z.flowsery=function(...j){Iz(j)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",n);else n();var $3=async(z)=>{let $=window;return $.__flowsery_config=z,n(),{trackEvent:V,trackPayment:N,trackPageview:M,identify:w,stop:P,reset:R,getTrackingParams:y,buildCrossDomainUrl:U,getVisitorId:q,getSessionId:x}};})();
|
package/dist/main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var{defineProperty:U,getOwnPropertyNames:Gn,getOwnPropertyDescriptor:Hn}=Object,Mn=Object.prototype.hasOwnProperty;function Vn(n){return this[n]}var Un=(n)=>{var o=(R??=new WeakMap).get(n),t;if(o)return o;if(o=U({},"__esModule",{value:!0}),n&&typeof n==="object"||typeof n==="function"){for(var c of Gn(n))if(!Mn.call(o,c))U(o,c,{get:Vn.bind(n,c),enumerable:!(t=Hn(n,c))||t.enumerable})}return R.set(n,o),o},R;var hn=(n)=>n;function Yn(n,o){this[n]=hn.bind(null,o)}var Kn=(n,o)=>{for(var t in o)U(n,t,{get:o[t],enumerable:!0,configurable:!0,set:Yn.bind(o,t)})};var On={};Kn(On,{trackPayment:()=>F,trackPageview:()=>y,trackEvent:()=>w,stopHeartbeat:()=>M,reset:()=>X,initFlowsery:()=>dn,identify:()=>W,getVisitorId:()=>u,getTrackingParams:()=>z,getSessionId:()=>x,buildCrossDomainUrl:()=>B});var h=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(n)=>{let o=Math.random()*16|0;return(n==="x"?o:o&3|8).toString(16)})},d=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0};var p=()=>{return window.__flowsery_config||null},b=()=>{return document.querySelector("script[data-fl-website-id]")},m=()=>{let n=p();if(n)return n.websiteId;return b()?.getAttribute("data-fl-website-id")||""},O=()=>{return p()?.apiUrl??null},T=()=>{let n=p();if(n?.apiBase)return n.apiBase;let o=b(),t=o?.getAttribute("data-api");if(t)return t;let c=o?.src??"",r=c.replace(/\/js\/(?:script|main)(?:\.hash)?\.js.*/,"");return r===c?"":r},J=()=>{return"https://analytics.flowsery.com/analytics"},Y=()=>{let n=p();if(n?.domain)return n.domain;return b()?.getAttribute("data-domain")||location.hostname},Q=()=>{let n=p();if(n)return!!n.cookieless;return b()?.hasAttribute("data-cookieless")??!1},Nn=new Set(["localhost","127.0.0.1","[::1]"]),_=()=>{return Nn.has(location.hostname)||location.hostname.endsWith(".local")},S=()=>{let n=p();if(n)return!!n.local;return b()?.hasAttribute("data-local")??!1},a=()=>{return location.protocol==="file:"},nn=()=>{let n=p();if(n)return!!n.allowFileProtocol;return b()?.hasAttribute("data-allow-file-protocol")??!1},on=()=>{try{return window.self!==window.top}catch{return!0}},tn=()=>{let n=p();if(n)return!!n.allowIframe;return b()?.hasAttribute("data-allow-iframe")??!1};var K=()=>{let n=p();if(n)return!!n.hashMode;return b()?.src?.includes(".hash.js")??!1},cn=()=>{let n=p();if(n?.allowedHostnames)return n.allowedHostnames;let t=b()?.getAttribute("data-allowed-hostnames");return t?t.split(",").map((c)=>c.trim()).filter(Boolean):[]},rn=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},fn=()=>{let n=new URLSearchParams(window.location.search),o={};for(let t of["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref","source","via"]){let c=n.get(t);if(c)o[t]=c}return o};var un=O(),s=(n,o)=>{let t=T(),c=!!t,r=un??(c?`${t}/api/track`:`${J()}/events`),f=m(),e=JSON.stringify({...o,websiteId:f,type:n});if(un||!c){try{let l=new XMLHttpRequest;l.open("POST",r,!0),l.setRequestHeader("Content-Type","application/json"),l.send(e)}catch(l){}return}if(typeof navigator.sendBeacon==="function"){let l=new Blob([e],{type:"application/json"});if(navigator.sendBeacon(r,l))return}fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:e,keepalive:!0}).catch(()=>{})};var Z="_fs_vid",g="_fs_sid",j="_fs_sts",vn=1800000,N="_fs_vid",v="_fs_sid",Ln=(n)=>{let o=document.cookie.match(new RegExp(`(?:^|; )${n}=([^;]*)`));return o?decodeURIComponent(o[1]):null},xn=(n,o,t)=>{let c=new Date(Date.now()+t*86400000).toUTCString(),r=Y(),f=r?`;domain=.${r}`:"";document.cookie=`${n}=${encodeURIComponent(o)};expires=${c};path=/${f};SameSite=Lax;Secure`},Pn=(n)=>{let o=Y(),t=o?`;domain=.${o}`:"";document.cookie=`${n}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${t};SameSite=Lax;Secure`},kn=()=>{let n=new URLSearchParams(window.location.search),o=n.get(N)||void 0,t=n.get(v)||void 0;if(o||t){n.delete(N),n.delete(v);let c=n.toString(),r=window.location.pathname+(c?`?${c}`:"")+window.location.hash;history.replaceState(null,"",r)}return{vid:o,sid:t}},q=null,ln=()=>{if(q===null)q=kn();return q},u=()=>{if(Q())return;let n=ln();if(n.vid){xn(Z,n.vid,730);let t=n.vid;return n.vid=void 0,t}let o=Ln(Z);if(!o)o=h(),xn(Z,o,730);return o},x=()=>{if(Q())return;let n=ln();if(n.sid){let r=n.sid;return sessionStorage.setItem(g,r),sessionStorage.setItem(j,Date.now().toString()),n.sid=void 0,r}let o=Date.now(),t=parseInt(sessionStorage.getItem(j)||"0",10),c=sessionStorage.getItem(g);if(!c||o-t>vn)c=h(),sessionStorage.setItem(g,c);return sessionStorage.setItem(j,o.toString()),c},sn=()=>{if(Q())return;sessionStorage.setItem(j,Date.now().toString())},z=()=>{let n=u(),o=x();return{...n&&{_fs_vid:n},...o&&{_fs_sid:o}}},B=(n)=>{let o=z(),t=new URL(n);if(o._fs_vid)t.searchParams.set(N,o._fs_vid);if(o._fs_sid)t.searchParams.set(v,o._fs_sid);return t.toString()},X=()=>{Pn(Z),sessionStorage.removeItem(g),sessionStorage.removeItem(j),q=null};var In=5000,P=0,G=0,H=null,Cn=()=>{let n=document.documentElement,o=window.scrollY||n.scrollTop,t=n.scrollHeight-n.clientHeight;if(t<=0)return 100;return Math.min(100,Math.round(o/t*100))},L=()=>{P++},en=()=>{let n=Cn();G=Math.max(G,n);let o=u(),t=x();s("heartbeat",{...o&&{visitorUid:o},...t&&{sessionUid:t},path:location.pathname,scrollDepth:G,isVisible:document.visibilityState==="visible",interactionCount:P}),sn()},pn=()=>{P=0,G=0},wn=()=>{document.addEventListener("click",L,{passive:!0}),document.addEventListener("scroll",L,{passive:!0}),document.addEventListener("keydown",L,{passive:!0}),H=setInterval(en,In),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")en()})},M=()=>{if(H)clearInterval(H),H=null};var bn="",yn=!1,y=()=>{let n=K(),o=n?location.href:location.pathname+location.search;if(o===bn)return;bn=o,pn();let t=fn(),c=u(),r=x(),f=n?location.pathname+location.hash:location.pathname;if(s("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}),!yn){yn=!0;let e=J();if(e){let l=JSON.stringify({type:"geo",websiteId:m(),visitorUid:c||void 0,sessionUid:r||void 0});try{fetch(`${e}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:l,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},mn=()=>{y();let{pushState:n,replaceState:o}=history;if(history.pushState=function(...t){n.apply(this,t),y()},history.replaceState=function(...t){o.apply(this,t),y()},window.addEventListener("popstate",()=>y()),K())window.addEventListener("hashchange",()=>y())};var Bn=()=>{document.addEventListener("click",(n)=>{let o=n.target.closest("a");if(!o)return;let t=o.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=u(),f=x();if(!r||!f)return;s("exit_click",{visitorUid:r,sessionUid:f,hostname:location.hostname,url:t})}catch{}})};var Dn=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,jn=()=>{document.addEventListener("click",(n)=>{let o=n.target.closest("a");if(!o)return;let t=o.href;if(!t||!Dn.test(t))return;let c=u(),r=x();s("goal",{...c&&{visitorUid:c},...r&&{sessionUid:r},name:"file_download",metadata:{url:t}})})};var w=(n,o)=>{let t=u(),c=x();s("goal",{...t&&{visitorUid:t},...c&&{sessionUid:c},name:n,metadata:o})};var k="data-fs-goal",zn="data-fs-goal-",An=(n)=>{let o={},t=0;for(let c of Array.from(n.attributes))if(c.name.startsWith(zn)&&c.name!==k){let r=c.name.slice(zn.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)o[r]=f,t++}return t>0?o:void 0},Fn=()=>{document.addEventListener("click",(n)=>{let o=n.target.closest(`[${k}]`);if(!o)return;let t=o.getAttribute(k);if(!t)return;let c=An(o);w(t,c)})};var V="data-fs-scroll",Jn="data-fs-scroll-threshold",I="data-fs-scroll-delay",Wn="data-fs-scroll-",En=new Set([V,Jn,I]),$n=(n)=>{let o={},t=0;for(let c of Array.from(n.attributes))if(c.name.startsWith(Wn)&&!En.has(c.name)){let r=c.name.slice(Wn.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)o[r]=f,t++}return t>0?o:void 0},Qn=()=>{let n=document.querySelectorAll(`[${V}]`);if(!n.length)return;let o=new Set,t=new IntersectionObserver((c)=>{for(let r of c){let f=r.target;if(!r.isIntersecting||o.has(f))continue;let e=f.getAttribute(V);if(!e)continue;let l=parseInt(f.getAttribute(I)||"0",10)||0,i=()=>{if(o.has(f))return;o.add(f),t.unobserve(f);let $=$n(f);w(e,$)};if(l>0)setTimeout(i,l);else i()}},{threshold:0});for(let c of Array.from(n)){let r=parseFloat(c.getAttribute(Jn)||"0.5");if(r!==0.5){let f=new IntersectionObserver((e)=>{for(let l of e){let i=l.target;if(!l.isIntersecting||o.has(i))continue;let $=i.getAttribute(V);if(!$)continue;let A=parseInt(i.getAttribute(I)||"0",10)||0,E=()=>{if(o.has(i))return;o.add(i),f.unobserve(i);let Xn=$n(i);w($,Xn)};if(A>0)setTimeout(E,A);else E()}},{threshold:r});f.observe(c)}else t.observe(c)}};var C=null,Zn=()=>{if(!C)C=new Set(cn());return C},Rn=(n)=>{let o=Zn();if(!o.size)return!1;for(let t of o)if(n===t||n.endsWith(`.${t}`))return!0;return!1},gn=()=>{if(!Zn().size)return;document.addEventListener("click",(o)=>{let t=o.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(!Rn(r.hostname))return;t.href=B(c)}catch{}})};var F=(n)=>{let o=u(),t=x();s("payment",{...o&&{visitorUid:o},...t&&{sessionUid:t},...n.amount!=null&&{amount:n.amount},...n.currency&&{currency:n.currency},...n.transactionId&&{transactionId:n.transactionId},...n.email&&{email:n.email},...n.name&&{name:n.name},...n.customerId&&{customerId:n.customerId},...n.isRenewal!=null&&{isRenewal:n.isRenewal},...n.isRefund!=null&&{isRefund:n.isRefund}})};var W=(n)=>{let o=u();s("identify",{...o&&{visitorUid:o},userId:n.userId,name:n.name,email:n.email,image:n.image,profileData:n.profileData})};var qn=(n)=>{let[o,...t]=n;switch(o){case"identify":W(t[0]);break;case"payment":F(t[0]);break;default:w(o,t[0]);break}},D=()=>{if(d())return;if(!m())return;if(rn())return;if(_()&&!S())return;if(a()&&!nn())return;if(on()&&!tn())return;mn(),wn(),Bn(),jn(),Fn(),Qn(),gn();let n=window,o=n.flowsery?.q||[];for(let t of o)qn(t);n.flowsery=function(...t){qn(t)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",D);else D();var dn=async(n)=>{let o=window;return o.__flowsery_config=n,D(),{trackEvent:w,trackPayment:F,trackPageview:y,identify:W,stop:M,reset:X,getTrackingParams:z,buildCrossDomainUrl:B,getVisitorId:u,getSessionId:x}};})();
|
|
1
|
+
(()=>{var{defineProperty:T,getOwnPropertyNames:Pz,getOwnPropertyDescriptor:Cz}=Object,Tz=Object.prototype.hasOwnProperty;function Ez(z){return this[z]}var hz=(z)=>{var $=(o??=new WeakMap).get(z),j;if($)return $;if($=T({},"__esModule",{value:!0}),z&&typeof z==="object"||typeof z==="function"){for(var J of Pz(z))if(!Tz.call($,J))T($,J,{get:Ez.bind(z,J),enumerable:!(j=Cz(z,J))||j.enumerable})}return o.set(z,$),$},o;var Az=(z)=>z;function _z(z,$){this[z]=Az.bind(null,$)}var pz=(z,$)=>{for(var j in $)T(z,j,{get:$[j],enumerable:!0,configurable:!0,set:_z.bind($,j)})};var j3={};pz(j3,{trackPayment:()=>N,trackPageview:()=>M,trackEvent:()=>V,stopHeartbeat:()=>P,reset:()=>R,initFlowsery:()=>$3,identify:()=>w,getVisitorId:()=>q,getTrackingParams:()=>y,getSessionId:()=>x,buildCrossDomainUrl:()=>U});var E=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(z)=>{let $=Math.random()*16|0;return(z==="x"?$:$&3|8).toString(16)})},s=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0};var X=()=>{return window.__flowsery_config||null},F=()=>{return document.querySelector("script[data-fl-website-id]")},Y=()=>{let z=X();if(z)return z.websiteId;return F()?.getAttribute("data-fl-website-id")||""},r=()=>{return X()?.apiUrl??null},i=()=>{let z=X();if(z?.apiBase)return z.apiBase;let $=F(),j=$?.getAttribute("data-api");if(j)return j;let J=$?.src??"",Q=J.replace(/\/js\/(?:script|main|recording)(?:\.hash)?\.js.*/,"");return Q===J?"":Q},D=()=>{return"https://analytics.flowsery.com/analytics"},h=()=>{let z=X();if(z?.domain)return z.domain;return F()?.getAttribute("data-domain")||location.hostname},v=()=>{let z=X();if(z)return!!z.cookieless;return F()?.hasAttribute("data-cookieless")??!1},mz=new Set(["localhost","127.0.0.1","[::1]"]),t=()=>{return mz.has(location.hostname)||location.hostname.endsWith(".local")},a=()=>{let z=X();if(z)return!!z.local;return F()?.hasAttribute("data-local")??!1},e=()=>{return location.protocol==="file:"},zz=()=>{let z=X();if(z)return!!z.allowFileProtocol;return F()?.hasAttribute("data-allow-file-protocol")??!1},$z=()=>{try{return window.self!==window.top}catch{return!0}},jz=()=>{let z=X();if(z)return!!z.allowIframe;return F()?.hasAttribute("data-allow-iframe")??!1};var L=()=>{let z=X();if(z)return!!z.hashMode;return F()?.src?.includes(".hash.js")??!1},Jz=()=>{let z=X();if(z)return!!z.recording;return F()?.hasAttribute("data-recording")??!1},Qz=()=>{let z=`recording${L()?".hash":""}.js`,$=F()?.src;if($)return $.replace(/(?:script|main)(?:\.hash)?\.js(?:\?.*)?$/,z);return`https://cdn.flowsery.com/${z}`},Zz=()=>{let z=X();if(z?.allowedHostnames)return z.allowedHostnames;let j=F()?.getAttribute("data-allowed-hostnames");return j?j.split(",").map((J)=>J.trim()).filter(Boolean):[]},qz=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},xz=()=>{let z=new URLSearchParams(window.location.search),$={};for(let j of["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref","source","via"]){let J=z.get(j);if(J)$[j]=J}return $};var Wz=r(),Sz=61440,Bz=(z,$)=>{try{let j=new XMLHttpRequest;j.open("POST",z,!0),j.setRequestHeader("Content-Type","application/json"),j.send($)}catch(j){}},W=(z,$)=>{let j=i(),J=!!j,Q=Wz??(J?`${j}/api/track`:`${D()}/events`),Z=Y(),B=JSON.stringify({...$,websiteId:Z,type:z});if(Wz||!J){Bz(Q,B);return}if(B.length>Sz){Bz(Q,B);return}if(typeof navigator.sendBeacon==="function"){let K=new Blob([B],{type:"application/json"});if(navigator.sendBeacon(Q,K))return}fetch(Q,{method:"POST",headers:{"Content-Type":"application/json"},body:B,keepalive:!0}).catch(()=>{})};var b="_fs_vid",k="_fs_sid",H="_fs_sts",cz=1800000,A="_fs_vid",_="_fs_sid",dz=(z)=>{let $=document.cookie.match(new RegExp(`(?:^|; )${z}=([^;]*)`));return $?decodeURIComponent($[1]):null},Xz=(z,$,j)=>{let J=new Date(Date.now()+j*86400000).toUTCString(),Q=h(),Z=Q?`;domain=.${Q}`:"";document.cookie=`${z}=${encodeURIComponent($)};expires=${J};path=/${Z};SameSite=Lax;Secure`},nz=(z)=>{let $=h(),j=$?`;domain=.${$}`:"";document.cookie=`${z}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${j};SameSite=Lax;Secure`},gz=()=>{let z=new URLSearchParams(window.location.search),$=z.get(A)||void 0,j=z.get(_)||void 0;if($||j){z.delete(A),z.delete(_);let J=z.toString(),Q=window.location.pathname+(J?`?${J}`:"")+window.location.hash;history.replaceState(null,"",Q)}return{vid:$,sid:j}},f=null,Fz=()=>{if(f===null)f=gz();return f},q=()=>{if(v())return;let z=Fz();if(z.vid){Xz(b,z.vid,730);let j=z.vid;return z.vid=void 0,j}let $=dz(b);if(!$)$=E(),Xz(b,$,730);return $},x=()=>{if(v())return;let z=Fz();if(z.sid){let Q=z.sid;return sessionStorage.setItem(k,Q),sessionStorage.setItem(H,Date.now().toString()),z.sid=void 0,Q}let $=Date.now(),j=parseInt(sessionStorage.getItem(H)||"0",10),J=sessionStorage.getItem(k);if(!J||$-j>cz)J=E(),sessionStorage.setItem(k,J);return sessionStorage.setItem(H,$.toString()),J},Gz=()=>{if(v())return;sessionStorage.setItem(H,Date.now().toString())},y=()=>{let z=q(),$=x();return{...z&&{_fs_vid:z},...$&&{_fs_sid:$}}},U=(z)=>{let $=y(),j=new URL(z);if($._fs_vid)j.searchParams.set(A,$._fs_vid);if($._fs_sid)j.searchParams.set(_,$._fs_sid);return j.toString()},R=()=>{nz(b),sessionStorage.removeItem(k),sessionStorage.removeItem(H),f=null};var lz=5000,m=0,I=0,O=null,oz=()=>{let z=document.documentElement,$=window.scrollY||z.scrollTop,j=z.scrollHeight-z.clientHeight;if(j<=0)return 100;return Math.min(100,Math.round($/j*100))},p=()=>{m++},Vz=()=>{let z=oz();I=Math.max(I,z);let $=q(),j=x();W("heartbeat",{...$&&{visitorUid:$},...j&&{sessionUid:j},path:location.pathname,scrollDepth:I,isVisible:document.visibilityState==="visible",interactionCount:m}),Gz()},Kz=()=>{m=0,I=0},Mz=()=>{document.addEventListener("click",p,{passive:!0}),document.addEventListener("scroll",p,{passive:!0}),document.addEventListener("keydown",p,{passive:!0}),O=setInterval(Vz,lz),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")Vz()})},P=()=>{if(O)clearInterval(O),O=null};var Yz="",Uz=!1,M=()=>{let z=L(),$=z?location.href:location.pathname+location.search;if($===Yz)return;Yz=$,Kz();let j=xz(),J=q(),Q=x(),Z=z?location.pathname+location.hash:location.pathname;if(W("pageview",{...J&&{visitorUid:J},...Q&&{sessionUid:Q},hostname:location.hostname,path:Z,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:j.utm_source,utmMedium:j.utm_medium,utmCampaign:j.utm_campaign,utmTerm:j.utm_term,utmContent:j.utm_content,ref:j.ref,source:j.source,via:j.via}),!Uz){Uz=!0;let B=D();if(B){let K=JSON.stringify({type:"geo",websiteId:Y(),visitorUid:J||void 0,sessionUid:Q||void 0});try{fetch(`${B}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:K,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},Hz=()=>{M();let{pushState:z,replaceState:$}=history;if(history.pushState=function(...j){z.apply(this,j),M()},history.replaceState=function(...j){$.apply(this,j),M()},window.addEventListener("popstate",()=>M()),L())window.addEventListener("hashchange",()=>M())};var yz=()=>{document.addEventListener("click",(z)=>{let $=z.target.closest("a");if(!$)return;let j=$.href;if(!j)return;try{let J=new URL(j);if(J.protocol!=="http:"&&J.protocol!=="https:")return;if(J.hostname===location.hostname)return;let Q=q(),Z=x();if(!Q||!Z)return;W("exit_click",{visitorUid:Q,sessionUid:Z,hostname:location.hostname,url:j})}catch{}})};var sz=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,Nz=()=>{document.addEventListener("click",(z)=>{let $=z.target.closest("a");if(!$)return;let j=$.href;if(!j||!sz.test(j))return;let J=q(),Q=x();W("goal",{...J&&{visitorUid:J},...Q&&{sessionUid:Q},name:"file_download",metadata:{url:j}})})};var V=(z,$)=>{let j=q(),J=x();W("goal",{...j&&{visitorUid:j},...J&&{sessionUid:J},name:z,metadata:$})};var S="data-fs-goal",wz="data-fs-goal-",rz=(z)=>{let $={},j=0;for(let J of Array.from(z.attributes))if(J.name.startsWith(wz)&&J.name!==S){let Q=J.name.slice(wz.length).replace(/-/g,"_"),Z=(J.value||"").slice(0,255);if(Q&&j<10)$[Q]=Z,j++}return j>0?$:void 0},uz=()=>{document.addEventListener("click",(z)=>{let $=z.target.closest(`[${S}]`);if(!$)return;let j=$.getAttribute(S);if(!j)return;let J=rz($);V(j,J)})};var C="data-fs-scroll",Lz="data-fs-scroll-threshold",c="data-fs-scroll-delay",Dz="data-fs-scroll-",iz=new Set([C,Lz,c]),vz=(z)=>{let $={},j=0;for(let J of Array.from(z.attributes))if(J.name.startsWith(Dz)&&!iz.has(J.name)){let Q=J.name.slice(Dz.length).replace(/-/g,"_"),Z=(J.value||"").slice(0,255);if(Q&&j<10)$[Q]=Z,j++}return j>0?$:void 0},bz=()=>{let z=document.querySelectorAll(`[${C}]`);if(!z.length)return;let $=new Set,j=new IntersectionObserver((J)=>{for(let Q of J){let Z=Q.target;if(!Q.isIntersecting||$.has(Z))continue;let B=Z.getAttribute(C);if(!B)continue;let K=parseInt(Z.getAttribute(c)||"0",10)||0,G=()=>{if($.has(Z))return;$.add(Z),j.unobserve(Z);let u=vz(Z);V(B,u)};if(K>0)setTimeout(G,K);else G()}},{threshold:0});for(let J of Array.from(z)){let Q=parseFloat(J.getAttribute(Lz)||"0.5");if(Q!==0.5){let Z=new IntersectionObserver((B)=>{for(let K of B){let G=K.target;if(!K.isIntersecting||$.has(G))continue;let u=G.getAttribute(C);if(!u)continue;let g=parseInt(G.getAttribute(c)||"0",10)||0,l=()=>{if($.has(G))return;$.add(G),Z.unobserve(G);let Oz=vz(G);V(u,Oz)};if(g>0)setTimeout(l,g);else l()}},{threshold:Q});Z.observe(J)}else j.observe(J)}};var d=null,kz=()=>{if(!d)d=new Set(Zz());return d},tz=(z)=>{let $=kz();if(!$.size)return!1;for(let j of $)if(z===j||z.endsWith(`.${j}`))return!0;return!1},fz=()=>{if(!kz().size)return;document.addEventListener("click",($)=>{let j=$.target.closest("a");if(!j)return;let J=j.href;if(!J)return;try{let Q=new URL(J);if(Q.hostname===location.hostname)return;if(!tz(Q.hostname))return;j.href=U(J)}catch{}})};var az="buy.stripe.com",ez=(z,$)=>{try{let j=new URL(z);if(j.hostname!==az)return z;if(j.searchParams.has("client_reference_id"))return z;return j.searchParams.set("client_reference_id",$),j.toString()}catch{return z}},Rz=()=>{document.addEventListener("click",(z)=>{let $=z.target.closest("a");if(!$||!$.href)return;let j=q();if(!j)return;$.href=ez($.href,j)})};var N=(z)=>{let $=q(),j=x();W("payment",{...$&&{visitorUid:$},...j&&{sessionUid:j},...z.amount!=null&&{amount:z.amount},...z.currency&&{currency:z.currency},...z.transactionId&&{transactionId:z.transactionId},...z.email&&{email:z.email},...z.name&&{name:z.name},...z.customerId&&{customerId:z.customerId},...z.isRenewal!=null&&{isRenewal:z.isRenewal},...z.isRefund!=null&&{isRefund:z.isRefund}})};var w=(z)=>{let $=q();W("identify",{...$&&{visitorUid:$},userId:z.userId,name:z.name,email:z.email,image:z.image,profileData:z.profileData})};var z3=()=>{if(typeof document>"u")return;if(document.querySelector("script[data-fl-recording]"))return;let z=document.createElement("script");z.src=Qz(),z.defer=!0,z.setAttribute("data-fl-recording",""),(document.head||document.documentElement).appendChild(z)},Iz=(z)=>{let[$,...j]=z;switch($){case"identify":w(j[0]);break;case"payment":N(j[0]);break;default:V($,j[0]);break}},n=()=>{if(s())return;if(!Y())return;if(qz())return;if(t()&&!a())return;if(e()&&!zz())return;if($z()&&!jz())return;if(Hz(),Mz(),yz(),Nz(),uz(),bz(),fz(),Rz(),Jz())z3();let z=window,$=z.flowsery?.q||[];for(let j of $)Iz(j);z.flowsery=function(...j){Iz(j)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",n);else n();var $3=async(z)=>{let $=window;return $.__flowsery_config=z,n(),{trackEvent:V,trackPayment:N,trackPageview:M,identify:w,stop:P,reset:R,getTrackingParams:y,buildCrossDomainUrl:U,getVisitorId:q,getSessionId:x}};})();
|