@webority/analytics 0.39.0 → 0.39.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/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as X,B as Z,C as $,a as V,b as j,c as W,d as U,e as D,f as I,g as K,h as L,i as m,j as u,k as v,l as T,m as r,n as P,o as s,p as i,q as G,r as z,s as q,t as c,u as M,v as Y,w as B,x as J,y as Q}from"./chunk-ZD363DXC.js";import{a as w,g as C}from"./chunk-JWEUCPJH.js";import"./chunk-O2XFH626.js";var
|
|
1
|
+
import{A as X,B as Z,C as $,a as V,b as j,c as W,d as U,e as D,f as I,g as K,h as L,i as m,j as u,k as v,l as T,m as r,n as P,o as s,p as i,q as G,r as z,s as q,t as c,u as M,v as Y,w as B,x as J,y as Q}from"./chunk-ZD363DXC.js";import{a as w,g as C}from"./chunk-JWEUCPJH.js";import"./chunk-O2XFH626.js";var _=null,f=new Map,tt="workspace";function et(t){if(!I())throw new Error("@webority/analytics: call initConsent before initAnalytics.");let e=w(t.webVitals);_?.(),_=m(n=>rt(n.analytics)),f.clear(),P({host:t.host,clientKey:t.clientKey,product:t.product,surface:t.surface,environment:t.environment,enabled:t.enabled??!0,logger:t.logger??null,sessionRecording:{enabled:t.sessionRecording?.enabled??!1,maskAllInputs:t.sessionRecording?.maskAllInputs??!0,maskTextSelector:t.sessionRecording?.maskTextSelector??null},heatmaps:t.heatmaps??!1,captureExceptions:t.captureExceptions??!1,webVitals:e,featureFlags:t.featureFlags===!0}),s()&&nt()}function nt(){let t=()=>{s()&&(R(),r.config?.webVitals&&C(r.config.webVitals,x))};typeof requestIdleCallback=="function"?requestIdleCallback(t,{timeout:3e3}):setTimeout(t,0)}function R(){c().catch(()=>{})}function rt(t){if(s()){if(t){r.posthogInstance?(r.posthogInstance.opt_in_capturing(),A(r.posthogInstance),O(r.posthogInstance)):c().then(e=>{A(e),e&&O(e)}).catch(()=>{});return}!r.posthogInstance&&!r.posthogInitPromise&&R(),ot()}}function A(t){if(!t||!i())return;let e=r.pendingIdentify;e&&t.identify(e.publicId,e.props);for(let[n,{key:o,props:a}]of f)t.group(n,o,a)}function O(t){r.config?.featureFlags===!0&&i()&&t.reloadFeatureFlags?.()}function ot(){if(r.posthogInstance){r.posthogInstance.opt_out_capturing();return}r.posthogInitPromise&&r.posthogInitPromise.then(t=>{i()||t?.opt_out_capturing()}).catch(()=>{})}function it(t,e={}){if(!s()){E("identify",{publicId:t,...e});return}r.pendingIdentify={publicId:t,props:e},i()&&c().then(n=>{!n||!i()||n.identify(t,e)}).catch(()=>{})}function st(t,e,n={}){if(typeof t!="string"||!t||typeof e!="string"||!e)throw new Error("@webority/analytics: group needs a type and a PublicId string.");if(!s()){E("group",{type:t,key:e,...n});return}f.set(t,{key:e,props:n}),i()&&c().then(o=>{!o||!i()||o.group(t,e,n)}).catch(()=>{})}function at(){r.pendingIdentify=null,f.clear();let t=r.posthogInstance;t&&(t.opt_out_capturing(),t.reset(),i()&&t.opt_in_capturing({captureEventName:!1}))}function p(t,e={}){T.assertRegistered(t),x(t,e)}function x(t,e){let n=r.config;if(!n||!s()){E(t,e);return}let o={...e,product:n.product,surface:n.surface,environment:n.environment};c().then(a=>{a?.capture(t,o)}).catch(()=>{})}function E(t,e){r.config?.environment==="Local"&&r.config.logger?.info(t,e)}function ut(){if(typeof document>"u")return()=>{};for(let[t,e]of Object.entries(S))document.addEventListener(t,e);return()=>{for(let[t,e]of Object.entries(S))document.removeEventListener(t,e)}}function ct(t){d(u.TOUR_STARTED,t,{step_count:l(b(t)?.total)})}function pt(t){let e=b(t);d(u.TOUR_STEP_VIEWED,t,{step_position:l(e?.position),step_count:l(e?.total)})}function lt(t){let e=b(t),n={step_position:l(e?.position),step_count:l(e?.total)};e?.reason==="finished"?d(u.TOUR_COMPLETED,t,n):e?.reason==="skipped"&&d(u.TOUR_SKIPPED,t,{...n,via:y(e.via)})}var S={"wui-tour:start":ct,"wui-tour:step":pt,"wui-tour:close":lt};function d(t,e,n){let o=e.target,a=y(N(o,"tour-id"));if(!a)return;let g={tour_id:a},h=y(N(o,"trigger"));h&&(g.trigger=h);for(let[F,k]of Object.entries(n))k!==void 0&&(g[F]=k);p(t,g)}function ft(t){return typeof t=="object"&&t!==null&&"getAttribute"in t&&typeof t.getAttribute=="function"}function N(t,e){return ft(t)?t.getAttribute(e):void 0}function b(t){let e="detail"in t?t.detail:void 0;return typeof e=="object"&&e!==null?e:void 0}function l(t){return typeof t=="number"&&Number.isInteger(t)&&t>=0?t:void 0}function y(t){return typeof t=="string"&&t!==""?t:void 0}function dt(t){return Object.keys(v).every(e=>typeof t[e]=="function")}var H=Object.fromEntries(Object.entries(v).map(([t,e])=>[t,(n={})=>p(e,n)]));if(!dt(H))throw new Error("@webority/analytics: a track helper is missing its function.");var gt=Object.freeze(H);export{W as CONSENT_CHANGE_EVENT,j as CONSENT_COOKIE_NAME,tt as WORKSPACE_GROUP_TYPE,J as captureAttribution,M as channels,u as events,Q as getAttribution,K as getConsent,z as getFeatureFlag,st as group,it as identify,et as initAnalytics,U as initConsent,G as isFeatureEnabled,$ as loadTags,m as onConsentChange,q as onFeatureFlags,Z as registerEvents,V as requiresOptIn,at as resetIdentity,B as resolveAiSource,Y as resolveChannel,L as saveConsent,D as setConsentRegion,gt as track,p as trackEvent,X as trackSiteEvent,ut as trackTours};
|