UNPKG

@deriv-com/analytics

Version:

Comprehensive analytics package for Deriv applications. Provides unified event tracking, A/B testing, and user analytics through RudderStack, PostHog and GrowthBook integrations with built-in caching and offline support.

4 lines 2.3 kB
import p from'js-cookie';/* @deriv-com/analytics - NPM Package - Built with tsup */ var c="https://deriv.com/cdn-cgi/trace",m="https://cdn.growthbook.io",f="https://deriv-dataplane.rudderstack.com",a="https://ph.deriv.com",y="https://us.posthog.com",h=()=>{if(typeof window>"u")return a;let t=window.location.hostname;return t.includes(".deriv.me")?"https://ph.deriv.me":t.includes(".deriv.be")?"https://ph.deriv.be":t.includes(".deriv.ae")?"https://ph.deriv.ae":a},g=["deriv.com","deriv.be","deriv.me","deriv.team","deriv.ae"],l=["deriv.com","derivcrypto.com","besquare.my","besquare.com.my","ewallet.exchange","champion-fx.com","opalstraits.com","binary.com","binary.marketing","championgbs.com","4x.my","re-work.dev","regentmarkets.com","4x.com","binary.me","deriv.team","firstsource.io","firstsource.tech","deriv.hr","vmgbpo.net","mailisk.net","mailosaur.net","mobileapps.mailisk.net","w3e180zd.mailosaur.net"];var A=(t,e)=>(...o)=>{e()&&console.log(`[ANALYTIC]${t}`,...o);},k=t=>{let e=t.split("@")[1]?.toLowerCase();return e?l.includes(e):false},b=t=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t),i=null,O=async()=>{if(i)return i;let t=JSON.parse(p.get("website_status")||"{}")?.clients_country;return i=(async()=>{try{let e=await fetch(c).catch(()=>null);if(!e)return t||"";let o=await e.text().catch(()=>"");return o?Object.fromEntries(o.split(` `).map(r=>r.split("=",2))).loc?.toLowerCase()||t||"":t||""}catch{return t||""}})(),i},d=t=>{if(t==null||typeof t!="object")return t;if(Array.isArray(t)){let n=[];for(let r=0;r<t.length;r++){let s=d(t[r]);s!=null&&n.push(s);}return n.length?n:void 0}let e={},o=false;for(let n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;let r=d(t[n]);r==null||r===""||typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0||Array.isArray(r)&&r.length===0||(e[n]=r,o=true);}return o?e:void 0},u=(t,e)=>{for(let o in t){if(!Object.prototype.hasOwnProperty.call(t,o))continue;let n=t[o];n&&typeof n=="object"&&!Array.isArray(n)?u(n,e):e[o]=n;}},D=t=>{if(t==null||typeof t!="object"||Array.isArray(t))return t;let e={};return u(t,e),e};export{m as a,f as b,y as c,h as d,g as e,A as f,k as g,b as h,O as i,d as j,D as k};//# sourceMappingURL=chunk-TE3DYZVQ.mjs.map //# sourceMappingURL=chunk-TE3DYZVQ.mjs.map