flowsery 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +204 -0
- package/dist/index.cjs +1 -0
- package/dist/index.mjs +1 -0
- package/dist/main.hash.js +1 -0
- package/dist/main.js +1 -0
- package/dist/script.hash.js +1 -0
- package/dist/script.js +1 -0
- package/package.json +34 -0
package/README.md
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# Flowsery
|
|
2
|
+
|
|
3
|
+
Privacy-focused website analytics for modern apps and simple script-tag installs.
|
|
4
|
+
|
|
5
|
+
Use Flowsery if you want:
|
|
6
|
+
|
|
7
|
+
- a quick npm setup for React, Next.js, Vue, Svelte, or plain JavaScript
|
|
8
|
+
- a hosted browser script you can drop into any site
|
|
9
|
+
- optional proxying through your own domain
|
|
10
|
+
- automatic pageviews, outbound link tracking, downloads, and heartbeat events
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install flowsery
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
Initialize Flowsery with your website ID. That is enough to start automatic pageview tracking.
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { initFlowsery } from 'flowsery';
|
|
24
|
+
|
|
25
|
+
const flowsery = await initFlowsery({
|
|
26
|
+
websiteId: 'flid_******',
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Use the returned client anywhere in your app:
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
flowsery.trackEvent('signup', { plan: 'pro' });
|
|
34
|
+
|
|
35
|
+
flowsery.identify({
|
|
36
|
+
userId: 'usr_123',
|
|
37
|
+
name: 'John Doe',
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
flowsery.trackPayment({
|
|
41
|
+
amount: 29,
|
|
42
|
+
currency: 'USD',
|
|
43
|
+
transactionId: 'pay_123',
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Cookieless Mode
|
|
48
|
+
|
|
49
|
+
If you do not want Flowsery to create visitor and session cookies, enable cookieless mode:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { initFlowsery } from 'flowsery';
|
|
53
|
+
|
|
54
|
+
const flowsery = await initFlowsery({
|
|
55
|
+
websiteId: 'flid_******',
|
|
56
|
+
cookieless: true,
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Proxy Setup
|
|
61
|
+
|
|
62
|
+
If you proxy tracking through your own domain, point `apiBase` at your site:
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
import { initFlowsery } from 'flowsery';
|
|
66
|
+
|
|
67
|
+
const flowsery = await initFlowsery({
|
|
68
|
+
websiteId: 'flid_******',
|
|
69
|
+
apiBase: 'https://example.com',
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Typical proxy setup:
|
|
74
|
+
|
|
75
|
+
- `/js/main.js` serves the Flowsery browser bundle
|
|
76
|
+
- `/api/track` proxies to `https://analytics.flowsery.com/analytics/events`
|
|
77
|
+
|
|
78
|
+
If you proxy events and also want direct geo enrichment, you can additionally set:
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
const flowsery = await initFlowsery({
|
|
82
|
+
websiteId: 'flid_******',
|
|
83
|
+
apiBase: 'https://example.com',
|
|
84
|
+
analyticsHost: 'https://analytics.flowsery.com/analytics',
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Script Tag
|
|
89
|
+
|
|
90
|
+
If you prefer not to use npm, you can install Flowsery with a script tag.
|
|
91
|
+
|
|
92
|
+
### Direct install
|
|
93
|
+
|
|
94
|
+
```html
|
|
95
|
+
<script>
|
|
96
|
+
window.flowsery =
|
|
97
|
+
window.flowsery ||
|
|
98
|
+
function () {
|
|
99
|
+
(window.flowsery.q = window.flowsery.q || []).push(arguments);
|
|
100
|
+
};
|
|
101
|
+
</script>
|
|
102
|
+
<script
|
|
103
|
+
defer
|
|
104
|
+
data-fl-website-id="flid_******"
|
|
105
|
+
data-domain="example.com"
|
|
106
|
+
src="https://cdn.flowsery.com/main.js"
|
|
107
|
+
></script>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Proxy install
|
|
111
|
+
|
|
112
|
+
```html
|
|
113
|
+
<script>
|
|
114
|
+
window.flowsery =
|
|
115
|
+
window.flowsery ||
|
|
116
|
+
function () {
|
|
117
|
+
(window.flowsery.q = window.flowsery.q || []).push(arguments);
|
|
118
|
+
};
|
|
119
|
+
</script>
|
|
120
|
+
<script
|
|
121
|
+
defer
|
|
122
|
+
data-fl-website-id="flid_******"
|
|
123
|
+
data-domain="example.com"
|
|
124
|
+
src="https://example.com/js/main.js"
|
|
125
|
+
></script>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
To improve geo accuracy in a proxied setup:
|
|
129
|
+
|
|
130
|
+
```html
|
|
131
|
+
<script
|
|
132
|
+
defer
|
|
133
|
+
data-fl-website-id="flid_******"
|
|
134
|
+
data-domain="example.com"
|
|
135
|
+
data-fl-host="https://analytics.flowsery.com/analytics"
|
|
136
|
+
src="https://example.com/js/main.js"
|
|
137
|
+
></script>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## What Flowsery Tracks Automatically
|
|
141
|
+
|
|
142
|
+
- pageviews, including SPA navigation
|
|
143
|
+
- heartbeat events with scroll depth, visibility, and interaction count
|
|
144
|
+
- outbound link clicks
|
|
145
|
+
- file downloads
|
|
146
|
+
- visitor and session IDs, unless cookieless mode is enabled
|
|
147
|
+
- UTM, `ref`, `source`, and `via` parameters
|
|
148
|
+
|
|
149
|
+
## Common Methods
|
|
150
|
+
|
|
151
|
+
`initFlowsery()` returns a client with:
|
|
152
|
+
|
|
153
|
+
- `trackEvent(name, metadata?)`
|
|
154
|
+
- `trackPayment(data)`
|
|
155
|
+
- `trackPageview()`
|
|
156
|
+
- `identify(data)`
|
|
157
|
+
- `stop()`
|
|
158
|
+
- `reset()`
|
|
159
|
+
- `getTrackingParams()`
|
|
160
|
+
- `buildCrossDomainUrl(url)`
|
|
161
|
+
- `getVisitorId()`
|
|
162
|
+
- `getSessionId()`
|
|
163
|
+
|
|
164
|
+
## Configuration
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
type FlowseryConfig = {
|
|
168
|
+
websiteId: string;
|
|
169
|
+
apiBase?: string;
|
|
170
|
+
analyticsHost?: string;
|
|
171
|
+
domain?: string;
|
|
172
|
+
cookieless?: boolean;
|
|
173
|
+
local?: boolean;
|
|
174
|
+
allowFileProtocol?: boolean;
|
|
175
|
+
allowIframe?: boolean;
|
|
176
|
+
disablePayments?: boolean;
|
|
177
|
+
disableConsole?: boolean;
|
|
178
|
+
allowedHostnames?: string[];
|
|
179
|
+
hashMode?: boolean;
|
|
180
|
+
};
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Build
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
bun install
|
|
187
|
+
bun run build
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Build output:
|
|
191
|
+
|
|
192
|
+
- `dist/main.js`
|
|
193
|
+
- `dist/main.hash.js`
|
|
194
|
+
- `dist/script.js`
|
|
195
|
+
- `dist/script.hash.js`
|
|
196
|
+
- `dist/index.mjs`
|
|
197
|
+
- `dist/index.cjs`
|
|
198
|
+
|
|
199
|
+
## Docs
|
|
200
|
+
|
|
201
|
+
For full setup guides and configuration details, see:
|
|
202
|
+
|
|
203
|
+
- https://flowsery.com/docs/npm-sdk
|
|
204
|
+
- https://flowsery.com/docs/script-configuration
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var h=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o)=>{let n=Math.random()*16|0;return(o==="x"?n:n&3|8).toString(16)})},D=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0},s=()=>{return window.__flowsery_config||null},i=()=>{return document.querySelector("script[data-fl-website-id]")},B=()=>{let o=s();if(o)return o.websiteId;return i()?.getAttribute("data-fl-website-id")||""},A=()=>{let o=s();if(o?.apiBase)return o.apiBase;let n=i();return n?.getAttribute("data-api")||n?.src?.replace(/\/js\/(?:script|main)(?:\.hash)?\.js.*/,"")||""},E=()=>{let o=s();if(o?.analyticsHost)return o.analyticsHost;return i()?.getAttribute("data-fl-host")||null},G=()=>{let o=s();if(o?.domain)return o.domain;return i()?.getAttribute("data-domain")||location.hostname},F=()=>{let o=s();if(o)return!!o.cookieless;return i()?.hasAttribute("data-cookieless")??!1},Qo=new Set(["localhost","127.0.0.1","[::1]"]),R=()=>{return Qo.has(location.hostname)||location.hostname.endsWith(".local")},O=()=>{let o=s();if(o)return!!o.local;return i()?.hasAttribute("data-local")??!1},T=()=>{return location.protocol==="file:"},_=()=>{let o=s();if(o)return!!o.allowFileProtocol;return i()?.hasAttribute("data-allow-file-protocol")??!1},S=()=>{try{return window.self!==window.top}catch{return!0}},a=()=>{let o=s();if(o)return!!o.allowIframe;return i()?.hasAttribute("data-debug")??!1};var M=()=>{let o=s();if(o)return!!o.hashMode;return i()?.src?.includes(".hash.js")??!1},oo=()=>{let o=s();if(o?.allowedHostnames)return o.allowedHostnames;let t=i()?.getAttribute("data-allowed-hostnames");return t?t.split(",").map((c)=>c.trim()).filter(Boolean):[]},no=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},to=()=>{let o=new URLSearchParams(window.location.search),n={};for(let t of["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref","source","via"]){let c=o.get(t);if(c)n[t]=c}return n};var l=(o,n)=>{let c=`${A()}/api/track`,r=B(),f=JSON.stringify({...n,websiteId:r,type:o});if(typeof navigator.sendBeacon==="function"){let b=new Blob([f],{type:"application/json"});if(navigator.sendBeacon(c,b))return}fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:f,keepalive:!0}).catch(()=>{})};var $="_fs_vid",g="_fs_sid",j="_fs_sts",Wo=1800000,V="_fs_vid",U="_fs_sid",Zo=(o)=>{let n=document.cookie.match(new RegExp(`(?:^|; )${o}=([^;]*)`));return n?decodeURIComponent(n[1]):null},co=(o,n,t)=>{let c=new Date(Date.now()+t*86400000).toUTCString(),r=G(),f=r?`;domain=.${r}`:"";document.cookie=`${o}=${encodeURIComponent(n)};expires=${c};path=/${f};SameSite=Lax;Secure`},qo=(o)=>{let n=G(),t=n?`;domain=.${n}`:"";document.cookie=`${o}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${t};SameSite=Lax;Secure`},Xo=()=>{let o=new URLSearchParams(window.location.search),n=o.get(V)||void 0,t=o.get(U)||void 0;if(n||t){o.delete(V),o.delete(U);let c=o.toString(),r=window.location.pathname+(c?`?${c}`:"")+window.location.hash;history.replaceState(null,"",r)}return{vid:n,sid:t}},J=null,ro=()=>{if(J===null)J=Xo();return J},u=()=>{if(F())return;let o=ro();if(o.vid){co($,o.vid,730);let t=o.vid;return o.vid=void 0,t}let n=Zo($);if(!n)n=h(),co($,n,730);return n},x=()=>{if(F())return;let o=ro();if(o.sid){let r=o.sid;return sessionStorage.setItem(g,r),sessionStorage.setItem(j,Date.now().toString()),o.sid=void 0,r}let n=Date.now(),t=parseInt(sessionStorage.getItem(j)||"0",10),c=sessionStorage.getItem(g);if(!c||n-t>Wo)c=h(),sessionStorage.setItem(g,c);return sessionStorage.setItem(j,n.toString()),c},fo=()=>{if(F())return;sessionStorage.setItem(j,Date.now().toString())},Q=()=>{let o=u(),n=x();return{...o&&{_fs_vid:o},...n&&{_fs_sid:n}}},z=(o)=>{let n=Q(),t=new URL(o);if(n._fs_vid)t.searchParams.set(V,n._fs_vid);if(n._fs_sid)t.searchParams.set(U,n._fs_sid);return t.toString()},K=()=>{qo($),sessionStorage.removeItem(g),sessionStorage.removeItem(j),J=null};var Ho=5000,N=0,W=0,Z=null,ho=()=>{let o=document.documentElement,n=window.scrollY||o.scrollTop,t=o.scrollHeight-o.clientHeight;if(t<=0)return 100;return Math.min(100,Math.round(n/t*100))},Y=()=>{N++},uo=()=>{let o=ho();W=Math.max(W,o);let n=u(),t=x();l("heartbeat",{...n&&{visitorUid:n},...t&&{sessionUid:t},path:location.pathname+location.search,scrollDepth:W,isVisible:document.visibilityState==="visible",interactionCount:N}),fo()},xo=()=>{N=0,W=0},lo=()=>{document.addEventListener("click",Y,{passive:!0}),document.addEventListener("scroll",Y,{passive:!0}),document.addEventListener("keydown",Y,{passive:!0}),Z=setInterval(uo,Ho),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")uo()})},P=()=>{if(Z)clearInterval(Z),Z=null};var eo="",so=!1,w=()=>{let o=M(),n=o?location.href:location.pathname+location.search;if(n===eo)return;eo=n,xo();let t=to(),c=u(),r=x(),f=o?location.pathname+location.search+location.hash:location.pathname+location.search;if(l("pageview",{...c&&{visitorUid:c},...r&&{sessionUid:r},hostname:location.hostname,path:f,referrer:document.referrer||void 0,title:document.title||void 0,screenWidth:window.screen?.width,screenHeight:window.screen?.height,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||void 0,language:navigator.language||void 0,utmSource:t.utm_source,utmMedium:t.utm_medium,utmCampaign:t.utm_campaign,utmTerm:t.utm_term,utmContent:t.utm_content,ref:t.ref,source:t.source,via:t.via}),!so){so=!0;let b=E();if(b){let y=JSON.stringify({type:"geo",websiteId:B(),visitorUid:c||void 0,sessionUid:r||void 0});try{fetch(`${b}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:y,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},io=()=>{w();let{pushState:o,replaceState:n}=history;if(history.pushState=function(...t){o.apply(this,t),w()},history.replaceState=function(...t){n.apply(this,t),w()},window.addEventListener("popstate",()=>w()),M())window.addEventListener("hashchange",()=>w())};var bo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t)return;try{let c=new URL(t);if(c.protocol!=="http:"&&c.protocol!=="https:")return;if(c.hostname===location.hostname)return;let r=u(),f=x();if(!r||!f)return;l("exit_click",{visitorUid:r,sessionUid:f,hostname:location.hostname,url:t})}catch{}})};var Go=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,po=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t||!Go.test(t))return;let c=u(),r=x();l("goal",{...c&&{visitorUid:c},...r&&{sessionUid:r},name:"file_download",metadata:{url:t}})})};var p=(o,n)=>{let t=u(),c=x();l("goal",{...t&&{visitorUid:t},...c&&{sessionUid:c},name:o,metadata:n})};var v="data-fs-goal",wo="data-fs-goal-",Mo=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(wo)&&c.name!==v){let r=c.name.slice(wo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},yo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest(`[${v}]`);if(!n)return;let t=n.getAttribute(v);if(!t)return;let c=Mo(n);p(t,c)})};var q="data-fs-scroll",zo="data-fs-scroll-threshold",k="data-fs-scroll-delay",Bo="data-fs-scroll-",Vo=new Set([q,zo,k]),jo=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(Bo)&&!Vo.has(c.name)){let r=c.name.slice(Bo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},mo=()=>{let o=document.querySelectorAll(`[${q}]`);if(!o.length)return;let n=new Set,t=new IntersectionObserver((c)=>{for(let r of c){let f=r.target;if(!r.isIntersecting||n.has(f))continue;let b=f.getAttribute(q);if(!b)continue;let y=parseInt(f.getAttribute(k)||"0",10)||0,e=()=>{if(n.has(f))return;n.add(f),t.unobserve(f);let m=jo(f);p(b,m)};if(y>0)setTimeout(e,y);else e()}},{threshold:0});for(let c of Array.from(o)){let r=parseFloat(c.getAttribute(zo)||"0.5");if(r!==0.5){let f=new IntersectionObserver((b)=>{for(let y of b){let e=y.target;if(!y.isIntersecting||n.has(e))continue;let m=e.getAttribute(q);if(!m)continue;let d=parseInt(e.getAttribute(k)||"0",10)||0,C=()=>{if(n.has(e))return;n.add(e),f.unobserve(e);let Jo=jo(e);p(m,Jo)};if(d>0)setTimeout(C,d);else C()}},{threshold:r});f.observe(c)}else t.observe(c)}};var L=null,Fo=()=>{if(!L)L=new Set(oo());return L},Uo=(o)=>{let n=Fo();if(!n.size)return!1;for(let t of n)if(o===t||o.endsWith(`.${t}`))return!0;return!1},$o=()=>{if(!Fo().size)return;document.addEventListener("click",(n)=>{let t=n.target.closest("a");if(!t)return;let c=t.href;if(!c)return;try{let r=new URL(c);if(r.hostname===location.hostname)return;if(!Uo(r.hostname))return;t.href=z(c)}catch{}})};var X=(o)=>{let n=u(),t=x();l("payment",{...n&&{visitorUid:n},...t&&{sessionUid:t},...o.amount!=null&&{amount:o.amount},...o.currency&&{currency:o.currency},...o.transactionId&&{transactionId:o.transactionId},...o.email&&{email:o.email},...o.name&&{name:o.name},...o.customerId&&{customerId:o.customerId},...o.isRenewal!=null&&{isRenewal:o.isRenewal},...o.isRefund!=null&&{isRefund:o.isRefund}})};var H=(o)=>{let n=u();l("identify",{...n&&{visitorUid:n},userId:o.userId,name:o.name,image:o.image,profileData:o.profileData})};var go=(o)=>{let[n,...t]=o;switch(n){case"identify":H(t[0]);break;case"payment":X(t[0]);break;default:p(n,t[0]);break}},I=()=>{if(D())return;if(!B())return;if(no())return;if(R()&&!O())return;if(T()&&!_())return;if(S()&&!a())return;io(),lo(),bo(),po(),yo(),mo(),$o();let o=window,n=o.flowsery?.q||[];for(let t of n)go(t);o.flowsery=function(...t){go(t)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",I);else I();var hn=async(o)=>{let n=window;return n.__flowsery_config=o,I(),{trackEvent:p,trackPayment:X,trackPageview:w,identify:H,stop:P,reset:K,getTrackingParams:Q,buildCrossDomainUrl:z,getVisitorId:u,getSessionId:x}};export{X as trackPayment,w as trackPageview,p as trackEvent,P as stopHeartbeat,K as reset,hn as initFlowsery,H as identify,u as getVisitorId,Q as getTrackingParams,x as getSessionId,z as buildCrossDomainUrl};
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var h=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o)=>{let n=Math.random()*16|0;return(o==="x"?n:n&3|8).toString(16)})},D=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0},s=()=>{return window.__flowsery_config||null},i=()=>{return document.querySelector("script[data-fl-website-id]")},B=()=>{let o=s();if(o)return o.websiteId;return i()?.getAttribute("data-fl-website-id")||""},A=()=>{let o=s();if(o?.apiBase)return o.apiBase;let n=i();return n?.getAttribute("data-api")||n?.src?.replace(/\/js\/(?:script|main)(?:\.hash)?\.js.*/,"")||""},E=()=>{let o=s();if(o?.analyticsHost)return o.analyticsHost;return i()?.getAttribute("data-fl-host")||null},G=()=>{let o=s();if(o?.domain)return o.domain;return i()?.getAttribute("data-domain")||location.hostname},F=()=>{let o=s();if(o)return!!o.cookieless;return i()?.hasAttribute("data-cookieless")??!1},Qo=new Set(["localhost","127.0.0.1","[::1]"]),R=()=>{return Qo.has(location.hostname)||location.hostname.endsWith(".local")},O=()=>{let o=s();if(o)return!!o.local;return i()?.hasAttribute("data-local")??!1},T=()=>{return location.protocol==="file:"},_=()=>{let o=s();if(o)return!!o.allowFileProtocol;return i()?.hasAttribute("data-allow-file-protocol")??!1},S=()=>{try{return window.self!==window.top}catch{return!0}},a=()=>{let o=s();if(o)return!!o.allowIframe;return i()?.hasAttribute("data-debug")??!1};var M=()=>{let o=s();if(o)return!!o.hashMode;return i()?.src?.includes(".hash.js")??!1},oo=()=>{let o=s();if(o?.allowedHostnames)return o.allowedHostnames;let t=i()?.getAttribute("data-allowed-hostnames");return t?t.split(",").map((c)=>c.trim()).filter(Boolean):[]},no=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},to=()=>{let o=new URLSearchParams(window.location.search),n={};for(let t of["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref","source","via"]){let c=o.get(t);if(c)n[t]=c}return n};var l=(o,n)=>{let c=`${A()}/api/track`,r=B(),f=JSON.stringify({...n,websiteId:r,type:o});if(typeof navigator.sendBeacon==="function"){let b=new Blob([f],{type:"application/json"});if(navigator.sendBeacon(c,b))return}fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:f,keepalive:!0}).catch(()=>{})};var $="_fs_vid",g="_fs_sid",j="_fs_sts",Wo=1800000,V="_fs_vid",U="_fs_sid",Zo=(o)=>{let n=document.cookie.match(new RegExp(`(?:^|; )${o}=([^;]*)`));return n?decodeURIComponent(n[1]):null},co=(o,n,t)=>{let c=new Date(Date.now()+t*86400000).toUTCString(),r=G(),f=r?`;domain=.${r}`:"";document.cookie=`${o}=${encodeURIComponent(n)};expires=${c};path=/${f};SameSite=Lax;Secure`},qo=(o)=>{let n=G(),t=n?`;domain=.${n}`:"";document.cookie=`${o}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${t};SameSite=Lax;Secure`},Xo=()=>{let o=new URLSearchParams(window.location.search),n=o.get(V)||void 0,t=o.get(U)||void 0;if(n||t){o.delete(V),o.delete(U);let c=o.toString(),r=window.location.pathname+(c?`?${c}`:"")+window.location.hash;history.replaceState(null,"",r)}return{vid:n,sid:t}},J=null,ro=()=>{if(J===null)J=Xo();return J},u=()=>{if(F())return;let o=ro();if(o.vid){co($,o.vid,730);let t=o.vid;return o.vid=void 0,t}let n=Zo($);if(!n)n=h(),co($,n,730);return n},x=()=>{if(F())return;let o=ro();if(o.sid){let r=o.sid;return sessionStorage.setItem(g,r),sessionStorage.setItem(j,Date.now().toString()),o.sid=void 0,r}let n=Date.now(),t=parseInt(sessionStorage.getItem(j)||"0",10),c=sessionStorage.getItem(g);if(!c||n-t>Wo)c=h(),sessionStorage.setItem(g,c);return sessionStorage.setItem(j,n.toString()),c},fo=()=>{if(F())return;sessionStorage.setItem(j,Date.now().toString())},Q=()=>{let o=u(),n=x();return{...o&&{_fs_vid:o},...n&&{_fs_sid:n}}},z=(o)=>{let n=Q(),t=new URL(o);if(n._fs_vid)t.searchParams.set(V,n._fs_vid);if(n._fs_sid)t.searchParams.set(U,n._fs_sid);return t.toString()},K=()=>{qo($),sessionStorage.removeItem(g),sessionStorage.removeItem(j),J=null};var Ho=5000,N=0,W=0,Z=null,ho=()=>{let o=document.documentElement,n=window.scrollY||o.scrollTop,t=o.scrollHeight-o.clientHeight;if(t<=0)return 100;return Math.min(100,Math.round(n/t*100))},Y=()=>{N++},uo=()=>{let o=ho();W=Math.max(W,o);let n=u(),t=x();l("heartbeat",{...n&&{visitorUid:n},...t&&{sessionUid:t},path:location.pathname+location.search,scrollDepth:W,isVisible:document.visibilityState==="visible",interactionCount:N}),fo()},xo=()=>{N=0,W=0},lo=()=>{document.addEventListener("click",Y,{passive:!0}),document.addEventListener("scroll",Y,{passive:!0}),document.addEventListener("keydown",Y,{passive:!0}),Z=setInterval(uo,Ho),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")uo()})},P=()=>{if(Z)clearInterval(Z),Z=null};var eo="",so=!1,w=()=>{let o=M(),n=o?location.href:location.pathname+location.search;if(n===eo)return;eo=n,xo();let t=to(),c=u(),r=x(),f=o?location.pathname+location.search+location.hash:location.pathname+location.search;if(l("pageview",{...c&&{visitorUid:c},...r&&{sessionUid:r},hostname:location.hostname,path:f,referrer:document.referrer||void 0,title:document.title||void 0,screenWidth:window.screen?.width,screenHeight:window.screen?.height,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||void 0,language:navigator.language||void 0,utmSource:t.utm_source,utmMedium:t.utm_medium,utmCampaign:t.utm_campaign,utmTerm:t.utm_term,utmContent:t.utm_content,ref:t.ref,source:t.source,via:t.via}),!so){so=!0;let b=E();if(b){let y=JSON.stringify({type:"geo",websiteId:B(),visitorUid:c||void 0,sessionUid:r||void 0});try{fetch(`${b}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:y,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},io=()=>{w();let{pushState:o,replaceState:n}=history;if(history.pushState=function(...t){o.apply(this,t),w()},history.replaceState=function(...t){n.apply(this,t),w()},window.addEventListener("popstate",()=>w()),M())window.addEventListener("hashchange",()=>w())};var bo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t)return;try{let c=new URL(t);if(c.protocol!=="http:"&&c.protocol!=="https:")return;if(c.hostname===location.hostname)return;let r=u(),f=x();if(!r||!f)return;l("exit_click",{visitorUid:r,sessionUid:f,hostname:location.hostname,url:t})}catch{}})};var Go=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,po=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t||!Go.test(t))return;let c=u(),r=x();l("goal",{...c&&{visitorUid:c},...r&&{sessionUid:r},name:"file_download",metadata:{url:t}})})};var p=(o,n)=>{let t=u(),c=x();l("goal",{...t&&{visitorUid:t},...c&&{sessionUid:c},name:o,metadata:n})};var v="data-fs-goal",wo="data-fs-goal-",Mo=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(wo)&&c.name!==v){let r=c.name.slice(wo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},yo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest(`[${v}]`);if(!n)return;let t=n.getAttribute(v);if(!t)return;let c=Mo(n);p(t,c)})};var q="data-fs-scroll",zo="data-fs-scroll-threshold",k="data-fs-scroll-delay",Bo="data-fs-scroll-",Vo=new Set([q,zo,k]),jo=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(Bo)&&!Vo.has(c.name)){let r=c.name.slice(Bo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},mo=()=>{let o=document.querySelectorAll(`[${q}]`);if(!o.length)return;let n=new Set,t=new IntersectionObserver((c)=>{for(let r of c){let f=r.target;if(!r.isIntersecting||n.has(f))continue;let b=f.getAttribute(q);if(!b)continue;let y=parseInt(f.getAttribute(k)||"0",10)||0,e=()=>{if(n.has(f))return;n.add(f),t.unobserve(f);let m=jo(f);p(b,m)};if(y>0)setTimeout(e,y);else e()}},{threshold:0});for(let c of Array.from(o)){let r=parseFloat(c.getAttribute(zo)||"0.5");if(r!==0.5){let f=new IntersectionObserver((b)=>{for(let y of b){let e=y.target;if(!y.isIntersecting||n.has(e))continue;let m=e.getAttribute(q);if(!m)continue;let d=parseInt(e.getAttribute(k)||"0",10)||0,C=()=>{if(n.has(e))return;n.add(e),f.unobserve(e);let Jo=jo(e);p(m,Jo)};if(d>0)setTimeout(C,d);else C()}},{threshold:r});f.observe(c)}else t.observe(c)}};var L=null,Fo=()=>{if(!L)L=new Set(oo());return L},Uo=(o)=>{let n=Fo();if(!n.size)return!1;for(let t of n)if(o===t||o.endsWith(`.${t}`))return!0;return!1},$o=()=>{if(!Fo().size)return;document.addEventListener("click",(n)=>{let t=n.target.closest("a");if(!t)return;let c=t.href;if(!c)return;try{let r=new URL(c);if(r.hostname===location.hostname)return;if(!Uo(r.hostname))return;t.href=z(c)}catch{}})};var X=(o)=>{let n=u(),t=x();l("payment",{...n&&{visitorUid:n},...t&&{sessionUid:t},...o.amount!=null&&{amount:o.amount},...o.currency&&{currency:o.currency},...o.transactionId&&{transactionId:o.transactionId},...o.email&&{email:o.email},...o.name&&{name:o.name},...o.customerId&&{customerId:o.customerId},...o.isRenewal!=null&&{isRenewal:o.isRenewal},...o.isRefund!=null&&{isRefund:o.isRefund}})};var H=(o)=>{let n=u();l("identify",{...n&&{visitorUid:n},userId:o.userId,name:o.name,image:o.image,profileData:o.profileData})};var go=(o)=>{let[n,...t]=o;switch(n){case"identify":H(t[0]);break;case"payment":X(t[0]);break;default:p(n,t[0]);break}},I=()=>{if(D())return;if(!B())return;if(no())return;if(R()&&!O())return;if(T()&&!_())return;if(S()&&!a())return;io(),lo(),bo(),po(),yo(),mo(),$o();let o=window,n=o.flowsery?.q||[];for(let t of n)go(t);o.flowsery=function(...t){go(t)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",I);else I();var hn=async(o)=>{let n=window;return n.__flowsery_config=o,I(),{trackEvent:p,trackPayment:X,trackPageview:w,identify:H,stop:P,reset:K,getTrackingParams:Q,buildCrossDomainUrl:z,getVisitorId:u,getSessionId:x}};export{X as trackPayment,w as trackPageview,p as trackEvent,P as stopHeartbeat,K as reset,hn as initFlowsery,H as identify,u as getVisitorId,Q as getTrackingParams,x as getSessionId,z as buildCrossDomainUrl};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{var{defineProperty:M,getOwnPropertyNames:Zo,getOwnPropertyDescriptor:qo}=Object,Xo=Object.prototype.hasOwnProperty;function Ho(o){return this[o]}var ho=(o)=>{var n=(A??=new WeakMap).get(o),t;if(n)return n;if(n=M({},"__esModule",{value:!0}),o&&typeof o==="object"||typeof o==="function"){for(var c of Zo(o))if(!Xo.call(n,c))M(n,c,{get:Ho.bind(o,c),enumerable:!(t=qo(o,c))||t.enumerable})}return A.set(o,n),n},A;var Go=(o)=>o;function Mo(o,n){this[o]=Go.bind(null,n)}var Vo=(o,n)=>{for(var t in n)M(o,t,{get:n[t],enumerable:!0,configurable:!0,set:Mo.bind(n,t)})};var Eo={};Vo(Eo,{trackPayment:()=>F,trackPageview:()=>w,trackEvent:()=>b,stopHeartbeat:()=>h,reset:()=>q,initFlowsery:()=>Ao,identify:()=>$,getVisitorId:()=>u,getTrackingParams:()=>m,getSessionId:()=>x,buildCrossDomainUrl:()=>j});var V=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o)=>{let n=Math.random()*16|0;return(o==="x"?n:n&3|8).toString(16)})},E=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0},s=()=>{return window.__flowsery_config||null},i=()=>{return document.querySelector("script[data-fl-website-id]")},B=()=>{let o=s();if(o)return o.websiteId;return i()?.getAttribute("data-fl-website-id")||""},R=()=>{let o=s();if(o?.apiBase)return o.apiBase;let n=i();return n?.getAttribute("data-api")||n?.src?.replace(/\/js\/(?:script|main)(?:\.hash)?\.js.*/,"")||""},O=()=>{let o=s();if(o?.analyticsHost)return o.analyticsHost;return i()?.getAttribute("data-fl-host")||null},U=()=>{let o=s();if(o?.domain)return o.domain;return i()?.getAttribute("data-domain")||location.hostname},J=()=>{let o=s();if(o)return!!o.cookieless;return i()?.hasAttribute("data-cookieless")??!1},Uo=new Set(["localhost","127.0.0.1","[::1]"]),T=()=>{return Uo.has(location.hostname)||location.hostname.endsWith(".local")},_=()=>{let o=s();if(o)return!!o.local;return i()?.hasAttribute("data-local")??!1},S=()=>{return location.protocol==="file:"},a=()=>{let o=s();if(o)return!!o.allowFileProtocol;return i()?.hasAttribute("data-allow-file-protocol")??!1},oo=()=>{try{return window.self!==window.top}catch{return!0}},no=()=>{let o=s();if(o)return!!o.allowIframe;return i()?.hasAttribute("data-debug")??!1};var K=()=>{let o=s();if(o)return!!o.hashMode;return i()?.src?.includes(".hash.js")??!1},to=()=>{let o=s();if(o?.allowedHostnames)return o.allowedHostnames;let t=i()?.getAttribute("data-allowed-hostnames");return t?t.split(",").map((c)=>c.trim()).filter(Boolean):[]},co=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},ro=()=>{let o=new URLSearchParams(window.location.search),n={};for(let t of["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref","source","via"]){let c=o.get(t);if(c)n[t]=c}return n};var l=(o,n)=>{let c=`${R()}/api/track`,r=B(),f=JSON.stringify({...n,websiteId:r,type:o});if(typeof navigator.sendBeacon==="function"){let p=new Blob([f],{type:"application/json"});if(navigator.sendBeacon(c,p))return}fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:f,keepalive:!0}).catch(()=>{})};var Q="_fs_vid",W="_fs_sid",z="_fs_sts",Ko=1800000,Y="_fs_vid",N="_fs_sid",Yo=(o)=>{let n=document.cookie.match(new RegExp(`(?:^|; )${o}=([^;]*)`));return n?decodeURIComponent(n[1]):null},fo=(o,n,t)=>{let c=new Date(Date.now()+t*86400000).toUTCString(),r=U(),f=r?`;domain=.${r}`:"";document.cookie=`${o}=${encodeURIComponent(n)};expires=${c};path=/${f};SameSite=Lax;Secure`},No=(o)=>{let n=U(),t=n?`;domain=.${n}`:"";document.cookie=`${o}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${t};SameSite=Lax;Secure`},Po=()=>{let o=new URLSearchParams(window.location.search),n=o.get(Y)||void 0,t=o.get(N)||void 0;if(n||t){o.delete(Y),o.delete(N);let c=o.toString(),r=window.location.pathname+(c?`?${c}`:"")+window.location.hash;history.replaceState(null,"",r)}return{vid:n,sid:t}},Z=null,uo=()=>{if(Z===null)Z=Po();return Z},u=()=>{if(J())return;let o=uo();if(o.vid){fo(Q,o.vid,730);let t=o.vid;return o.vid=void 0,t}let n=Yo(Q);if(!n)n=V(),fo(Q,n,730);return n},x=()=>{if(J())return;let o=uo();if(o.sid){let r=o.sid;return sessionStorage.setItem(W,r),sessionStorage.setItem(z,Date.now().toString()),o.sid=void 0,r}let n=Date.now(),t=parseInt(sessionStorage.getItem(z)||"0",10),c=sessionStorage.getItem(W);if(!c||n-t>Ko)c=V(),sessionStorage.setItem(W,c);return sessionStorage.setItem(z,n.toString()),c},xo=()=>{if(J())return;sessionStorage.setItem(z,Date.now().toString())},m=()=>{let o=u(),n=x();return{...o&&{_fs_vid:o},...n&&{_fs_sid:n}}},j=(o)=>{let n=m(),t=new URL(o);if(n._fs_vid)t.searchParams.set(Y,n._fs_vid);if(n._fs_sid)t.searchParams.set(N,n._fs_sid);return t.toString()},q=()=>{No(Q),sessionStorage.removeItem(W),sessionStorage.removeItem(z),Z=null};var vo=5000,v=0,X=0,H=null,ko=()=>{let o=document.documentElement,n=window.scrollY||o.scrollTop,t=o.scrollHeight-o.clientHeight;if(t<=0)return 100;return Math.min(100,Math.round(n/t*100))},P=()=>{v++},lo=()=>{let o=ko();X=Math.max(X,o);let n=u(),t=x();l("heartbeat",{...n&&{visitorUid:n},...t&&{sessionUid:t},path:location.pathname+location.search,scrollDepth:X,isVisible:document.visibilityState==="visible",interactionCount:v}),xo()},eo=()=>{v=0,X=0},so=()=>{document.addEventListener("click",P,{passive:!0}),document.addEventListener("scroll",P,{passive:!0}),document.addEventListener("keydown",P,{passive:!0}),H=setInterval(lo,vo),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")lo()})},h=()=>{if(H)clearInterval(H),H=null};var io="",bo=!1,w=()=>{let o=K(),n=o?location.href:location.pathname+location.search;if(n===io)return;io=n,eo();let t=ro(),c=u(),r=x(),f=o?location.pathname+location.search+location.hash:location.pathname+location.search;if(l("pageview",{...c&&{visitorUid:c},...r&&{sessionUid:r},hostname:location.hostname,path:f,referrer:document.referrer||void 0,title:document.title||void 0,screenWidth:window.screen?.width,screenHeight:window.screen?.height,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||void 0,language:navigator.language||void 0,utmSource:t.utm_source,utmMedium:t.utm_medium,utmCampaign:t.utm_campaign,utmTerm:t.utm_term,utmContent:t.utm_content,ref:t.ref,source:t.source,via:t.via}),!bo){bo=!0;let p=O();if(p){let y=JSON.stringify({type:"geo",websiteId:B(),visitorUid:c||void 0,sessionUid:r||void 0});try{fetch(`${p}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:y,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},po=()=>{w();let{pushState:o,replaceState:n}=history;if(history.pushState=function(...t){o.apply(this,t),w()},history.replaceState=function(...t){n.apply(this,t),w()},window.addEventListener("popstate",()=>w()),K())window.addEventListener("hashchange",()=>w())};var wo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t)return;try{let c=new URL(t);if(c.protocol!=="http:"&&c.protocol!=="https:")return;if(c.hostname===location.hostname)return;let r=u(),f=x();if(!r||!f)return;l("exit_click",{visitorUid:r,sessionUid:f,hostname:location.hostname,url:t})}catch{}})};var Lo=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,yo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t||!Lo.test(t))return;let c=u(),r=x();l("goal",{...c&&{visitorUid:c},...r&&{sessionUid:r},name:"file_download",metadata:{url:t}})})};var b=(o,n)=>{let t=u(),c=x();l("goal",{...t&&{visitorUid:t},...c&&{sessionUid:c},name:o,metadata:n})};var k="data-fs-goal",Bo="data-fs-goal-",Io=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(Bo)&&c.name!==k){let r=c.name.slice(Bo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},jo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest(`[${k}]`);if(!n)return;let t=n.getAttribute(k);if(!t)return;let c=Io(n);b(t,c)})};var G="data-fs-scroll",Fo="data-fs-scroll-threshold",L="data-fs-scroll-delay",zo="data-fs-scroll-",Co=new Set([G,Fo,L]),mo=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(zo)&&!Co.has(c.name)){let r=c.name.slice(zo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},$o=()=>{let o=document.querySelectorAll(`[${G}]`);if(!o.length)return;let n=new Set,t=new IntersectionObserver((c)=>{for(let r of c){let f=r.target;if(!r.isIntersecting||n.has(f))continue;let p=f.getAttribute(G);if(!p)continue;let y=parseInt(f.getAttribute(L)||"0",10)||0,e=()=>{if(n.has(f))return;n.add(f),t.unobserve(f);let g=mo(f);b(p,g)};if(y>0)setTimeout(e,y);else e()}},{threshold:0});for(let c of Array.from(o)){let r=parseFloat(c.getAttribute(Fo)||"0.5");if(r!==0.5){let f=new IntersectionObserver((p)=>{for(let y of p){let e=y.target;if(!y.isIntersecting||n.has(e))continue;let g=e.getAttribute(G);if(!g)continue;let C=parseInt(e.getAttribute(L)||"0",10)||0,D=()=>{if(n.has(e))return;n.add(e),f.unobserve(e);let Wo=mo(e);b(g,Wo)};if(C>0)setTimeout(D,C);else D()}},{threshold:r});f.observe(c)}else t.observe(c)}};var I=null,go=()=>{if(!I)I=new Set(to());return I},Do=(o)=>{let n=go();if(!n.size)return!1;for(let t of n)if(o===t||o.endsWith(`.${t}`))return!0;return!1},Jo=()=>{if(!go().size)return;document.addEventListener("click",(n)=>{let t=n.target.closest("a");if(!t)return;let c=t.href;if(!c)return;try{let r=new URL(c);if(r.hostname===location.hostname)return;if(!Do(r.hostname))return;t.href=j(c)}catch{}})};var F=(o)=>{let n=u(),t=x();l("payment",{...n&&{visitorUid:n},...t&&{sessionUid:t},...o.amount!=null&&{amount:o.amount},...o.currency&&{currency:o.currency},...o.transactionId&&{transactionId:o.transactionId},...o.email&&{email:o.email},...o.name&&{name:o.name},...o.customerId&&{customerId:o.customerId},...o.isRenewal!=null&&{isRenewal:o.isRenewal},...o.isRefund!=null&&{isRefund:o.isRefund}})};var $=(o)=>{let n=u();l("identify",{...n&&{visitorUid:n},userId:o.userId,name:o.name,image:o.image,profileData:o.profileData})};var Qo=(o)=>{let[n,...t]=o;switch(n){case"identify":$(t[0]);break;case"payment":F(t[0]);break;default:b(n,t[0]);break}},d=()=>{if(E())return;if(!B())return;if(co())return;if(T()&&!_())return;if(S()&&!a())return;if(oo()&&!no())return;po(),so(),wo(),yo(),jo(),$o(),Jo();let o=window,n=o.flowsery?.q||[];for(let t of n)Qo(t);o.flowsery=function(...t){Qo(t)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",d);else d();var Ao=async(o)=>{let n=window;return n.__flowsery_config=o,d(),{trackEvent:b,trackPayment:F,trackPageview:w,identify:$,stop:h,reset:q,getTrackingParams:m,buildCrossDomainUrl:j,getVisitorId:u,getSessionId:x}};})();
|
package/dist/main.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{var{defineProperty:M,getOwnPropertyNames:Zo,getOwnPropertyDescriptor:qo}=Object,Xo=Object.prototype.hasOwnProperty;function Ho(o){return this[o]}var ho=(o)=>{var n=(A??=new WeakMap).get(o),t;if(n)return n;if(n=M({},"__esModule",{value:!0}),o&&typeof o==="object"||typeof o==="function"){for(var c of Zo(o))if(!Xo.call(n,c))M(n,c,{get:Ho.bind(o,c),enumerable:!(t=qo(o,c))||t.enumerable})}return A.set(o,n),n},A;var Go=(o)=>o;function Mo(o,n){this[o]=Go.bind(null,n)}var Vo=(o,n)=>{for(var t in n)M(o,t,{get:n[t],enumerable:!0,configurable:!0,set:Mo.bind(n,t)})};var Eo={};Vo(Eo,{trackPayment:()=>F,trackPageview:()=>w,trackEvent:()=>b,stopHeartbeat:()=>h,reset:()=>q,initFlowsery:()=>Ao,identify:()=>$,getVisitorId:()=>u,getTrackingParams:()=>m,getSessionId:()=>x,buildCrossDomainUrl:()=>j});var V=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o)=>{let n=Math.random()*16|0;return(o==="x"?n:n&3|8).toString(16)})},E=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0},s=()=>{return window.__flowsery_config||null},i=()=>{return document.querySelector("script[data-fl-website-id]")},B=()=>{let o=s();if(o)return o.websiteId;return i()?.getAttribute("data-fl-website-id")||""},R=()=>{let o=s();if(o?.apiBase)return o.apiBase;let n=i();return n?.getAttribute("data-api")||n?.src?.replace(/\/js\/(?:script|main)(?:\.hash)?\.js.*/,"")||""},O=()=>{let o=s();if(o?.analyticsHost)return o.analyticsHost;return i()?.getAttribute("data-fl-host")||null},U=()=>{let o=s();if(o?.domain)return o.domain;return i()?.getAttribute("data-domain")||location.hostname},J=()=>{let o=s();if(o)return!!o.cookieless;return i()?.hasAttribute("data-cookieless")??!1},Uo=new Set(["localhost","127.0.0.1","[::1]"]),T=()=>{return Uo.has(location.hostname)||location.hostname.endsWith(".local")},_=()=>{let o=s();if(o)return!!o.local;return i()?.hasAttribute("data-local")??!1},S=()=>{return location.protocol==="file:"},a=()=>{let o=s();if(o)return!!o.allowFileProtocol;return i()?.hasAttribute("data-allow-file-protocol")??!1},oo=()=>{try{return window.self!==window.top}catch{return!0}},no=()=>{let o=s();if(o)return!!o.allowIframe;return i()?.hasAttribute("data-debug")??!1};var K=()=>{let o=s();if(o)return!!o.hashMode;return i()?.src?.includes(".hash.js")??!1},to=()=>{let o=s();if(o?.allowedHostnames)return o.allowedHostnames;let t=i()?.getAttribute("data-allowed-hostnames");return t?t.split(",").map((c)=>c.trim()).filter(Boolean):[]},co=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},ro=()=>{let o=new URLSearchParams(window.location.search),n={};for(let t of["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref","source","via"]){let c=o.get(t);if(c)n[t]=c}return n};var l=(o,n)=>{let c=`${R()}/api/track`,r=B(),f=JSON.stringify({...n,websiteId:r,type:o});if(typeof navigator.sendBeacon==="function"){let p=new Blob([f],{type:"application/json"});if(navigator.sendBeacon(c,p))return}fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:f,keepalive:!0}).catch(()=>{})};var Q="_fs_vid",W="_fs_sid",z="_fs_sts",Ko=1800000,Y="_fs_vid",N="_fs_sid",Yo=(o)=>{let n=document.cookie.match(new RegExp(`(?:^|; )${o}=([^;]*)`));return n?decodeURIComponent(n[1]):null},fo=(o,n,t)=>{let c=new Date(Date.now()+t*86400000).toUTCString(),r=U(),f=r?`;domain=.${r}`:"";document.cookie=`${o}=${encodeURIComponent(n)};expires=${c};path=/${f};SameSite=Lax;Secure`},No=(o)=>{let n=U(),t=n?`;domain=.${n}`:"";document.cookie=`${o}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${t};SameSite=Lax;Secure`},Po=()=>{let o=new URLSearchParams(window.location.search),n=o.get(Y)||void 0,t=o.get(N)||void 0;if(n||t){o.delete(Y),o.delete(N);let c=o.toString(),r=window.location.pathname+(c?`?${c}`:"")+window.location.hash;history.replaceState(null,"",r)}return{vid:n,sid:t}},Z=null,uo=()=>{if(Z===null)Z=Po();return Z},u=()=>{if(J())return;let o=uo();if(o.vid){fo(Q,o.vid,730);let t=o.vid;return o.vid=void 0,t}let n=Yo(Q);if(!n)n=V(),fo(Q,n,730);return n},x=()=>{if(J())return;let o=uo();if(o.sid){let r=o.sid;return sessionStorage.setItem(W,r),sessionStorage.setItem(z,Date.now().toString()),o.sid=void 0,r}let n=Date.now(),t=parseInt(sessionStorage.getItem(z)||"0",10),c=sessionStorage.getItem(W);if(!c||n-t>Ko)c=V(),sessionStorage.setItem(W,c);return sessionStorage.setItem(z,n.toString()),c},xo=()=>{if(J())return;sessionStorage.setItem(z,Date.now().toString())},m=()=>{let o=u(),n=x();return{...o&&{_fs_vid:o},...n&&{_fs_sid:n}}},j=(o)=>{let n=m(),t=new URL(o);if(n._fs_vid)t.searchParams.set(Y,n._fs_vid);if(n._fs_sid)t.searchParams.set(N,n._fs_sid);return t.toString()},q=()=>{No(Q),sessionStorage.removeItem(W),sessionStorage.removeItem(z),Z=null};var vo=5000,v=0,X=0,H=null,ko=()=>{let o=document.documentElement,n=window.scrollY||o.scrollTop,t=o.scrollHeight-o.clientHeight;if(t<=0)return 100;return Math.min(100,Math.round(n/t*100))},P=()=>{v++},lo=()=>{let o=ko();X=Math.max(X,o);let n=u(),t=x();l("heartbeat",{...n&&{visitorUid:n},...t&&{sessionUid:t},path:location.pathname+location.search,scrollDepth:X,isVisible:document.visibilityState==="visible",interactionCount:v}),xo()},eo=()=>{v=0,X=0},so=()=>{document.addEventListener("click",P,{passive:!0}),document.addEventListener("scroll",P,{passive:!0}),document.addEventListener("keydown",P,{passive:!0}),H=setInterval(lo,vo),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")lo()})},h=()=>{if(H)clearInterval(H),H=null};var io="",bo=!1,w=()=>{let o=K(),n=o?location.href:location.pathname+location.search;if(n===io)return;io=n,eo();let t=ro(),c=u(),r=x(),f=o?location.pathname+location.search+location.hash:location.pathname+location.search;if(l("pageview",{...c&&{visitorUid:c},...r&&{sessionUid:r},hostname:location.hostname,path:f,referrer:document.referrer||void 0,title:document.title||void 0,screenWidth:window.screen?.width,screenHeight:window.screen?.height,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||void 0,language:navigator.language||void 0,utmSource:t.utm_source,utmMedium:t.utm_medium,utmCampaign:t.utm_campaign,utmTerm:t.utm_term,utmContent:t.utm_content,ref:t.ref,source:t.source,via:t.via}),!bo){bo=!0;let p=O();if(p){let y=JSON.stringify({type:"geo",websiteId:B(),visitorUid:c||void 0,sessionUid:r||void 0});try{fetch(`${p}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:y,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},po=()=>{w();let{pushState:o,replaceState:n}=history;if(history.pushState=function(...t){o.apply(this,t),w()},history.replaceState=function(...t){n.apply(this,t),w()},window.addEventListener("popstate",()=>w()),K())window.addEventListener("hashchange",()=>w())};var wo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t)return;try{let c=new URL(t);if(c.protocol!=="http:"&&c.protocol!=="https:")return;if(c.hostname===location.hostname)return;let r=u(),f=x();if(!r||!f)return;l("exit_click",{visitorUid:r,sessionUid:f,hostname:location.hostname,url:t})}catch{}})};var Lo=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,yo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t||!Lo.test(t))return;let c=u(),r=x();l("goal",{...c&&{visitorUid:c},...r&&{sessionUid:r},name:"file_download",metadata:{url:t}})})};var b=(o,n)=>{let t=u(),c=x();l("goal",{...t&&{visitorUid:t},...c&&{sessionUid:c},name:o,metadata:n})};var k="data-fs-goal",Bo="data-fs-goal-",Io=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(Bo)&&c.name!==k){let r=c.name.slice(Bo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},jo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest(`[${k}]`);if(!n)return;let t=n.getAttribute(k);if(!t)return;let c=Io(n);b(t,c)})};var G="data-fs-scroll",Fo="data-fs-scroll-threshold",L="data-fs-scroll-delay",zo="data-fs-scroll-",Co=new Set([G,Fo,L]),mo=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(zo)&&!Co.has(c.name)){let r=c.name.slice(zo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},$o=()=>{let o=document.querySelectorAll(`[${G}]`);if(!o.length)return;let n=new Set,t=new IntersectionObserver((c)=>{for(let r of c){let f=r.target;if(!r.isIntersecting||n.has(f))continue;let p=f.getAttribute(G);if(!p)continue;let y=parseInt(f.getAttribute(L)||"0",10)||0,e=()=>{if(n.has(f))return;n.add(f),t.unobserve(f);let g=mo(f);b(p,g)};if(y>0)setTimeout(e,y);else e()}},{threshold:0});for(let c of Array.from(o)){let r=parseFloat(c.getAttribute(Fo)||"0.5");if(r!==0.5){let f=new IntersectionObserver((p)=>{for(let y of p){let e=y.target;if(!y.isIntersecting||n.has(e))continue;let g=e.getAttribute(G);if(!g)continue;let C=parseInt(e.getAttribute(L)||"0",10)||0,D=()=>{if(n.has(e))return;n.add(e),f.unobserve(e);let Wo=mo(e);b(g,Wo)};if(C>0)setTimeout(D,C);else D()}},{threshold:r});f.observe(c)}else t.observe(c)}};var I=null,go=()=>{if(!I)I=new Set(to());return I},Do=(o)=>{let n=go();if(!n.size)return!1;for(let t of n)if(o===t||o.endsWith(`.${t}`))return!0;return!1},Jo=()=>{if(!go().size)return;document.addEventListener("click",(n)=>{let t=n.target.closest("a");if(!t)return;let c=t.href;if(!c)return;try{let r=new URL(c);if(r.hostname===location.hostname)return;if(!Do(r.hostname))return;t.href=j(c)}catch{}})};var F=(o)=>{let n=u(),t=x();l("payment",{...n&&{visitorUid:n},...t&&{sessionUid:t},...o.amount!=null&&{amount:o.amount},...o.currency&&{currency:o.currency},...o.transactionId&&{transactionId:o.transactionId},...o.email&&{email:o.email},...o.name&&{name:o.name},...o.customerId&&{customerId:o.customerId},...o.isRenewal!=null&&{isRenewal:o.isRenewal},...o.isRefund!=null&&{isRefund:o.isRefund}})};var $=(o)=>{let n=u();l("identify",{...n&&{visitorUid:n},userId:o.userId,name:o.name,image:o.image,profileData:o.profileData})};var Qo=(o)=>{let[n,...t]=o;switch(n){case"identify":$(t[0]);break;case"payment":F(t[0]);break;default:b(n,t[0]);break}},d=()=>{if(E())return;if(!B())return;if(co())return;if(T()&&!_())return;if(S()&&!a())return;if(oo()&&!no())return;po(),so(),wo(),yo(),jo(),$o(),Jo();let o=window,n=o.flowsery?.q||[];for(let t of n)Qo(t);o.flowsery=function(...t){Qo(t)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",d);else d();var Ao=async(o)=>{let n=window;return n.__flowsery_config=o,d(),{trackEvent:b,trackPayment:F,trackPageview:w,identify:$,stop:h,reset:q,getTrackingParams:m,buildCrossDomainUrl:j,getVisitorId:u,getSessionId:x}};})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{var{defineProperty:M,getOwnPropertyNames:Zo,getOwnPropertyDescriptor:qo}=Object,Xo=Object.prototype.hasOwnProperty;function Ho(o){return this[o]}var ho=(o)=>{var n=(A??=new WeakMap).get(o),t;if(n)return n;if(n=M({},"__esModule",{value:!0}),o&&typeof o==="object"||typeof o==="function"){for(var c of Zo(o))if(!Xo.call(n,c))M(n,c,{get:Ho.bind(o,c),enumerable:!(t=qo(o,c))||t.enumerable})}return A.set(o,n),n},A;var Go=(o)=>o;function Mo(o,n){this[o]=Go.bind(null,n)}var Vo=(o,n)=>{for(var t in n)M(o,t,{get:n[t],enumerable:!0,configurable:!0,set:Mo.bind(n,t)})};var Eo={};Vo(Eo,{trackPayment:()=>F,trackPageview:()=>w,trackEvent:()=>b,stopHeartbeat:()=>h,reset:()=>q,initFlowsery:()=>Ao,identify:()=>$,getVisitorId:()=>u,getTrackingParams:()=>m,getSessionId:()=>x,buildCrossDomainUrl:()=>j});var V=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o)=>{let n=Math.random()*16|0;return(o==="x"?n:n&3|8).toString(16)})},E=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0},s=()=>{return window.__flowsery_config||null},i=()=>{return document.querySelector("script[data-fl-website-id]")},B=()=>{let o=s();if(o)return o.websiteId;return i()?.getAttribute("data-fl-website-id")||""},R=()=>{let o=s();if(o?.apiBase)return o.apiBase;let n=i();return n?.getAttribute("data-api")||n?.src?.replace(/\/js\/(?:script|main)(?:\.hash)?\.js.*/,"")||""},O=()=>{let o=s();if(o?.analyticsHost)return o.analyticsHost;return i()?.getAttribute("data-fl-host")||null},U=()=>{let o=s();if(o?.domain)return o.domain;return i()?.getAttribute("data-domain")||location.hostname},J=()=>{let o=s();if(o)return!!o.cookieless;return i()?.hasAttribute("data-cookieless")??!1},Uo=new Set(["localhost","127.0.0.1","[::1]"]),T=()=>{return Uo.has(location.hostname)||location.hostname.endsWith(".local")},_=()=>{let o=s();if(o)return!!o.local;return i()?.hasAttribute("data-local")??!1},S=()=>{return location.protocol==="file:"},a=()=>{let o=s();if(o)return!!o.allowFileProtocol;return i()?.hasAttribute("data-allow-file-protocol")??!1},oo=()=>{try{return window.self!==window.top}catch{return!0}},no=()=>{let o=s();if(o)return!!o.allowIframe;return i()?.hasAttribute("data-debug")??!1};var K=()=>{let o=s();if(o)return!!o.hashMode;return i()?.src?.includes(".hash.js")??!1},to=()=>{let o=s();if(o?.allowedHostnames)return o.allowedHostnames;let t=i()?.getAttribute("data-allowed-hostnames");return t?t.split(",").map((c)=>c.trim()).filter(Boolean):[]},co=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},ro=()=>{let o=new URLSearchParams(window.location.search),n={};for(let t of["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref","source","via"]){let c=o.get(t);if(c)n[t]=c}return n};var l=(o,n)=>{let c=`${R()}/api/track`,r=B(),f=JSON.stringify({...n,websiteId:r,type:o});if(typeof navigator.sendBeacon==="function"){let p=new Blob([f],{type:"application/json"});if(navigator.sendBeacon(c,p))return}fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:f,keepalive:!0}).catch(()=>{})};var Q="_fs_vid",W="_fs_sid",z="_fs_sts",Ko=1800000,Y="_fs_vid",N="_fs_sid",Yo=(o)=>{let n=document.cookie.match(new RegExp(`(?:^|; )${o}=([^;]*)`));return n?decodeURIComponent(n[1]):null},fo=(o,n,t)=>{let c=new Date(Date.now()+t*86400000).toUTCString(),r=U(),f=r?`;domain=.${r}`:"";document.cookie=`${o}=${encodeURIComponent(n)};expires=${c};path=/${f};SameSite=Lax;Secure`},No=(o)=>{let n=U(),t=n?`;domain=.${n}`:"";document.cookie=`${o}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${t};SameSite=Lax;Secure`},Po=()=>{let o=new URLSearchParams(window.location.search),n=o.get(Y)||void 0,t=o.get(N)||void 0;if(n||t){o.delete(Y),o.delete(N);let c=o.toString(),r=window.location.pathname+(c?`?${c}`:"")+window.location.hash;history.replaceState(null,"",r)}return{vid:n,sid:t}},Z=null,uo=()=>{if(Z===null)Z=Po();return Z},u=()=>{if(J())return;let o=uo();if(o.vid){fo(Q,o.vid,730);let t=o.vid;return o.vid=void 0,t}let n=Yo(Q);if(!n)n=V(),fo(Q,n,730);return n},x=()=>{if(J())return;let o=uo();if(o.sid){let r=o.sid;return sessionStorage.setItem(W,r),sessionStorage.setItem(z,Date.now().toString()),o.sid=void 0,r}let n=Date.now(),t=parseInt(sessionStorage.getItem(z)||"0",10),c=sessionStorage.getItem(W);if(!c||n-t>Ko)c=V(),sessionStorage.setItem(W,c);return sessionStorage.setItem(z,n.toString()),c},xo=()=>{if(J())return;sessionStorage.setItem(z,Date.now().toString())},m=()=>{let o=u(),n=x();return{...o&&{_fs_vid:o},...n&&{_fs_sid:n}}},j=(o)=>{let n=m(),t=new URL(o);if(n._fs_vid)t.searchParams.set(Y,n._fs_vid);if(n._fs_sid)t.searchParams.set(N,n._fs_sid);return t.toString()},q=()=>{No(Q),sessionStorage.removeItem(W),sessionStorage.removeItem(z),Z=null};var vo=5000,v=0,X=0,H=null,ko=()=>{let o=document.documentElement,n=window.scrollY||o.scrollTop,t=o.scrollHeight-o.clientHeight;if(t<=0)return 100;return Math.min(100,Math.round(n/t*100))},P=()=>{v++},lo=()=>{let o=ko();X=Math.max(X,o);let n=u(),t=x();l("heartbeat",{...n&&{visitorUid:n},...t&&{sessionUid:t},path:location.pathname+location.search,scrollDepth:X,isVisible:document.visibilityState==="visible",interactionCount:v}),xo()},eo=()=>{v=0,X=0},so=()=>{document.addEventListener("click",P,{passive:!0}),document.addEventListener("scroll",P,{passive:!0}),document.addEventListener("keydown",P,{passive:!0}),H=setInterval(lo,vo),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")lo()})},h=()=>{if(H)clearInterval(H),H=null};var io="",bo=!1,w=()=>{let o=K(),n=o?location.href:location.pathname+location.search;if(n===io)return;io=n,eo();let t=ro(),c=u(),r=x(),f=o?location.pathname+location.search+location.hash:location.pathname+location.search;if(l("pageview",{...c&&{visitorUid:c},...r&&{sessionUid:r},hostname:location.hostname,path:f,referrer:document.referrer||void 0,title:document.title||void 0,screenWidth:window.screen?.width,screenHeight:window.screen?.height,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||void 0,language:navigator.language||void 0,utmSource:t.utm_source,utmMedium:t.utm_medium,utmCampaign:t.utm_campaign,utmTerm:t.utm_term,utmContent:t.utm_content,ref:t.ref,source:t.source,via:t.via}),!bo){bo=!0;let p=O();if(p){let y=JSON.stringify({type:"geo",websiteId:B(),visitorUid:c||void 0,sessionUid:r||void 0});try{fetch(`${p}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:y,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},po=()=>{w();let{pushState:o,replaceState:n}=history;if(history.pushState=function(...t){o.apply(this,t),w()},history.replaceState=function(...t){n.apply(this,t),w()},window.addEventListener("popstate",()=>w()),K())window.addEventListener("hashchange",()=>w())};var wo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t)return;try{let c=new URL(t);if(c.protocol!=="http:"&&c.protocol!=="https:")return;if(c.hostname===location.hostname)return;let r=u(),f=x();if(!r||!f)return;l("exit_click",{visitorUid:r,sessionUid:f,hostname:location.hostname,url:t})}catch{}})};var Lo=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,yo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t||!Lo.test(t))return;let c=u(),r=x();l("goal",{...c&&{visitorUid:c},...r&&{sessionUid:r},name:"file_download",metadata:{url:t}})})};var b=(o,n)=>{let t=u(),c=x();l("goal",{...t&&{visitorUid:t},...c&&{sessionUid:c},name:o,metadata:n})};var k="data-fs-goal",Bo="data-fs-goal-",Io=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(Bo)&&c.name!==k){let r=c.name.slice(Bo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},jo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest(`[${k}]`);if(!n)return;let t=n.getAttribute(k);if(!t)return;let c=Io(n);b(t,c)})};var G="data-fs-scroll",Fo="data-fs-scroll-threshold",L="data-fs-scroll-delay",zo="data-fs-scroll-",Co=new Set([G,Fo,L]),mo=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(zo)&&!Co.has(c.name)){let r=c.name.slice(zo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},$o=()=>{let o=document.querySelectorAll(`[${G}]`);if(!o.length)return;let n=new Set,t=new IntersectionObserver((c)=>{for(let r of c){let f=r.target;if(!r.isIntersecting||n.has(f))continue;let p=f.getAttribute(G);if(!p)continue;let y=parseInt(f.getAttribute(L)||"0",10)||0,e=()=>{if(n.has(f))return;n.add(f),t.unobserve(f);let g=mo(f);b(p,g)};if(y>0)setTimeout(e,y);else e()}},{threshold:0});for(let c of Array.from(o)){let r=parseFloat(c.getAttribute(Fo)||"0.5");if(r!==0.5){let f=new IntersectionObserver((p)=>{for(let y of p){let e=y.target;if(!y.isIntersecting||n.has(e))continue;let g=e.getAttribute(G);if(!g)continue;let C=parseInt(e.getAttribute(L)||"0",10)||0,D=()=>{if(n.has(e))return;n.add(e),f.unobserve(e);let Wo=mo(e);b(g,Wo)};if(C>0)setTimeout(D,C);else D()}},{threshold:r});f.observe(c)}else t.observe(c)}};var I=null,go=()=>{if(!I)I=new Set(to());return I},Do=(o)=>{let n=go();if(!n.size)return!1;for(let t of n)if(o===t||o.endsWith(`.${t}`))return!0;return!1},Jo=()=>{if(!go().size)return;document.addEventListener("click",(n)=>{let t=n.target.closest("a");if(!t)return;let c=t.href;if(!c)return;try{let r=new URL(c);if(r.hostname===location.hostname)return;if(!Do(r.hostname))return;t.href=j(c)}catch{}})};var F=(o)=>{let n=u(),t=x();l("payment",{...n&&{visitorUid:n},...t&&{sessionUid:t},...o.amount!=null&&{amount:o.amount},...o.currency&&{currency:o.currency},...o.transactionId&&{transactionId:o.transactionId},...o.email&&{email:o.email},...o.name&&{name:o.name},...o.customerId&&{customerId:o.customerId},...o.isRenewal!=null&&{isRenewal:o.isRenewal},...o.isRefund!=null&&{isRefund:o.isRefund}})};var $=(o)=>{let n=u();l("identify",{...n&&{visitorUid:n},userId:o.userId,name:o.name,image:o.image,profileData:o.profileData})};var Qo=(o)=>{let[n,...t]=o;switch(n){case"identify":$(t[0]);break;case"payment":F(t[0]);break;default:b(n,t[0]);break}},d=()=>{if(E())return;if(!B())return;if(co())return;if(T()&&!_())return;if(S()&&!a())return;if(oo()&&!no())return;po(),so(),wo(),yo(),jo(),$o(),Jo();let o=window,n=o.flowsery?.q||[];for(let t of n)Qo(t);o.flowsery=function(...t){Qo(t)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",d);else d();var Ao=async(o)=>{let n=window;return n.__flowsery_config=o,d(),{trackEvent:b,trackPayment:F,trackPageview:w,identify:$,stop:h,reset:q,getTrackingParams:m,buildCrossDomainUrl:j,getVisitorId:u,getSessionId:x}};})();
|
package/dist/script.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{var{defineProperty:M,getOwnPropertyNames:Zo,getOwnPropertyDescriptor:qo}=Object,Xo=Object.prototype.hasOwnProperty;function Ho(o){return this[o]}var ho=(o)=>{var n=(A??=new WeakMap).get(o),t;if(n)return n;if(n=M({},"__esModule",{value:!0}),o&&typeof o==="object"||typeof o==="function"){for(var c of Zo(o))if(!Xo.call(n,c))M(n,c,{get:Ho.bind(o,c),enumerable:!(t=qo(o,c))||t.enumerable})}return A.set(o,n),n},A;var Go=(o)=>o;function Mo(o,n){this[o]=Go.bind(null,n)}var Vo=(o,n)=>{for(var t in n)M(o,t,{get:n[t],enumerable:!0,configurable:!0,set:Mo.bind(n,t)})};var Eo={};Vo(Eo,{trackPayment:()=>F,trackPageview:()=>w,trackEvent:()=>b,stopHeartbeat:()=>h,reset:()=>q,initFlowsery:()=>Ao,identify:()=>$,getVisitorId:()=>u,getTrackingParams:()=>m,getSessionId:()=>x,buildCrossDomainUrl:()=>j});var V=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o)=>{let n=Math.random()*16|0;return(o==="x"?n:n&3|8).toString(16)})},E=()=>{if(typeof navigator>"u")return!0;return"webdriver"in navigator&&navigator.webdriver===!0},s=()=>{return window.__flowsery_config||null},i=()=>{return document.querySelector("script[data-fl-website-id]")},B=()=>{let o=s();if(o)return o.websiteId;return i()?.getAttribute("data-fl-website-id")||""},R=()=>{let o=s();if(o?.apiBase)return o.apiBase;let n=i();return n?.getAttribute("data-api")||n?.src?.replace(/\/js\/(?:script|main)(?:\.hash)?\.js.*/,"")||""},O=()=>{let o=s();if(o?.analyticsHost)return o.analyticsHost;return i()?.getAttribute("data-fl-host")||null},U=()=>{let o=s();if(o?.domain)return o.domain;return i()?.getAttribute("data-domain")||location.hostname},J=()=>{let o=s();if(o)return!!o.cookieless;return i()?.hasAttribute("data-cookieless")??!1},Uo=new Set(["localhost","127.0.0.1","[::1]"]),T=()=>{return Uo.has(location.hostname)||location.hostname.endsWith(".local")},_=()=>{let o=s();if(o)return!!o.local;return i()?.hasAttribute("data-local")??!1},S=()=>{return location.protocol==="file:"},a=()=>{let o=s();if(o)return!!o.allowFileProtocol;return i()?.hasAttribute("data-allow-file-protocol")??!1},oo=()=>{try{return window.self!==window.top}catch{return!0}},no=()=>{let o=s();if(o)return!!o.allowIframe;return i()?.hasAttribute("data-debug")??!1};var K=()=>{let o=s();if(o)return!!o.hashMode;return i()?.src?.includes(".hash.js")??!1},to=()=>{let o=s();if(o?.allowedHostnames)return o.allowedHostnames;let t=i()?.getAttribute("data-allowed-hostnames");return t?t.split(",").map((c)=>c.trim()).filter(Boolean):[]},co=()=>{try{return localStorage.getItem("flowsery_ignore")==="true"}catch{return!1}},ro=()=>{let o=new URLSearchParams(window.location.search),n={};for(let t of["utm_source","utm_medium","utm_campaign","utm_term","utm_content","ref","source","via"]){let c=o.get(t);if(c)n[t]=c}return n};var l=(o,n)=>{let c=`${R()}/api/track`,r=B(),f=JSON.stringify({...n,websiteId:r,type:o});if(typeof navigator.sendBeacon==="function"){let p=new Blob([f],{type:"application/json"});if(navigator.sendBeacon(c,p))return}fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:f,keepalive:!0}).catch(()=>{})};var Q="_fs_vid",W="_fs_sid",z="_fs_sts",Ko=1800000,Y="_fs_vid",N="_fs_sid",Yo=(o)=>{let n=document.cookie.match(new RegExp(`(?:^|; )${o}=([^;]*)`));return n?decodeURIComponent(n[1]):null},fo=(o,n,t)=>{let c=new Date(Date.now()+t*86400000).toUTCString(),r=U(),f=r?`;domain=.${r}`:"";document.cookie=`${o}=${encodeURIComponent(n)};expires=${c};path=/${f};SameSite=Lax;Secure`},No=(o)=>{let n=U(),t=n?`;domain=.${n}`:"";document.cookie=`${o}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${t};SameSite=Lax;Secure`},Po=()=>{let o=new URLSearchParams(window.location.search),n=o.get(Y)||void 0,t=o.get(N)||void 0;if(n||t){o.delete(Y),o.delete(N);let c=o.toString(),r=window.location.pathname+(c?`?${c}`:"")+window.location.hash;history.replaceState(null,"",r)}return{vid:n,sid:t}},Z=null,uo=()=>{if(Z===null)Z=Po();return Z},u=()=>{if(J())return;let o=uo();if(o.vid){fo(Q,o.vid,730);let t=o.vid;return o.vid=void 0,t}let n=Yo(Q);if(!n)n=V(),fo(Q,n,730);return n},x=()=>{if(J())return;let o=uo();if(o.sid){let r=o.sid;return sessionStorage.setItem(W,r),sessionStorage.setItem(z,Date.now().toString()),o.sid=void 0,r}let n=Date.now(),t=parseInt(sessionStorage.getItem(z)||"0",10),c=sessionStorage.getItem(W);if(!c||n-t>Ko)c=V(),sessionStorage.setItem(W,c);return sessionStorage.setItem(z,n.toString()),c},xo=()=>{if(J())return;sessionStorage.setItem(z,Date.now().toString())},m=()=>{let o=u(),n=x();return{...o&&{_fs_vid:o},...n&&{_fs_sid:n}}},j=(o)=>{let n=m(),t=new URL(o);if(n._fs_vid)t.searchParams.set(Y,n._fs_vid);if(n._fs_sid)t.searchParams.set(N,n._fs_sid);return t.toString()},q=()=>{No(Q),sessionStorage.removeItem(W),sessionStorage.removeItem(z),Z=null};var vo=5000,v=0,X=0,H=null,ko=()=>{let o=document.documentElement,n=window.scrollY||o.scrollTop,t=o.scrollHeight-o.clientHeight;if(t<=0)return 100;return Math.min(100,Math.round(n/t*100))},P=()=>{v++},lo=()=>{let o=ko();X=Math.max(X,o);let n=u(),t=x();l("heartbeat",{...n&&{visitorUid:n},...t&&{sessionUid:t},path:location.pathname+location.search,scrollDepth:X,isVisible:document.visibilityState==="visible",interactionCount:v}),xo()},eo=()=>{v=0,X=0},so=()=>{document.addEventListener("click",P,{passive:!0}),document.addEventListener("scroll",P,{passive:!0}),document.addEventListener("keydown",P,{passive:!0}),H=setInterval(lo,vo),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")lo()})},h=()=>{if(H)clearInterval(H),H=null};var io="",bo=!1,w=()=>{let o=K(),n=o?location.href:location.pathname+location.search;if(n===io)return;io=n,eo();let t=ro(),c=u(),r=x(),f=o?location.pathname+location.search+location.hash:location.pathname+location.search;if(l("pageview",{...c&&{visitorUid:c},...r&&{sessionUid:r},hostname:location.hostname,path:f,referrer:document.referrer||void 0,title:document.title||void 0,screenWidth:window.screen?.width,screenHeight:window.screen?.height,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||void 0,language:navigator.language||void 0,utmSource:t.utm_source,utmMedium:t.utm_medium,utmCampaign:t.utm_campaign,utmTerm:t.utm_term,utmContent:t.utm_content,ref:t.ref,source:t.source,via:t.via}),!bo){bo=!0;let p=O();if(p){let y=JSON.stringify({type:"geo",websiteId:B(),visitorUid:c||void 0,sessionUid:r||void 0});try{fetch(`${p}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:y,keepalive:!0,credentials:"omit"}).catch(()=>{})}catch{}}}},po=()=>{w();let{pushState:o,replaceState:n}=history;if(history.pushState=function(...t){o.apply(this,t),w()},history.replaceState=function(...t){n.apply(this,t),w()},window.addEventListener("popstate",()=>w()),K())window.addEventListener("hashchange",()=>w())};var wo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t)return;try{let c=new URL(t);if(c.protocol!=="http:"&&c.protocol!=="https:")return;if(c.hostname===location.hostname)return;let r=u(),f=x();if(!r||!f)return;l("exit_click",{visitorUid:r,sessionUid:f,hostname:location.hostname,url:t})}catch{}})};var Lo=/\.(pdf|zip|dmg|exe|doc|docx|xls|xlsx|ppt|pptx|csv|rar|7z|tar|gz|mp3|mp4|avi|mov)$/i,yo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest("a");if(!n)return;let t=n.href;if(!t||!Lo.test(t))return;let c=u(),r=x();l("goal",{...c&&{visitorUid:c},...r&&{sessionUid:r},name:"file_download",metadata:{url:t}})})};var b=(o,n)=>{let t=u(),c=x();l("goal",{...t&&{visitorUid:t},...c&&{sessionUid:c},name:o,metadata:n})};var k="data-fs-goal",Bo="data-fs-goal-",Io=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(Bo)&&c.name!==k){let r=c.name.slice(Bo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},jo=()=>{document.addEventListener("click",(o)=>{let n=o.target.closest(`[${k}]`);if(!n)return;let t=n.getAttribute(k);if(!t)return;let c=Io(n);b(t,c)})};var G="data-fs-scroll",Fo="data-fs-scroll-threshold",L="data-fs-scroll-delay",zo="data-fs-scroll-",Co=new Set([G,Fo,L]),mo=(o)=>{let n={},t=0;for(let c of Array.from(o.attributes))if(c.name.startsWith(zo)&&!Co.has(c.name)){let r=c.name.slice(zo.length).replace(/-/g,"_"),f=(c.value||"").slice(0,255);if(r&&t<10)n[r]=f,t++}return t>0?n:void 0},$o=()=>{let o=document.querySelectorAll(`[${G}]`);if(!o.length)return;let n=new Set,t=new IntersectionObserver((c)=>{for(let r of c){let f=r.target;if(!r.isIntersecting||n.has(f))continue;let p=f.getAttribute(G);if(!p)continue;let y=parseInt(f.getAttribute(L)||"0",10)||0,e=()=>{if(n.has(f))return;n.add(f),t.unobserve(f);let g=mo(f);b(p,g)};if(y>0)setTimeout(e,y);else e()}},{threshold:0});for(let c of Array.from(o)){let r=parseFloat(c.getAttribute(Fo)||"0.5");if(r!==0.5){let f=new IntersectionObserver((p)=>{for(let y of p){let e=y.target;if(!y.isIntersecting||n.has(e))continue;let g=e.getAttribute(G);if(!g)continue;let C=parseInt(e.getAttribute(L)||"0",10)||0,D=()=>{if(n.has(e))return;n.add(e),f.unobserve(e);let Wo=mo(e);b(g,Wo)};if(C>0)setTimeout(D,C);else D()}},{threshold:r});f.observe(c)}else t.observe(c)}};var I=null,go=()=>{if(!I)I=new Set(to());return I},Do=(o)=>{let n=go();if(!n.size)return!1;for(let t of n)if(o===t||o.endsWith(`.${t}`))return!0;return!1},Jo=()=>{if(!go().size)return;document.addEventListener("click",(n)=>{let t=n.target.closest("a");if(!t)return;let c=t.href;if(!c)return;try{let r=new URL(c);if(r.hostname===location.hostname)return;if(!Do(r.hostname))return;t.href=j(c)}catch{}})};var F=(o)=>{let n=u(),t=x();l("payment",{...n&&{visitorUid:n},...t&&{sessionUid:t},...o.amount!=null&&{amount:o.amount},...o.currency&&{currency:o.currency},...o.transactionId&&{transactionId:o.transactionId},...o.email&&{email:o.email},...o.name&&{name:o.name},...o.customerId&&{customerId:o.customerId},...o.isRenewal!=null&&{isRenewal:o.isRenewal},...o.isRefund!=null&&{isRefund:o.isRefund}})};var $=(o)=>{let n=u();l("identify",{...n&&{visitorUid:n},userId:o.userId,name:o.name,image:o.image,profileData:o.profileData})};var Qo=(o)=>{let[n,...t]=o;switch(n){case"identify":$(t[0]);break;case"payment":F(t[0]);break;default:b(n,t[0]);break}},d=()=>{if(E())return;if(!B())return;if(co())return;if(T()&&!_())return;if(S()&&!a())return;if(oo()&&!no())return;po(),so(),wo(),yo(),jo(),$o(),Jo();let o=window,n=o.flowsery?.q||[];for(let t of n)Qo(t);o.flowsery=function(...t){Qo(t)}};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",d);else d();var Ao=async(o)=>{let n=window;return n.__flowsery_config=o,d(),{trackEvent:b,trackPayment:F,trackPageview:w,identify:$,stop:h,reset:q,getTrackingParams:m,buildCrossDomainUrl:j,getVisitorId:u,getSessionId:x}};})();
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "flowsery",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Flowsery analytics tracking script",
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"require": "./dist/index.cjs",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"./script": "./dist/script.js",
|
|
15
|
+
"./script.hash": "./dist/script.hash.js",
|
|
16
|
+
"./main": "./dist/main.js",
|
|
17
|
+
"./main.hash": "./dist/main.hash.js"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "bun run build:main && bun run build:main-hash && bun run build:script && bun run build:script-hash && bun run build:esm && bun run build:cjs",
|
|
21
|
+
"build:main": "bun build src/index.ts --outfile dist/main.js --minify --format iife --target browser",
|
|
22
|
+
"build:main-hash": "bun build src/index.ts --outfile dist/main.hash.js --minify --format iife --target browser --define 'HASH_MODE=true'",
|
|
23
|
+
"build:script": "bun build src/index.ts --outfile dist/script.js --minify --format iife --target browser",
|
|
24
|
+
"build:script-hash": "bun build src/index.ts --outfile dist/script.hash.js --minify --format iife --target browser --define 'HASH_MODE=true'",
|
|
25
|
+
"build:esm": "bun build src/index.ts --outfile dist/index.mjs --minify --format esm --target browser",
|
|
26
|
+
"build:cjs": "bun build src/index.ts --outfile dist/index.cjs --minify --target node",
|
|
27
|
+
"dev": "bun build src/index.ts --outfile dist/script.js --watch --target browser"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"typescript": "^5.3.0"
|
|
31
|
+
},
|
|
32
|
+
"files": ["dist"],
|
|
33
|
+
"license": "MIT"
|
|
34
|
+
}
|