flowsery 1.0.6 → 1.1.1
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 +85 -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,84 @@ 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
|
+
|
|
113
|
+
### Sampling
|
|
114
|
+
|
|
115
|
+
On high-traffic sites you rarely need to record every visit. Two independent
|
|
116
|
+
rates control this, both set here on the client (`0`–`100`, default `100` —
|
|
117
|
+
record and analyze everything):
|
|
118
|
+
|
|
119
|
+
- **`recordingSampleRate`** (`data-recording-sample`) — the share of sessions
|
|
120
|
+
that get recorded. The browser decides, so unsampled sessions never download
|
|
121
|
+
the recording bundle. The decision is deterministic per session, so a visitor
|
|
122
|
+
is recorded (or not) consistently across reloads and page navigations.
|
|
123
|
+
- **`aiSampleRate`** (`data-ai-sample`) — the share of _recorded_ sessions sent
|
|
124
|
+
to AI session analysis. Sent to Flowsery in the recording handshake and applied
|
|
125
|
+
server-side, since AI analysis runs after the page has closed.
|
|
126
|
+
|
|
127
|
+
The two multiply: a recording rate of `30` and an AI rate of `50` records ~30% of
|
|
128
|
+
sessions and AI-analyzes ~15% (30% × 50%) of them — the rest stay fully
|
|
129
|
+
replayable, just not AI-analyzed.
|
|
130
|
+
|
|
131
|
+
Via npm:
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
const flowsery = await initFlowsery({
|
|
135
|
+
websiteId: 'flid_******',
|
|
136
|
+
recording: true,
|
|
137
|
+
recordingSampleRate: 30,
|
|
138
|
+
aiSampleRate: 50,
|
|
139
|
+
});
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Via script tag:
|
|
143
|
+
|
|
144
|
+
```html
|
|
145
|
+
<script
|
|
146
|
+
defer
|
|
147
|
+
data-fl-website-id="flid_******"
|
|
148
|
+
data-recording
|
|
149
|
+
data-recording-sample="30"
|
|
150
|
+
data-ai-sample="50"
|
|
151
|
+
src="https://cdn.flowsery.com/main.js"
|
|
152
|
+
></script>
|
|
153
|
+
```
|
|
154
|
+
|
|
77
155
|
## Script Tag
|
|
78
156
|
|
|
79
157
|
If you prefer not to use npm, you can install Flowsery with a script tag.
|
|
@@ -91,11 +169,12 @@ If you prefer not to use npm, you can install Flowsery with a script tag.
|
|
|
91
169
|
<script
|
|
92
170
|
defer
|
|
93
171
|
data-fl-website-id="flid_******"
|
|
94
|
-
data-domain="example.com"
|
|
95
172
|
src="https://cdn.flowsery.com/main.js"
|
|
96
173
|
></script>
|
|
97
174
|
```
|
|
98
175
|
|
|
176
|
+
`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.
|
|
177
|
+
|
|
99
178
|
### Proxy install
|
|
100
179
|
|
|
101
180
|
```html
|
|
@@ -109,18 +188,6 @@ If you prefer not to use npm, you can install Flowsery with a script tag.
|
|
|
109
188
|
<script
|
|
110
189
|
defer
|
|
111
190
|
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
191
|
src="https://example.com/js/main.js"
|
|
125
192
|
></script>
|
|
126
193
|
```
|
|
@@ -164,6 +231,9 @@ type FlowseryConfig = {
|
|
|
164
231
|
disableConsole?: boolean;
|
|
165
232
|
allowedHostnames?: string[];
|
|
166
233
|
hashMode?: boolean;
|
|
234
|
+
recording?: boolean;
|
|
235
|
+
recordingSampleRate?: number;
|
|
236
|
+
aiSampleRate?: number;
|
|
167
237
|
};
|
|
168
238
|
```
|
|
169
239
|
|
|
@@ -180,6 +250,8 @@ Build output:
|
|
|
180
250
|
- `dist/main.hash.js`
|
|
181
251
|
- `dist/script.js`
|
|
182
252
|
- `dist/script.hash.js`
|
|
253
|
+
- `dist/recording.js`
|
|
254
|
+
- `dist/recording.hash.js`
|
|
183
255
|
- `dist/index.mjs`
|
|
184
256
|
- `dist/index.cjs`
|
|
185
257
|
|
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 f=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(z)=>{let $=Math.random()*16|0;return(z==="x"?$:$&3|8).toString(16)})},o=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0};var x=()=>{return window.__flowsery_config||null},X=()=>{return document.querySelector("script[data-fl-website-id]")},M=()=>{let z=x();if(z)return z.websiteId;return X()?.getAttribute("data-fl-website-id")||""},s=()=>{return x()?.apiUrl??null},i=()=>{let z=x();if(z?.apiBase)return z.apiBase;let $=X(),j=$?.getAttribute("data-api");if(j)return j;let J=$?.src??"",Q=J.replace(/\/js\/(?:script|main|recording)(?:\.hash)?\.js.*/,"");return Q===J?"":Q},w=()=>{return"https://analytics.flowsery.com/analytics"},T=()=>{let z=x();if(z?.domain)return z.domain;return X()?.getAttribute("data-domain")||location.hostname},D=()=>{let z=x();if(z)return!!z.cookieless;return X()?.hasAttribute("data-cookieless")??!1},Ez=new Set(["localhost","127.0.0.1","[::1]"]),r=()=>{return Ez.has(location.hostname)||location.hostname.endsWith(".local")},t=()=>{let z=x();if(z)return!!z.local;return X()?.hasAttribute("data-local")??!1},a=()=>{return location.protocol==="file:"},e=()=>{let z=x();if(z)return!!z.allowFileProtocol;return X()?.hasAttribute("data-allow-file-protocol")??!1},zz=()=>{try{return window.self!==window.top}catch{return!0}},$z=()=>{let z=x();if(z)return!!z.allowIframe;return X()?.hasAttribute("data-allow-iframe")??!1};var v=()=>{let z=x();if(z)return!!z.hashMode;return X()?.src?.includes(".hash.js")??!1},jz=()=>{let z=x();if(z)return!!z.recording;return X()?.hasAttribute("data-recording")??!1},hz=(z)=>{let $=2166136261;for(let j=0;j<z.length;j++)$^=z.charCodeAt(j),$=Math.imul($,16777619);return($>>>0)%100},Jz=(z,$)=>{if(!Number.isFinite($)||$>=100)return!0;if($<=0)return!1;return hz(z)<$},l=(z)=>z==null||!Number.isFinite(z)?100:Math.max(0,Math.min(100,Math.floor(z))),Az=(z,$)=>{if(typeof z==="number")return l(z);let j=X()?.getAttribute($);return l(j!=null&&j!==""?Number(j):null)},Qz=()=>Az(x()?.recordingSampleRate,"data-recording-sample");var Zz=()=>{let z=`recording${v()?".hash":""}.js`,$=X()?.src;if($)return $.replace(/(?:script|main)(?:\.hash)?\.js(?:\?.*)?$/,z);return`https://cdn.flowsery.com/${z}`},qz=()=>{let z=x();if(z?.allowedHostnames)return z.allowedHostnames;let j=X()?.getAttribute("data-allowed-hostnames");return j?j.split(",").map((J)=>J.trim()).filter(Boolean):[]},Wz=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},Fz=()=>{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 Bz=s(),_z=61440,xz=3,mz=1000,Xz=(z,$,j)=>{try{let J=new XMLHttpRequest;if(J.open("POST",z,!0),J.setRequestHeader("Content-Type","application/json"),j>0){let Q=()=>{let Z=xz-j;setTimeout(()=>Xz(z,$,j-1),mz*Math.pow(2,Z))};J.onreadystatechange=()=>{if(J.readyState!==4)return;if(J.status===0||J.status>=500)Q()},J.onerror=Q}J.send($)}catch(J){}},Gz=(z,$,j=!1)=>{Xz(z,$,j?xz:0)},pz=(z,$)=>Bz??(z?`${$}/api/track`:`${w()}/events`),F=(z,$,j)=>{let J=i(),Q=!!J,Z=pz(Q,J),K=M(),G=JSON.stringify({...$,websiteId:K,type:z}),B=j?.retry??!1;if(Bz||!Q){Gz(Z,G,B);return}if(G.length>_z){Gz(Z,G,B);return}if(typeof navigator.sendBeacon==="function"){let U=new Blob([G],{type:"application/json"});if(navigator.sendBeacon(Z,U))return}fetch(Z,{method:"POST",headers:{"Content-Type":"application/json"},body:G,keepalive:!0}).catch(()=>{})};var y="_fs_vid",L="_fs_sid",H="_fs_sts",Sz=1800000,R="_fs_vid",E="_fs_sid",cz=(z)=>{let $=document.cookie.match(new RegExp(`(?:^|; )${z}=([^;]*)`));return $?decodeURIComponent($[1]):null},Kz=(z,$,j)=>{let J=new Date(Date.now()+j*86400000).toUTCString(),Q=T(),Z=Q?`;domain=.${Q}`:"";document.cookie=`${z}=${encodeURIComponent($)};expires=${J};path=/${Z};SameSite=Lax;Secure`},nz=(z)=>{let $=T(),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(R)||void 0,j=z.get(E)||void 0;if($||j){z.delete(R),z.delete(E);let J=z.toString(),Q=window.location.pathname+(J?`?${J}`:"")+window.location.hash;history.replaceState(null,"",Q)}return{vid:$,sid:j}},b=null,Vz=()=>{if(b===null)b=gz();return b},q=()=>{if(D())return;let z=Vz();if(z.vid){Kz(y,z.vid,730);let j=z.vid;return z.vid=void 0,j}let $=cz(y);if(!$)$=f(),Kz(y,$,730);return $},W=()=>{if(D())return;let z=Vz();if(z.sid){let Q=z.sid;return sessionStorage.setItem(L,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(L);if(!J||$-j>Sz)J=f(),sessionStorage.setItem(L,J);return sessionStorage.setItem(H,$.toString()),J},Yz=()=>{if(D())return;sessionStorage.setItem(H,Date.now().toString())},k=()=>{let z=q(),$=W();return{...z&&{_fs_vid:z},...$&&{_fs_sid:$}}},N=(z)=>{let $=k(),j=new URL(z);if($._fs_vid)j.searchParams.set(R,$._fs_vid);if($._fs_sid)j.searchParams.set(E,$._fs_sid);return j.toString()},h=()=>{nz(y),sessionStorage.removeItem(L),sessionStorage.removeItem(H),b=null};var dz=5000,_=0,u=0,O=null,lz=()=>{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=()=>{_++},Uz=()=>{let z=lz();u=Math.max(u,z);let $=q(),j=W();F("heartbeat",{...$&&{visitorUid:$},...j&&{sessionUid:j},path:location.pathname,scrollDepth:u,isVisible:document.visibilityState==="visible",interactionCount:_}),Yz()},Mz=()=>{_=0,u=0},Hz=()=>{document.addEventListener("click",A,{passive:!0}),document.addEventListener("scroll",A,{passive:!0}),document.addEventListener("keydown",A,{passive:!0}),O=setInterval(Uz,dz),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")Uz()})},m=()=>{if(O)clearInterval(O),O=null};var Nz="",wz=!1,Y=()=>{let z=v(),$=z?location.href:location.pathname+location.search;if($===Nz)return;Nz=$,Mz();let j=Fz(),J=q(),Q=W(),Z=z?location.pathname+location.hash:location.pathname;if(F("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}),!wz){wz=!0;let K=w();if(K){let G=JSON.stringify({type:"geo",websiteId:M(),visitorUid:J||void 0,sessionUid:Q||void 0});try{fetch(`${K}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:G,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},Dz=()=>{Y();let{pushState:z,replaceState:$}=history;if(history.pushState=function(...j){z.apply(this,j),Y()},history.replaceState=function(...j){$.apply(this,j),Y()},window.addEventListener("popstate",()=>Y()),v())window.addEventListener("hashchange",()=>Y())};var vz=()=>{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=W();if(!Q||!Z)return;F("exit_click",{visitorUid:Q,sessionUid:Z,hostname:location.hostname,url:j})}catch{}})};var oz=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,yz=()=>{document.addEventListener("click",(z)=>{let $=z.target.closest("a");if(!$)return;let j=$.href;if(!j||!oz.test(j))return;let J=q(),Q=W();F("goal",{...J&&{visitorUid:J},...Q&&{sessionUid:Q},name:"file_download",metadata:{url:j}})})};var V=(z,$)=>{let j=q(),J=W();F("goal",{...j&&{visitorUid:j},...J&&{sessionUid:J},name:z,metadata:$})};var p="data-fs-goal",Lz="data-fs-goal-",sz=(z)=>{let $={},j=0;for(let J of Array.from(z.attributes))if(J.name.startsWith(Lz)&&J.name!==p){let Q=J.name.slice(Lz.length).replace(/-/g,"_"),Z=(J.value||"").slice(0,255);if(Q&&j<10)$[Q]=Z,j++}return j>0?$:void 0},bz=()=>{document.addEventListener("click",(z)=>{let $=z.target.closest(`[${p}]`);if(!$)return;let j=$.getAttribute(p);if(!j)return;let J=sz($);V(j,J)})};var C="data-fs-scroll",Oz="data-fs-scroll-threshold",S="data-fs-scroll-delay",kz="data-fs-scroll-",iz=new Set([C,Oz,S]),uz=(z)=>{let $={},j=0;for(let J of Array.from(z.attributes))if(J.name.startsWith(kz)&&!iz.has(J.name)){let Q=J.name.slice(kz.length).replace(/-/g,"_"),Z=(J.value||"").slice(0,255);if(Q&&j<10)$[Q]=Z,j++}return j>0?$:void 0},Cz=()=>{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 K=Z.getAttribute(C);if(!K)continue;let G=parseInt(Z.getAttribute(S)||"0",10)||0,B=()=>{if($.has(Z))return;$.add(Z),j.unobserve(Z);let U=uz(Z);V(K,U)};if(G>0)setTimeout(B,G);else B()}},{threshold:0});for(let J of Array.from(z)){let Q=parseFloat(J.getAttribute(Oz)||"0.5");if(Q!==0.5){let Z=new IntersectionObserver((K)=>{for(let G of K){let B=G.target;if(!G.isIntersecting||$.has(B))continue;let U=B.getAttribute(C);if(!U)continue;let g=parseInt(B.getAttribute(S)||"0",10)||0,d=()=>{if($.has(B))return;$.add(B),Z.unobserve(B);let Rz=uz(B);V(U,Rz)};if(g>0)setTimeout(d,g);else d()}},{threshold:Q});Z.observe(J)}else j.observe(J)}};var c=null,Pz=()=>{if(!c)c=new Set(qz());return c},rz=(z)=>{let $=Pz();if(!$.size)return!1;for(let j of $)if(z===j||z.endsWith(`.${j}`))return!0;return!1},Iz=()=>{if(!Pz().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(!rz(Q.hostname))return;j.href=N(J)}catch{}})};var tz="buy.stripe.com",az=(z,$)=>{try{let j=new URL(z);if(j.hostname!==tz)return z;if(j.searchParams.has("client_reference_id"))return z;return j.searchParams.set("client_reference_id",$),j.toString()}catch{return z}},fz=()=>{document.addEventListener("click",(z)=>{let $=z.target.closest("a");if(!$||!$.href)return;let j=q();if(!j)return;$.href=az($.href,j)})};var P=(z)=>{let $=q(),j=W();F("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 I=(z)=>{let $=q();F("identify",{...$&&{visitorUid:$},userId:z.userId,name:z.name,email:z.email,image:z.image,profileData:z.profileData})};var ez=()=>{if(typeof document>"u")return;if(document.querySelector("script[data-fl-recording]"))return;let z=document.createElement("script");z.src=Zz(),z.defer=!0,z.setAttribute("data-fl-recording",""),(document.head||document.documentElement).appendChild(z)},Tz=(z)=>{let[$,...j]=z;switch($){case"identify":I(j[0]);break;case"payment":P(j[0]);break;default:V($,j[0]);break}},n=()=>{if(o())return;if(!M())return;if(Wz())return;if(r()&&!t())return;if(a()&&!e())return;if(zz()&&!$z())return;if(Dz(),Hz(),vz(),yz(),bz(),Cz(),Iz(),fz(),jz()){let j=W();if(!j||Jz(j,Qz()))ez()}let z=window,$=z.flowsery?.q||[];for(let j of $)Tz(j);z.flowsery=function(...j){Tz(j)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",n);else n();var r3=async(z)=>{let $=window;return $.__flowsery_config=z,n(),{trackEvent:V,trackPayment:P,trackPageview:Y,identify:I,stop:m,reset:h,getTrackingParams:k,buildCrossDomainUrl:N,getVisitorId:q,getSessionId:W}};export{P as trackPayment,Y as trackPageview,V as trackEvent,m as stopHeartbeat,h as reset,r3 as initFlowsery,I as identify,q as getVisitorId,k as getTrackingParams,W as getSessionId,N 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 f=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(z)=>{let $=Math.random()*16|0;return(z==="x"?$:$&3|8).toString(16)})},o=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0};var x=()=>{return window.__flowsery_config||null},X=()=>{return document.querySelector("script[data-fl-website-id]")},M=()=>{let z=x();if(z)return z.websiteId;return X()?.getAttribute("data-fl-website-id")||""},s=()=>{return x()?.apiUrl??null},i=()=>{let z=x();if(z?.apiBase)return z.apiBase;let $=X(),j=$?.getAttribute("data-api");if(j)return j;let J=$?.src??"",Q=J.replace(/\/js\/(?:script|main|recording)(?:\.hash)?\.js.*/,"");return Q===J?"":Q},w=()=>{return"https://analytics.flowsery.com/analytics"},T=()=>{let z=x();if(z?.domain)return z.domain;return X()?.getAttribute("data-domain")||location.hostname},D=()=>{let z=x();if(z)return!!z.cookieless;return X()?.hasAttribute("data-cookieless")??!1},Ez=new Set(["localhost","127.0.0.1","[::1]"]),r=()=>{return Ez.has(location.hostname)||location.hostname.endsWith(".local")},t=()=>{let z=x();if(z)return!!z.local;return X()?.hasAttribute("data-local")??!1},a=()=>{return location.protocol==="file:"},e=()=>{let z=x();if(z)return!!z.allowFileProtocol;return X()?.hasAttribute("data-allow-file-protocol")??!1},zz=()=>{try{return window.self!==window.top}catch{return!0}},$z=()=>{let z=x();if(z)return!!z.allowIframe;return X()?.hasAttribute("data-allow-iframe")??!1};var v=()=>{let z=x();if(z)return!!z.hashMode;return X()?.src?.includes(".hash.js")??!1},jz=()=>{let z=x();if(z)return!!z.recording;return X()?.hasAttribute("data-recording")??!1},hz=(z)=>{let $=2166136261;for(let j=0;j<z.length;j++)$^=z.charCodeAt(j),$=Math.imul($,16777619);return($>>>0)%100},Jz=(z,$)=>{if(!Number.isFinite($)||$>=100)return!0;if($<=0)return!1;return hz(z)<$},l=(z)=>z==null||!Number.isFinite(z)?100:Math.max(0,Math.min(100,Math.floor(z))),Az=(z,$)=>{if(typeof z==="number")return l(z);let j=X()?.getAttribute($);return l(j!=null&&j!==""?Number(j):null)},Qz=()=>Az(x()?.recordingSampleRate,"data-recording-sample");var Zz=()=>{let z=`recording${v()?".hash":""}.js`,$=X()?.src;if($)return $.replace(/(?:script|main)(?:\.hash)?\.js(?:\?.*)?$/,z);return`https://cdn.flowsery.com/${z}`},qz=()=>{let z=x();if(z?.allowedHostnames)return z.allowedHostnames;let j=X()?.getAttribute("data-allowed-hostnames");return j?j.split(",").map((J)=>J.trim()).filter(Boolean):[]},Wz=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},Fz=()=>{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 Bz=s(),_z=61440,xz=3,mz=1000,Xz=(z,$,j)=>{try{let J=new XMLHttpRequest;if(J.open("POST",z,!0),J.setRequestHeader("Content-Type","application/json"),j>0){let Q=()=>{let Z=xz-j;setTimeout(()=>Xz(z,$,j-1),mz*Math.pow(2,Z))};J.onreadystatechange=()=>{if(J.readyState!==4)return;if(J.status===0||J.status>=500)Q()},J.onerror=Q}J.send($)}catch(J){}},Gz=(z,$,j=!1)=>{Xz(z,$,j?xz:0)},pz=(z,$)=>Bz??(z?`${$}/api/track`:`${w()}/events`),F=(z,$,j)=>{let J=i(),Q=!!J,Z=pz(Q,J),K=M(),G=JSON.stringify({...$,websiteId:K,type:z}),B=j?.retry??!1;if(Bz||!Q){Gz(Z,G,B);return}if(G.length>_z){Gz(Z,G,B);return}if(typeof navigator.sendBeacon==="function"){let U=new Blob([G],{type:"application/json"});if(navigator.sendBeacon(Z,U))return}fetch(Z,{method:"POST",headers:{"Content-Type":"application/json"},body:G,keepalive:!0}).catch(()=>{})};var y="_fs_vid",L="_fs_sid",H="_fs_sts",Sz=1800000,R="_fs_vid",E="_fs_sid",cz=(z)=>{let $=document.cookie.match(new RegExp(`(?:^|; )${z}=([^;]*)`));return $?decodeURIComponent($[1]):null},Kz=(z,$,j)=>{let J=new Date(Date.now()+j*86400000).toUTCString(),Q=T(),Z=Q?`;domain=.${Q}`:"";document.cookie=`${z}=${encodeURIComponent($)};expires=${J};path=/${Z};SameSite=Lax;Secure`},nz=(z)=>{let $=T(),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(R)||void 0,j=z.get(E)||void 0;if($||j){z.delete(R),z.delete(E);let J=z.toString(),Q=window.location.pathname+(J?`?${J}`:"")+window.location.hash;history.replaceState(null,"",Q)}return{vid:$,sid:j}},b=null,Vz=()=>{if(b===null)b=gz();return b},q=()=>{if(D())return;let z=Vz();if(z.vid){Kz(y,z.vid,730);let j=z.vid;return z.vid=void 0,j}let $=cz(y);if(!$)$=f(),Kz(y,$,730);return $},W=()=>{if(D())return;let z=Vz();if(z.sid){let Q=z.sid;return sessionStorage.setItem(L,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(L);if(!J||$-j>Sz)J=f(),sessionStorage.setItem(L,J);return sessionStorage.setItem(H,$.toString()),J},Yz=()=>{if(D())return;sessionStorage.setItem(H,Date.now().toString())},k=()=>{let z=q(),$=W();return{...z&&{_fs_vid:z},...$&&{_fs_sid:$}}},N=(z)=>{let $=k(),j=new URL(z);if($._fs_vid)j.searchParams.set(R,$._fs_vid);if($._fs_sid)j.searchParams.set(E,$._fs_sid);return j.toString()},h=()=>{nz(y),sessionStorage.removeItem(L),sessionStorage.removeItem(H),b=null};var dz=5000,_=0,u=0,O=null,lz=()=>{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=()=>{_++},Uz=()=>{let z=lz();u=Math.max(u,z);let $=q(),j=W();F("heartbeat",{...$&&{visitorUid:$},...j&&{sessionUid:j},path:location.pathname,scrollDepth:u,isVisible:document.visibilityState==="visible",interactionCount:_}),Yz()},Mz=()=>{_=0,u=0},Hz=()=>{document.addEventListener("click",A,{passive:!0}),document.addEventListener("scroll",A,{passive:!0}),document.addEventListener("keydown",A,{passive:!0}),O=setInterval(Uz,dz),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")Uz()})},m=()=>{if(O)clearInterval(O),O=null};var Nz="",wz=!1,Y=()=>{let z=v(),$=z?location.href:location.pathname+location.search;if($===Nz)return;Nz=$,Mz();let j=Fz(),J=q(),Q=W(),Z=z?location.pathname+location.hash:location.pathname;if(F("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}),!wz){wz=!0;let K=w();if(K){let G=JSON.stringify({type:"geo",websiteId:M(),visitorUid:J||void 0,sessionUid:Q||void 0});try{fetch(`${K}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:G,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},Dz=()=>{Y();let{pushState:z,replaceState:$}=history;if(history.pushState=function(...j){z.apply(this,j),Y()},history.replaceState=function(...j){$.apply(this,j),Y()},window.addEventListener("popstate",()=>Y()),v())window.addEventListener("hashchange",()=>Y())};var vz=()=>{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=W();if(!Q||!Z)return;F("exit_click",{visitorUid:Q,sessionUid:Z,hostname:location.hostname,url:j})}catch{}})};var oz=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,yz=()=>{document.addEventListener("click",(z)=>{let $=z.target.closest("a");if(!$)return;let j=$.href;if(!j||!oz.test(j))return;let J=q(),Q=W();F("goal",{...J&&{visitorUid:J},...Q&&{sessionUid:Q},name:"file_download",metadata:{url:j}})})};var V=(z,$)=>{let j=q(),J=W();F("goal",{...j&&{visitorUid:j},...J&&{sessionUid:J},name:z,metadata:$})};var p="data-fs-goal",Lz="data-fs-goal-",sz=(z)=>{let $={},j=0;for(let J of Array.from(z.attributes))if(J.name.startsWith(Lz)&&J.name!==p){let Q=J.name.slice(Lz.length).replace(/-/g,"_"),Z=(J.value||"").slice(0,255);if(Q&&j<10)$[Q]=Z,j++}return j>0?$:void 0},bz=()=>{document.addEventListener("click",(z)=>{let $=z.target.closest(`[${p}]`);if(!$)return;let j=$.getAttribute(p);if(!j)return;let J=sz($);V(j,J)})};var C="data-fs-scroll",Oz="data-fs-scroll-threshold",S="data-fs-scroll-delay",kz="data-fs-scroll-",iz=new Set([C,Oz,S]),uz=(z)=>{let $={},j=0;for(let J of Array.from(z.attributes))if(J.name.startsWith(kz)&&!iz.has(J.name)){let Q=J.name.slice(kz.length).replace(/-/g,"_"),Z=(J.value||"").slice(0,255);if(Q&&j<10)$[Q]=Z,j++}return j>0?$:void 0},Cz=()=>{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 K=Z.getAttribute(C);if(!K)continue;let G=parseInt(Z.getAttribute(S)||"0",10)||0,B=()=>{if($.has(Z))return;$.add(Z),j.unobserve(Z);let U=uz(Z);V(K,U)};if(G>0)setTimeout(B,G);else B()}},{threshold:0});for(let J of Array.from(z)){let Q=parseFloat(J.getAttribute(Oz)||"0.5");if(Q!==0.5){let Z=new IntersectionObserver((K)=>{for(let G of K){let B=G.target;if(!G.isIntersecting||$.has(B))continue;let U=B.getAttribute(C);if(!U)continue;let g=parseInt(B.getAttribute(S)||"0",10)||0,d=()=>{if($.has(B))return;$.add(B),Z.unobserve(B);let Rz=uz(B);V(U,Rz)};if(g>0)setTimeout(d,g);else d()}},{threshold:Q});Z.observe(J)}else j.observe(J)}};var c=null,Pz=()=>{if(!c)c=new Set(qz());return c},rz=(z)=>{let $=Pz();if(!$.size)return!1;for(let j of $)if(z===j||z.endsWith(`.${j}`))return!0;return!1},Iz=()=>{if(!Pz().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(!rz(Q.hostname))return;j.href=N(J)}catch{}})};var tz="buy.stripe.com",az=(z,$)=>{try{let j=new URL(z);if(j.hostname!==tz)return z;if(j.searchParams.has("client_reference_id"))return z;return j.searchParams.set("client_reference_id",$),j.toString()}catch{return z}},fz=()=>{document.addEventListener("click",(z)=>{let $=z.target.closest("a");if(!$||!$.href)return;let j=q();if(!j)return;$.href=az($.href,j)})};var P=(z)=>{let $=q(),j=W();F("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 I=(z)=>{let $=q();F("identify",{...$&&{visitorUid:$},userId:z.userId,name:z.name,email:z.email,image:z.image,profileData:z.profileData})};var ez=()=>{if(typeof document>"u")return;if(document.querySelector("script[data-fl-recording]"))return;let z=document.createElement("script");z.src=Zz(),z.defer=!0,z.setAttribute("data-fl-recording",""),(document.head||document.documentElement).appendChild(z)},Tz=(z)=>{let[$,...j]=z;switch($){case"identify":I(j[0]);break;case"payment":P(j[0]);break;default:V($,j[0]);break}},n=()=>{if(o())return;if(!M())return;if(Wz())return;if(r()&&!t())return;if(a()&&!e())return;if(zz()&&!$z())return;if(Dz(),Hz(),vz(),yz(),bz(),Cz(),Iz(),fz(),jz()){let j=W();if(!j||Jz(j,Qz()))ez()}let z=window,$=z.flowsery?.q||[];for(let j of $)Tz(j);z.flowsery=function(...j){Tz(j)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",n);else n();var r3=async(z)=>{let $=window;return $.__flowsery_config=z,n(),{trackEvent:V,trackPayment:P,trackPageview:Y,identify:I,stop:m,reset:h,getTrackingParams:k,buildCrossDomainUrl:N,getVisitorId:q,getSessionId:W}};export{P as trackPayment,Y as trackPageview,V as trackEvent,m as stopHeartbeat,h as reset,r3 as initFlowsery,I as identify,q as getVisitorId,k as getTrackingParams,W as getSessionId,N 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:R,getOwnPropertyNames:Az,getOwnPropertyDescriptor:_z}=Object,mz=Object.prototype.hasOwnProperty;function pz(z){return this[z]}var Sz=(z)=>{var $=(o??=new WeakMap).get(z),j;if($)return $;if($=R({},"__esModule",{value:!0}),z&&typeof z==="object"||typeof z==="function"){for(var J of Az(z))if(!mz.call($,J))R($,J,{get:pz.bind(z,J),enumerable:!(j=_z(z,J))||j.enumerable})}return o.set(z,$),$},o;var cz=(z)=>z;function nz(z,$){this[z]=cz.bind(null,$)}var gz=(z,$)=>{for(var j in $)R(z,j,{get:$[j],enumerable:!0,configurable:!0,set:nz.bind($,j)})};var x3={};gz(x3,{trackPayment:()=>D,trackPageview:()=>Y,trackEvent:()=>K,stopHeartbeat:()=>f,reset:()=>C,initFlowsery:()=>B3,identify:()=>v,getVisitorId:()=>q,getTrackingParams:()=>w,getSessionId:()=>W,buildCrossDomainUrl:()=>H});var E=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(z)=>{let $=Math.random()*16|0;return(z==="x"?$:$&3|8).toString(16)})},i=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0};var x=()=>{return window.__flowsery_config||null},X=()=>{return document.querySelector("script[data-fl-website-id]")},M=()=>{let z=x();if(z)return z.websiteId;return X()?.getAttribute("data-fl-website-id")||""},r=()=>{return x()?.apiUrl??null},t=()=>{let z=x();if(z?.apiBase)return z.apiBase;let $=X(),j=$?.getAttribute("data-api");if(j)return j;let J=$?.src??"",Q=J.replace(/\/js\/(?:script|main|recording)(?:\.hash)?\.js.*/,"");return Q===J?"":Q},y=()=>{return"https://analytics.flowsery.com/analytics"},h=()=>{let z=x();if(z?.domain)return z.domain;return X()?.getAttribute("data-domain")||location.hostname},L=()=>{let z=x();if(z)return!!z.cookieless;return X()?.hasAttribute("data-cookieless")??!1},dz=new Set(["localhost","127.0.0.1","[::1]"]),a=()=>{return dz.has(location.hostname)||location.hostname.endsWith(".local")},e=()=>{let z=x();if(z)return!!z.local;return X()?.hasAttribute("data-local")??!1},zz=()=>{return location.protocol==="file:"},$z=()=>{let z=x();if(z)return!!z.allowFileProtocol;return X()?.hasAttribute("data-allow-file-protocol")??!1},jz=()=>{try{return window.self!==window.top}catch{return!0}},Jz=()=>{let z=x();if(z)return!!z.allowIframe;return X()?.hasAttribute("data-allow-iframe")??!1};var b=()=>{let z=x();if(z)return!!z.hashMode;return X()?.src?.includes(".hash.js")??!1},Qz=()=>{let z=x();if(z)return!!z.recording;return X()?.hasAttribute("data-recording")??!1},lz=(z)=>{let $=2166136261;for(let j=0;j<z.length;j++)$^=z.charCodeAt(j),$=Math.imul($,16777619);return($>>>0)%100},Zz=(z,$)=>{if(!Number.isFinite($)||$>=100)return!0;if($<=0)return!1;return lz(z)<$},s=(z)=>z==null||!Number.isFinite(z)?100:Math.max(0,Math.min(100,Math.floor(z))),oz=(z,$)=>{if(typeof z==="number")return s(z);let j=X()?.getAttribute($);return s(j!=null&&j!==""?Number(j):null)},qz=()=>oz(x()?.recordingSampleRate,"data-recording-sample");var Wz=()=>{let z=`recording${b()?".hash":""}.js`,$=X()?.src;if($)return $.replace(/(?:script|main)(?:\.hash)?\.js(?:\?.*)?$/,z);return`https://cdn.flowsery.com/${z}`},Fz=()=>{let z=x();if(z?.allowedHostnames)return z.allowedHostnames;let j=X()?.getAttribute("data-allowed-hostnames");return j?j.split(",").map((J)=>J.trim()).filter(Boolean):[]},Gz=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},Bz=()=>{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 Xz=r(),sz=61440,Kz=3,iz=1000,Vz=(z,$,j)=>{try{let J=new XMLHttpRequest;if(J.open("POST",z,!0),J.setRequestHeader("Content-Type","application/json"),j>0){let Q=()=>{let Z=Kz-j;setTimeout(()=>Vz(z,$,j-1),iz*Math.pow(2,Z))};J.onreadystatechange=()=>{if(J.readyState!==4)return;if(J.status===0||J.status>=500)Q()},J.onerror=Q}J.send($)}catch(J){}},xz=(z,$,j=!1)=>{Vz(z,$,j?Kz:0)},rz=(z,$)=>Xz??(z?`${$}/api/track`:`${y()}/events`),F=(z,$,j)=>{let J=t(),Q=!!J,Z=rz(Q,J),V=M(),G=JSON.stringify({...$,websiteId:V,type:z}),B=j?.retry??!1;if(Xz||!Q){xz(Z,G,B);return}if(G.length>sz){xz(Z,G,B);return}if(typeof navigator.sendBeacon==="function"){let U=new Blob([G],{type:"application/json"});if(navigator.sendBeacon(Z,U))return}fetch(Z,{method:"POST",headers:{"Content-Type":"application/json"},body:G,keepalive:!0}).catch(()=>{})};var k="_fs_vid",u="_fs_sid",N="_fs_sts",tz=1800000,A="_fs_vid",_="_fs_sid",az=(z)=>{let $=document.cookie.match(new RegExp(`(?:^|; )${z}=([^;]*)`));return $?decodeURIComponent($[1]):null},Yz=(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`},ez=(z)=>{let $=h(),j=$?`;domain=.${$}`:"";document.cookie=`${z}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${j};SameSite=Lax;Secure`},z3=()=>{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}},O=null,Uz=()=>{if(O===null)O=z3();return O},q=()=>{if(L())return;let z=Uz();if(z.vid){Yz(k,z.vid,730);let j=z.vid;return z.vid=void 0,j}let $=az(k);if(!$)$=E(),Yz(k,$,730);return $},W=()=>{if(L())return;let z=Uz();if(z.sid){let Q=z.sid;return sessionStorage.setItem(u,Q),sessionStorage.setItem(N,Date.now().toString()),z.sid=void 0,Q}let $=Date.now(),j=parseInt(sessionStorage.getItem(N)||"0",10),J=sessionStorage.getItem(u);if(!J||$-j>tz)J=E(),sessionStorage.setItem(u,J);return sessionStorage.setItem(N,$.toString()),J},Mz=()=>{if(L())return;sessionStorage.setItem(N,Date.now().toString())},w=()=>{let z=q(),$=W();return{...z&&{_fs_vid:z},...$&&{_fs_sid:$}}},H=(z)=>{let $=w(),j=new URL(z);if($._fs_vid)j.searchParams.set(A,$._fs_vid);if($._fs_sid)j.searchParams.set(_,$._fs_sid);return j.toString()},C=()=>{ez(k),sessionStorage.removeItem(u),sessionStorage.removeItem(N),O=null};var $3=5000,p=0,P=0,I=null,j3=()=>{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))},m=()=>{p++},Hz=()=>{let z=j3();P=Math.max(P,z);let $=q(),j=W();F("heartbeat",{...$&&{visitorUid:$},...j&&{sessionUid:j},path:location.pathname,scrollDepth:P,isVisible:document.visibilityState==="visible",interactionCount:p}),Mz()},Nz=()=>{p=0,P=0},wz=()=>{document.addEventListener("click",m,{passive:!0}),document.addEventListener("scroll",m,{passive:!0}),document.addEventListener("keydown",m,{passive:!0}),I=setInterval(Hz,$3),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")Hz()})},f=()=>{if(I)clearInterval(I),I=null};var Dz="",vz=!1,Y=()=>{let z=b(),$=z?location.href:location.pathname+location.search;if($===Dz)return;Dz=$,Nz();let j=Bz(),J=q(),Q=W(),Z=z?location.pathname+location.hash:location.pathname;if(F("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}),!vz){vz=!0;let V=y();if(V){let G=JSON.stringify({type:"geo",websiteId:M(),visitorUid:J||void 0,sessionUid:Q||void 0});try{fetch(`${V}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:G,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},yz=()=>{Y();let{pushState:z,replaceState:$}=history;if(history.pushState=function(...j){z.apply(this,j),Y()},history.replaceState=function(...j){$.apply(this,j),Y()},window.addEventListener("popstate",()=>Y()),b())window.addEventListener("hashchange",()=>Y())};var Lz=()=>{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=W();if(!Q||!Z)return;F("exit_click",{visitorUid:Q,sessionUid:Z,hostname:location.hostname,url:j})}catch{}})};var J3=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,bz=()=>{document.addEventListener("click",(z)=>{let $=z.target.closest("a");if(!$)return;let j=$.href;if(!j||!J3.test(j))return;let J=q(),Q=W();F("goal",{...J&&{visitorUid:J},...Q&&{sessionUid:Q},name:"file_download",metadata:{url:j}})})};var K=(z,$)=>{let j=q(),J=W();F("goal",{...j&&{visitorUid:j},...J&&{sessionUid:J},name:z,metadata:$})};var S="data-fs-goal",kz="data-fs-goal-",Q3=(z)=>{let $={},j=0;for(let J of Array.from(z.attributes))if(J.name.startsWith(kz)&&J.name!==S){let Q=J.name.slice(kz.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=Q3($);K(j,J)})};var T="data-fs-scroll",Pz="data-fs-scroll-threshold",c="data-fs-scroll-delay",Oz="data-fs-scroll-",Z3=new Set([T,Pz,c]),Cz=(z)=>{let $={},j=0;for(let J of Array.from(z.attributes))if(J.name.startsWith(Oz)&&!Z3.has(J.name)){let Q=J.name.slice(Oz.length).replace(/-/g,"_"),Z=(J.value||"").slice(0,255);if(Q&&j<10)$[Q]=Z,j++}return j>0?$:void 0},Iz=()=>{let z=document.querySelectorAll(`[${T}]`);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 V=Z.getAttribute(T);if(!V)continue;let G=parseInt(Z.getAttribute(c)||"0",10)||0,B=()=>{if($.has(Z))return;$.add(Z),j.unobserve(Z);let U=Cz(Z);K(V,U)};if(G>0)setTimeout(B,G);else B()}},{threshold:0});for(let J of Array.from(z)){let Q=parseFloat(J.getAttribute(Pz)||"0.5");if(Q!==0.5){let Z=new IntersectionObserver((V)=>{for(let G of V){let B=G.target;if(!G.isIntersecting||$.has(B))continue;let U=B.getAttribute(T);if(!U)continue;let d=parseInt(B.getAttribute(c)||"0",10)||0,l=()=>{if($.has(B))return;$.add(B),Z.unobserve(B);let hz=Cz(B);K(U,hz)};if(d>0)setTimeout(l,d);else l()}},{threshold:Q});Z.observe(J)}else j.observe(J)}};var n=null,fz=()=>{if(!n)n=new Set(Fz());return n},q3=(z)=>{let $=fz();if(!$.size)return!1;for(let j of $)if(z===j||z.endsWith(`.${j}`))return!0;return!1},Tz=()=>{if(!fz().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(!q3(Q.hostname))return;j.href=H(J)}catch{}})};var W3="buy.stripe.com",F3=(z,$)=>{try{let j=new URL(z);if(j.hostname!==W3)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=F3($.href,j)})};var D=(z)=>{let $=q(),j=W();F("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 v=(z)=>{let $=q();F("identify",{...$&&{visitorUid:$},userId:z.userId,name:z.name,email:z.email,image:z.image,profileData:z.profileData})};var G3=()=>{if(typeof document>"u")return;if(document.querySelector("script[data-fl-recording]"))return;let z=document.createElement("script");z.src=Wz(),z.defer=!0,z.setAttribute("data-fl-recording",""),(document.head||document.documentElement).appendChild(z)},Ez=(z)=>{let[$,...j]=z;switch($){case"identify":v(j[0]);break;case"payment":D(j[0]);break;default:K($,j[0]);break}},g=()=>{if(i())return;if(!M())return;if(Gz())return;if(a()&&!e())return;if(zz()&&!$z())return;if(jz()&&!Jz())return;if(yz(),wz(),Lz(),bz(),uz(),Iz(),Tz(),Rz(),Qz()){let j=W();if(!j||Zz(j,qz()))G3()}let z=window,$=z.flowsery?.q||[];for(let j of $)Ez(j);z.flowsery=function(...j){Ez(j)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",g);else g();var B3=async(z)=>{let $=window;return $.__flowsery_config=z,g(),{trackEvent:K,trackPayment:D,trackPageview:Y,identify:v,stop:f,reset:C,getTrackingParams:w,buildCrossDomainUrl:H,getVisitorId:q,getSessionId:W}};})();
|
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:R,getOwnPropertyNames:Az,getOwnPropertyDescriptor:_z}=Object,mz=Object.prototype.hasOwnProperty;function pz(z){return this[z]}var Sz=(z)=>{var $=(o??=new WeakMap).get(z),j;if($)return $;if($=R({},"__esModule",{value:!0}),z&&typeof z==="object"||typeof z==="function"){for(var J of Az(z))if(!mz.call($,J))R($,J,{get:pz.bind(z,J),enumerable:!(j=_z(z,J))||j.enumerable})}return o.set(z,$),$},o;var cz=(z)=>z;function nz(z,$){this[z]=cz.bind(null,$)}var gz=(z,$)=>{for(var j in $)R(z,j,{get:$[j],enumerable:!0,configurable:!0,set:nz.bind($,j)})};var x3={};gz(x3,{trackPayment:()=>D,trackPageview:()=>Y,trackEvent:()=>K,stopHeartbeat:()=>f,reset:()=>C,initFlowsery:()=>B3,identify:()=>v,getVisitorId:()=>q,getTrackingParams:()=>w,getSessionId:()=>W,buildCrossDomainUrl:()=>H});var E=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(z)=>{let $=Math.random()*16|0;return(z==="x"?$:$&3|8).toString(16)})},i=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0};var x=()=>{return window.__flowsery_config||null},X=()=>{return document.querySelector("script[data-fl-website-id]")},M=()=>{let z=x();if(z)return z.websiteId;return X()?.getAttribute("data-fl-website-id")||""},r=()=>{return x()?.apiUrl??null},t=()=>{let z=x();if(z?.apiBase)return z.apiBase;let $=X(),j=$?.getAttribute("data-api");if(j)return j;let J=$?.src??"",Q=J.replace(/\/js\/(?:script|main|recording)(?:\.hash)?\.js.*/,"");return Q===J?"":Q},y=()=>{return"https://analytics.flowsery.com/analytics"},h=()=>{let z=x();if(z?.domain)return z.domain;return X()?.getAttribute("data-domain")||location.hostname},L=()=>{let z=x();if(z)return!!z.cookieless;return X()?.hasAttribute("data-cookieless")??!1},dz=new Set(["localhost","127.0.0.1","[::1]"]),a=()=>{return dz.has(location.hostname)||location.hostname.endsWith(".local")},e=()=>{let z=x();if(z)return!!z.local;return X()?.hasAttribute("data-local")??!1},zz=()=>{return location.protocol==="file:"},$z=()=>{let z=x();if(z)return!!z.allowFileProtocol;return X()?.hasAttribute("data-allow-file-protocol")??!1},jz=()=>{try{return window.self!==window.top}catch{return!0}},Jz=()=>{let z=x();if(z)return!!z.allowIframe;return X()?.hasAttribute("data-allow-iframe")??!1};var b=()=>{let z=x();if(z)return!!z.hashMode;return X()?.src?.includes(".hash.js")??!1},Qz=()=>{let z=x();if(z)return!!z.recording;return X()?.hasAttribute("data-recording")??!1},lz=(z)=>{let $=2166136261;for(let j=0;j<z.length;j++)$^=z.charCodeAt(j),$=Math.imul($,16777619);return($>>>0)%100},Zz=(z,$)=>{if(!Number.isFinite($)||$>=100)return!0;if($<=0)return!1;return lz(z)<$},s=(z)=>z==null||!Number.isFinite(z)?100:Math.max(0,Math.min(100,Math.floor(z))),oz=(z,$)=>{if(typeof z==="number")return s(z);let j=X()?.getAttribute($);return s(j!=null&&j!==""?Number(j):null)},qz=()=>oz(x()?.recordingSampleRate,"data-recording-sample");var Wz=()=>{let z=`recording${b()?".hash":""}.js`,$=X()?.src;if($)return $.replace(/(?:script|main)(?:\.hash)?\.js(?:\?.*)?$/,z);return`https://cdn.flowsery.com/${z}`},Fz=()=>{let z=x();if(z?.allowedHostnames)return z.allowedHostnames;let j=X()?.getAttribute("data-allowed-hostnames");return j?j.split(",").map((J)=>J.trim()).filter(Boolean):[]},Gz=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},Bz=()=>{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 Xz=r(),sz=61440,Kz=3,iz=1000,Vz=(z,$,j)=>{try{let J=new XMLHttpRequest;if(J.open("POST",z,!0),J.setRequestHeader("Content-Type","application/json"),j>0){let Q=()=>{let Z=Kz-j;setTimeout(()=>Vz(z,$,j-1),iz*Math.pow(2,Z))};J.onreadystatechange=()=>{if(J.readyState!==4)return;if(J.status===0||J.status>=500)Q()},J.onerror=Q}J.send($)}catch(J){}},xz=(z,$,j=!1)=>{Vz(z,$,j?Kz:0)},rz=(z,$)=>Xz??(z?`${$}/api/track`:`${y()}/events`),F=(z,$,j)=>{let J=t(),Q=!!J,Z=rz(Q,J),V=M(),G=JSON.stringify({...$,websiteId:V,type:z}),B=j?.retry??!1;if(Xz||!Q){xz(Z,G,B);return}if(G.length>sz){xz(Z,G,B);return}if(typeof navigator.sendBeacon==="function"){let U=new Blob([G],{type:"application/json"});if(navigator.sendBeacon(Z,U))return}fetch(Z,{method:"POST",headers:{"Content-Type":"application/json"},body:G,keepalive:!0}).catch(()=>{})};var k="_fs_vid",u="_fs_sid",N="_fs_sts",tz=1800000,A="_fs_vid",_="_fs_sid",az=(z)=>{let $=document.cookie.match(new RegExp(`(?:^|; )${z}=([^;]*)`));return $?decodeURIComponent($[1]):null},Yz=(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`},ez=(z)=>{let $=h(),j=$?`;domain=.${$}`:"";document.cookie=`${z}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${j};SameSite=Lax;Secure`},z3=()=>{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}},O=null,Uz=()=>{if(O===null)O=z3();return O},q=()=>{if(L())return;let z=Uz();if(z.vid){Yz(k,z.vid,730);let j=z.vid;return z.vid=void 0,j}let $=az(k);if(!$)$=E(),Yz(k,$,730);return $},W=()=>{if(L())return;let z=Uz();if(z.sid){let Q=z.sid;return sessionStorage.setItem(u,Q),sessionStorage.setItem(N,Date.now().toString()),z.sid=void 0,Q}let $=Date.now(),j=parseInt(sessionStorage.getItem(N)||"0",10),J=sessionStorage.getItem(u);if(!J||$-j>tz)J=E(),sessionStorage.setItem(u,J);return sessionStorage.setItem(N,$.toString()),J},Mz=()=>{if(L())return;sessionStorage.setItem(N,Date.now().toString())},w=()=>{let z=q(),$=W();return{...z&&{_fs_vid:z},...$&&{_fs_sid:$}}},H=(z)=>{let $=w(),j=new URL(z);if($._fs_vid)j.searchParams.set(A,$._fs_vid);if($._fs_sid)j.searchParams.set(_,$._fs_sid);return j.toString()},C=()=>{ez(k),sessionStorage.removeItem(u),sessionStorage.removeItem(N),O=null};var $3=5000,p=0,P=0,I=null,j3=()=>{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))},m=()=>{p++},Hz=()=>{let z=j3();P=Math.max(P,z);let $=q(),j=W();F("heartbeat",{...$&&{visitorUid:$},...j&&{sessionUid:j},path:location.pathname,scrollDepth:P,isVisible:document.visibilityState==="visible",interactionCount:p}),Mz()},Nz=()=>{p=0,P=0},wz=()=>{document.addEventListener("click",m,{passive:!0}),document.addEventListener("scroll",m,{passive:!0}),document.addEventListener("keydown",m,{passive:!0}),I=setInterval(Hz,$3),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")Hz()})},f=()=>{if(I)clearInterval(I),I=null};var Dz="",vz=!1,Y=()=>{let z=b(),$=z?location.href:location.pathname+location.search;if($===Dz)return;Dz=$,Nz();let j=Bz(),J=q(),Q=W(),Z=z?location.pathname+location.hash:location.pathname;if(F("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}),!vz){vz=!0;let V=y();if(V){let G=JSON.stringify({type:"geo",websiteId:M(),visitorUid:J||void 0,sessionUid:Q||void 0});try{fetch(`${V}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:G,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},yz=()=>{Y();let{pushState:z,replaceState:$}=history;if(history.pushState=function(...j){z.apply(this,j),Y()},history.replaceState=function(...j){$.apply(this,j),Y()},window.addEventListener("popstate",()=>Y()),b())window.addEventListener("hashchange",()=>Y())};var Lz=()=>{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=W();if(!Q||!Z)return;F("exit_click",{visitorUid:Q,sessionUid:Z,hostname:location.hostname,url:j})}catch{}})};var J3=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,bz=()=>{document.addEventListener("click",(z)=>{let $=z.target.closest("a");if(!$)return;let j=$.href;if(!j||!J3.test(j))return;let J=q(),Q=W();F("goal",{...J&&{visitorUid:J},...Q&&{sessionUid:Q},name:"file_download",metadata:{url:j}})})};var K=(z,$)=>{let j=q(),J=W();F("goal",{...j&&{visitorUid:j},...J&&{sessionUid:J},name:z,metadata:$})};var S="data-fs-goal",kz="data-fs-goal-",Q3=(z)=>{let $={},j=0;for(let J of Array.from(z.attributes))if(J.name.startsWith(kz)&&J.name!==S){let Q=J.name.slice(kz.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=Q3($);K(j,J)})};var T="data-fs-scroll",Pz="data-fs-scroll-threshold",c="data-fs-scroll-delay",Oz="data-fs-scroll-",Z3=new Set([T,Pz,c]),Cz=(z)=>{let $={},j=0;for(let J of Array.from(z.attributes))if(J.name.startsWith(Oz)&&!Z3.has(J.name)){let Q=J.name.slice(Oz.length).replace(/-/g,"_"),Z=(J.value||"").slice(0,255);if(Q&&j<10)$[Q]=Z,j++}return j>0?$:void 0},Iz=()=>{let z=document.querySelectorAll(`[${T}]`);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 V=Z.getAttribute(T);if(!V)continue;let G=parseInt(Z.getAttribute(c)||"0",10)||0,B=()=>{if($.has(Z))return;$.add(Z),j.unobserve(Z);let U=Cz(Z);K(V,U)};if(G>0)setTimeout(B,G);else B()}},{threshold:0});for(let J of Array.from(z)){let Q=parseFloat(J.getAttribute(Pz)||"0.5");if(Q!==0.5){let Z=new IntersectionObserver((V)=>{for(let G of V){let B=G.target;if(!G.isIntersecting||$.has(B))continue;let U=B.getAttribute(T);if(!U)continue;let d=parseInt(B.getAttribute(c)||"0",10)||0,l=()=>{if($.has(B))return;$.add(B),Z.unobserve(B);let hz=Cz(B);K(U,hz)};if(d>0)setTimeout(l,d);else l()}},{threshold:Q});Z.observe(J)}else j.observe(J)}};var n=null,fz=()=>{if(!n)n=new Set(Fz());return n},q3=(z)=>{let $=fz();if(!$.size)return!1;for(let j of $)if(z===j||z.endsWith(`.${j}`))return!0;return!1},Tz=()=>{if(!fz().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(!q3(Q.hostname))return;j.href=H(J)}catch{}})};var W3="buy.stripe.com",F3=(z,$)=>{try{let j=new URL(z);if(j.hostname!==W3)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=F3($.href,j)})};var D=(z)=>{let $=q(),j=W();F("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 v=(z)=>{let $=q();F("identify",{...$&&{visitorUid:$},userId:z.userId,name:z.name,email:z.email,image:z.image,profileData:z.profileData})};var G3=()=>{if(typeof document>"u")return;if(document.querySelector("script[data-fl-recording]"))return;let z=document.createElement("script");z.src=Wz(),z.defer=!0,z.setAttribute("data-fl-recording",""),(document.head||document.documentElement).appendChild(z)},Ez=(z)=>{let[$,...j]=z;switch($){case"identify":v(j[0]);break;case"payment":D(j[0]);break;default:K($,j[0]);break}},g=()=>{if(i())return;if(!M())return;if(Gz())return;if(a()&&!e())return;if(zz()&&!$z())return;if(jz()&&!Jz())return;if(yz(),wz(),Lz(),bz(),uz(),Iz(),Tz(),Rz(),Qz()){let j=W();if(!j||Zz(j,qz()))G3()}let z=window,$=z.flowsery?.q||[];for(let j of $)Ez(j);z.flowsery=function(...j){Ez(j)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",g);else g();var B3=async(z)=>{let $=window;return $.__flowsery_config=z,g(),{trackEvent:K,trackPayment:D,trackPageview:Y,identify:v,stop:f,reset:C,getTrackingParams:w,buildCrossDomainUrl:H,getVisitorId:q,getSessionId:W}};})();
|