@webority/analytics 0.14.1 → 0.14.2
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 b,b as C,c as x,d as w,e as k,f as c,g as l,h as A,i as u,j as f,k as d,l as h,m as T,n as N,o as S,p as O,q as P,r as R,s as U}from"./chunk-K4QQTXDP.js";var n={config:null,posthogInstance:null,posthogInitPromise:null,registeredEvents:new Set(Object.values(f)),warnedUnregisteredEvents:new Set,pendingIdentify:null},m=50;function I(e){n.config=e,n.posthogInstance=null,n.posthogInitPromise=null,n.pendingIdentify=null}function i(){let e=n.config;return e?!!(e.enabled&&e.clientKey&&e.environment!=="Local"):!1}function r(){return c()&&l().analytics}function _(){return i()&&r()}async function a(){if(n.posthogInstance)return n.posthogInstance;if(n.posthogInitPromise)return n.posthogInitPromise;let e=n.config;return n.posthogInitPromise=import("posthog-js").then(t=>{let o=t.default??t,s=z(j(e),r());return o.init(e.clientKey,s),o.register({product:e.product,surface:e.surface}),r()?o.opt_in_capturing({captureEventName:!1}):o.opt_out_capturing(),n.posthogInstance=o,o}).catch(t=>{throw n.posthogInitPromise=null,t}),n.posthogInitPromise}function z(e,t){return t?e:{...e,opt_out_capturing_by_default:!0}}function j(e){let t=e.sessionRecording??{enabled:!1},o={api_host:e.host,autocapture:!1,capture_pageview:"history_change",cookieless_mode:"on_reject",person_profiles:"identified_only",persistence:"localStorage",disable_session_recording:!t.enabled,disable_surveys:!0,disable_product_tours:!0,disable_conversations:!0,advanced_disable_feature_flags:!t.enabled};return t.enabled&&(o.session_recording={maskAllInputs:t.maskAllInputs??!0,...t.maskTextSelector?{maskTextSelector:t.maskTextSelector}:{}}),o}var
|
|
1
|
+
import{a as b,b as C,c as x,d as w,e as k,f as c,g as l,h as A,i as u,j as f,k as d,l as h,m as T,n as N,o as S,p as O,q as P,r as R,s as U}from"./chunk-K4QQTXDP.js";var n={config:null,posthogInstance:null,posthogInitPromise:null,registeredEvents:new Set(Object.values(f)),warnedUnregisteredEvents:new Set,pendingIdentify:null},m=50;function I(e){n.config=e,n.posthogInstance=null,n.posthogInitPromise=null,n.pendingIdentify=null}function i(){let e=n.config;return e?!!(e.enabled&&e.clientKey&&e.environment!=="Local"):!1}function r(){return c()&&l().analytics}function _(){return i()&&r()}async function a(){if(n.posthogInstance)return n.posthogInstance;if(n.posthogInitPromise)return n.posthogInitPromise;let e=n.config;return n.posthogInitPromise=import("posthog-js").then(t=>{let o=t.default??t,s=z(j(e),r());return o.init(e.clientKey,s),o.register({product:e.product,surface:e.surface,environment:e.environment}),r()?o.opt_in_capturing({captureEventName:!1}):o.opt_out_capturing(),n.posthogInstance=o,o}).catch(t=>{throw n.posthogInitPromise=null,t}),n.posthogInitPromise}function z(e,t){return t?e:{...e,opt_out_capturing_by_default:!0}}function j(e){let t=e.sessionRecording??{enabled:!1},o={api_host:e.host,autocapture:!1,capture_pageview:"history_change",cookieless_mode:"on_reject",person_profiles:"identified_only",persistence:"localStorage",disable_session_recording:!t.enabled,disable_surveys:!0,disable_product_tours:!0,disable_conversations:!0,advanced_disable_feature_flags:!t.enabled};return t.enabled&&(o.session_recording={maskAllInputs:t.maskAllInputs??!0,...t.maskTextSelector?{maskTextSelector:t.maskTextSelector}:{}}),o}var v=null;function K(e){if(!c())throw new Error("@webority/analytics: call initConsent before initAnalytics.");v?.(),v=u(t=>M(t.analytics)),I({host:e.host,clientKey:e.clientKey,product:e.product,surface:e.surface,environment:e.environment,enabled:e.enabled??!0,logger:e.logger??null,sessionRecording:{enabled:e.sessionRecording?.enabled??!1,maskAllInputs:e.sessionRecording?.maskAllInputs??!0,maskTextSelector:e.sessionRecording?.maskTextSelector??null}}),i()&&L()}function L(){let e=()=>{i()&&y()};typeof requestIdleCallback=="function"?requestIdleCallback(e,{timeout:3e3}):setTimeout(e,0)}function y(){a().catch(()=>{})}function M(e){if(i()){if(e){n.posthogInstance?(n.posthogInstance.opt_in_capturing(),E(n.posthogInstance)):a().then(E).catch(()=>{});return}!n.posthogInstance&&!n.posthogInitPromise&&y(),V()}}function E(e){let t=n.pendingIdentify;e&&t&&r()&&e.identify(t.publicId,t.props)}function V(){if(n.posthogInstance){n.posthogInstance.opt_out_capturing();return}n.posthogInitPromise&&n.posthogInitPromise.then(e=>{r()||e?.opt_out_capturing()}).catch(()=>{})}function W(e,t={}){if(!i()){g("identify",{publicId:e,...t});return}n.pendingIdentify={publicId:e,props:t},r()&&a().then(o=>{!o||!r()||o.identify(e,t)}).catch(()=>{})}function q(e,t,o={}){if(!_()){g("group",{type:e,key:t,...o});return}a().then(s=>{!s||!r()||s.group(e,t,o)}).catch(()=>{})}function D(){n.pendingIdentify=null,n.posthogInstance&&n.posthogInstance.reset()}function H(e){for(let t of e){if(!h.test(t))throw new Error(`@webority/analytics: invalid event name "${t}". Expected snake_case.`);n.registeredEvents.add(t)}}function p(e,t={}){if(!n.registeredEvents.has(e)){$(e);return}B(e,t)}function $(e){if(n.warnedUnregisteredEvents.has(e))return;n.warnedUnregisteredEvents.size<m&&n.warnedUnregisteredEvents.add(e);let t=n.config?.logger,o=`@webority/analytics: event "${e}" is not registered, so it was dropped. Call registerEvents() first.`;if(typeof t?.warn=="function"){t.warn(o);return}if(typeof t?.info=="function"){t.info(o);return}console.warn(o)}function B(e,t){if(!i()){g(e,t);return}let o={...t,product:n.config.product,surface:n.config.surface,environment:n.config.environment};a().then(s=>{s?.capture(e,o)}).catch(()=>{})}function g(e,t){n.config?.environment==="Local"&&n.config.logger?.info(e,t)}var F=Object.freeze(Object.fromEntries(Object.entries(d).map(([e,t])=>[e,(o={})=>p(t,o)])));export{x as CONSENT_CHANGE_EVENT,C as CONSENT_COOKIE_NAME,O as captureAttribution,T as channels,f as events,P as getAttribution,l as getConsent,q as group,W as identify,K as initAnalytics,w as initConsent,U as loadTags,u as onConsentChange,H as registerEvents,b as requiresOptIn,D as resetIdentity,S as resolveAiSource,N as resolveChannel,A as saveConsent,k as setConsentRegion,F as track,p as trackEvent,R as trackSiteEvent};
|