@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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. 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 A=null,f=new Map,ee="workspace";function te(e){if(!I())throw new Error("@webority/analytics: call initConsent before initAnalytics.");let t=w(e.webVitals);A?.(),A=m(n=>re(n.analytics)),f.clear(),P({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},heatmaps:e.heatmaps??!1,captureExceptions:e.captureExceptions??!1,webVitals:t,featureFlags:e.featureFlags===!0}),s()&&ne()}function ne(){let e=()=>{s()&&(R(),r.config?.webVitals&&C(r.config.webVitals,x))};typeof requestIdleCallback=="function"?requestIdleCallback(e,{timeout:3e3}):setTimeout(e,0)}function R(){c().catch(()=>{})}function re(e){if(s()){if(e){r.posthogInstance?(r.posthogInstance.opt_in_capturing(),O(r.posthogInstance),_(r.posthogInstance)):c().then(t=>{O(t),t&&_(t)}).catch(()=>{});return}!r.posthogInstance&&!r.posthogInitPromise&&R(),oe()}}function O(e){if(!e||!i())return;let t=r.pendingIdentify;t&&e.identify(t.publicId,t.props);for(let[n,{key:o,props:a}]of f)e.group(n,o,a)}function _(e){r.config?.featureFlags===!0&&i()&&e.reloadFeatureFlags?.()}function oe(){if(r.posthogInstance){r.posthogInstance.opt_out_capturing();return}r.posthogInitPromise&&r.posthogInitPromise.then(e=>{i()||e?.opt_out_capturing()}).catch(()=>{})}function ie(e,t={}){if(!s()){E("identify",{publicId:e,...t});return}r.pendingIdentify={publicId:e,props:t},i()&&c().then(n=>{!n||!i()||n.identify(e,t)}).catch(()=>{})}function se(e,t,n={}){if(typeof e!="string"||!e||typeof t!="string"||!t)throw new Error("@webority/analytics: group needs a type and a PublicId string.");if(!s()){E("group",{type:e,key:t,...n});return}f.set(e,{key:t,props:n}),i()&&c().then(o=>{!o||!i()||o.group(e,t,n)}).catch(()=>{})}function ae(){r.pendingIdentify=null,f.clear(),r.posthogInstance&&r.posthogInstance.reset()}function l(e,t={}){T.assertRegistered(e),x(e,t)}function x(e,t){let n=r.config;if(!n||!s()){E(e,t);return}let o={...t,product:n.product,surface:n.surface,environment:n.environment};c().then(a=>{a?.capture(e,o)}).catch(()=>{})}function E(e,t){r.config?.environment==="Local"&&r.config.logger?.info(e,t)}function ue(){if(typeof document>"u")return()=>{};for(let[e,t]of Object.entries(S))document.addEventListener(e,t);return()=>{for(let[e,t]of Object.entries(S))document.removeEventListener(e,t)}}function ce(e){d(u.TOUR_STARTED,e,{step_count:p(b(e)?.total)})}function le(e){let t=b(e);d(u.TOUR_STEP_VIEWED,e,{step_position:p(t?.position),step_count:p(t?.total)})}function pe(e){let t=b(e),n={step_position:p(t?.position),step_count:p(t?.total)};t?.reason==="finished"?d(u.TOUR_COMPLETED,e,n):t?.reason==="skipped"&&d(u.TOUR_SKIPPED,e,{...n,via:y(t.via)})}var S={"wui-tour:start":ce,"wui-tour:step":le,"wui-tour:close":pe};function d(e,t,n){let o=t.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);l(e,g)}function fe(e){return typeof e=="object"&&e!==null&&"getAttribute"in e&&typeof e.getAttribute=="function"}function N(e,t){return fe(e)?e.getAttribute(t):void 0}function b(e){let t="detail"in e?e.detail:void 0;return typeof t=="object"&&t!==null?t:void 0}function p(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:void 0}function y(e){return typeof e=="string"&&e!==""?e:void 0}function de(e){return Object.keys(v).every(t=>typeof e[t]=="function")}var H=Object.fromEntries(Object.entries(v).map(([e,t])=>[e,(n={})=>l(t,n)]));if(!de(H))throw new Error("@webority/analytics: a track helper is missing its function.");var ge=Object.freeze(H);export{W as CONSENT_CHANGE_EVENT,j as CONSENT_COOKIE_NAME,ee as WORKSPACE_GROUP_TYPE,J as captureAttribution,M as channels,u as events,Q as getAttribution,K as getConsent,z as getFeatureFlag,se as group,ie as identify,te as initAnalytics,U as initConsent,G as isFeatureEnabled,$ as loadTags,m as onConsentChange,q as onFeatureFlags,Z as registerEvents,V as requiresOptIn,ae as resetIdentity,B as resolveAiSource,Y as resolveChannel,L as saveConsent,D as setConsentRegion,ge as track,l as trackEvent,X as trackSiteEvent,ue as trackTours};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/analytics",
3
- "version": "0.39.0",
3
+ "version": "0.39.1",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",