@axceera/playstep-analytics 0.11.2 → 0.11.3

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 CHANGED
@@ -28,18 +28,26 @@ with Insights on. React apps on `@axceera/playstep-react` call `useInsights()` f
28
28
  - **Ids are hashed in the browser** with the environment's analytics key. Ids, emails and names are stored only where
29
29
  the app turns identities on (Pro and Business).
30
30
  - **Consent:** start `pending` (events wait in memory) or `denied` in the dashboard, then call
31
- `insights.setConsent(true | false)` from your banner. The answer is remembered in the browser.
32
- - **Clicks record the element, never what was typed:** its selector, label, role and link, and the page it was on
33
- (the path PlayStep last saw, so heatmaps and reports can place it). Elements marked
34
- `data-private` or `data-ps-no-capture`, hidden ones, PlayStep's own UI and the app's mask list are skipped.
35
- `analytics(playstep, { mask: ['.billing'] })` adds selectors for one page, and `autocapture: { clicks: false }`
36
- turns a part off.
37
- - **Needs a secure page** (https or localhost): it hashes with the browser's `crypto.subtle`.
31
+ `insights.setConsent(true | false)` from your banner. The answer is remembered in the browser, and withdrawing it
32
+ drops what was not sent yet: events waiting, batches saved in the browser and their retries.
33
+ - **Clicks record the element, never what was typed:** its selector, words, role and link (without its query), and
34
+ the page it was on (the path PlayStep last saw, so heatmaps and reports can place it). Elements marked
35
+ `data-private` or `data-ps-no-capture`, hidden ones, PlayStep's own UI and the app's mask list are skipped, and their
36
+ words never show in a bigger element's. A click inside a PlayStep anchor (`data-guide`) that is no control of its
37
+ own is recorded without words. `analytics(playstep, { mask: ['.billing'] })` adds selectors for one page, and
38
+ `autocapture: { clicks: false }` turns a part off; `{ text: false }`, or the dashboard's "Words on clicked
39
+ elements", keeps clicks without their words.
40
+ - **Needs a secure page** (https or localhost): it hashes with the browser's `crypto.subtle`. Without one it stays off
41
+ and says so once in the console.
38
42
  - Batches go to `POST /v1/batch`, kept in local storage and retried when offline, never on the guide queue.
39
43
 
40
44
  API: `setConsent(granted)`, `register(props)` / `unregister(key)` (properties on every event), `group(type, id,
41
- traits?)` (at most 5 kinds), `flush()`. On sign-out, `playstep.identify('')` stops filing events under the user (what
42
- follows waits for the next one; consent and properties stay, groups go) and keeps their guide progress;
43
- `playstep.reset()` forgets the user, the device and those properties too. Script tag: `(window.playstepInsights ||= []).push(['setConsent', true])` works before it loads.
45
+ traits?)` (at most 5 kinds), `flush()`. On sign-out, `playstep.identify('')` stops filing events under the user and keeps
46
+ their guide progress. What follows goes under no one until the next sign-in: it is dropped, or with anonymous tracking
47
+ on it goes under a new device id, so it never lands with whoever signs in next. Consent and properties stay, groups
48
+ go. `playstep.reset()` forgets the user, the device and those properties too. Script tag: `(window.playstepInsights ||= []).push(['setConsent', true])` works before it loads.
44
49
 
45
- About 3.3 KB gzipped from npm (the event queue comes from `@axceera/playstep`), 4 KB as the script tag.
50
+ About 3.5 KB gzipped from npm (the event queue comes from `@axceera/playstep`), 4.2 KB as the script tag.
51
+
52
+ A page view takes the title the page has half a second after the URL changes, since single-page apps set it after
53
+ navigating. Calling `identify()` again for the same user sends `$identify` only when the traits changed.
@@ -6,12 +6,14 @@ interface AnalyticsConfig {
6
6
  hash_key: string;
7
7
  anonymous: boolean;
8
8
  consent: 'granted' | 'pending' | 'denied';
9
+ /** `text` (PLAY-107) is missing from configs published before it: missing means on. */
9
10
  autocapture: {
10
11
  pages: boolean;
11
12
  clicks: boolean;
12
13
  forms: boolean;
13
14
  rage: boolean;
14
15
  dead: boolean;
16
+ text: boolean;
15
17
  };
16
18
  identities: boolean;
17
19
  mask: string[];
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as Props, i as InsightsOptions, n as Autocapture, r as Insights, t as analytics } from "./index-BHJ9eOBw.js";
1
+ import { a as Props, i as InsightsOptions, n as Autocapture, r as Insights, t as analytics } from "./index-BriEsBVD.js";
2
2
  export { type Autocapture, type Insights, type InsightsOptions, type Props, analytics };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export{t as analytics}from"./src-C9pnehdK.js";
1
+ export{t as analytics}from"./src-DzSCbLW0.js";
package/dist/react.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { i as InsightsOptions, r as Insights } from "./index-BHJ9eOBw.js";
1
+ import { i as InsightsOptions, r as Insights } from "./index-BriEsBVD.js";
2
2
  //#region src/react.d.ts
3
3
  /** Attaches Insights to PlayStep (the first call's options win) and returns its API. */
4
4
  export declare function useInsights(options?: InsightsOptions): Insights;
package/dist/react.js CHANGED
@@ -1 +1 @@
1
- import{t as e}from"./src-C9pnehdK.js";import{playstep as t}from"@axceera/playstep";function n(n){return e(t,n)}export{n as useInsights};
1
+ import{t as e}from"./src-DzSCbLW0.js";import{playstep as t}from"@axceera/playstep";function n(n){return e(t,n)}export{n as useInsights};
@@ -0,0 +1 @@
1
+ import{createQueue as e,store as t}from"@axceera/playstep/plugin";const n=/^(:|radix-|headlessui-|react-|ember\d|mui-|v-|css-|sc-|jsx-)|\d{3,}|[a-f0-9]{8,}|__/i,r=/active|selected|current|open|hover|focus|disabled|hidden|show|visible|checked|loading/i,i=e=>`"${e.replace(/["\\]/g,`\\$&`)}"`,a=e=>CSS.escape(e);function o(e,t){try{return e.querySelectorAll(t).length===1}catch{return!1}}function s(e){let t=e.getAttribute(`role`),n=e.tagName,r=(e.getAttribute(`type`)??``).toLowerCase();return t===`tab`||t===`menuitem`||t===`link`||t===`button`?t:t===`checkbox`||t===`switch`||n===`INPUT`&&(r===`checkbox`||r===`radio`)?`checkbox`:n===`A`?`link`:n===`BUTTON`||n===`SUMMARY`||n===`INPUT`&&/^(submit|button|reset|image)$/.test(r)?`button`:n===`SELECT`?`select`:n===`INPUT`||n===`TEXTAREA`?`input`:`other`}function c(e){let t=e.ownerDocument,s=e.tagName.toLowerCase(),c=[];e.id&&!n.test(e.id)&&c.push(`#${a(e.id)}`);for(let t of[`data-testid`,`data-test`,`data-cy`,`data-qa`]){let n=e.getAttribute(t);n&&c.push(`[${t}=${i(n)}]`)}for(let t of[`aria-label`,`name`,`title`,`placeholder`]){let n=e.getAttribute(t);n&&n.length<=80&&c.push(`${s}[${t}=${i(n)}]`)}let l=e.getAttribute(`href`);s===`a`&&l&&!/^javascript:|[?#]/i.test(l)&&l.length<=200&&c.push(`a[href=${i(l)}]`);let u=[...e.classList].filter(e=>/^[a-z][\w-]{1,40}$/i.test(e)&&!n.test(e)&&!r.test(e));u.length&&c.push(`${s}.${u.slice(0,3).map(a).join(`.`)}`);for(let e of c)if(o(t,e))return e;let d=[],f=e;for(;f&&d.length<7;){if(f===t.body){d.unshift(`body`);break}if(f!==e&&f.id&&!n.test(f.id)){d.unshift(`#${a(f.id)}`);break}let r=f.tagName.toLowerCase(),i=f.parentElement?[...f.parentElement.children].filter(e=>e.tagName===f.tagName):[];d.unshift(i.length>1?`${r}:nth-of-type(${i.indexOf(f)+1})`:r),f=f.parentElement}let p=d.join(`>`);return o(t,p)?p:void 0}function l(e){let t=e.getAttribute(`aria-label`)||e.getAttribute(`title`);if(t)return t;let n=e.getAttribute(`aria-labelledby`);if(n)return n.split(/\s+/).map(t=>e.ownerDocument.getElementById(t)?.textContent??``).join(` `);let r=e.labels;return r?.length?r[0].innerText:``}function u(e,t=[]){if(e.closest(`[data-private],[aria-hidden=true],[inert],[data-ps-no-capture],playstep-root,playstep-capture`))return!0;for(let n of t)try{if(e.closest(n))return!0}catch{}return!1}const d=()=>crypto.randomUUID(),f=async e=>`u_`+[...new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)),0,20)].map(e=>e.toString(16).padStart(2,`0`)).join(``),p=e=>/^(string|number|boolean)$/.test(typeof e),m=e=>Object.keys(e).length,h=e=>(e??``).replace(/\s+/g,` `).trim().slice(0,80),g=e=>{try{localStorage.removeItem(`playstep:${e}`)}catch{}},_=()=>void 0;function v(e,t=!0){let n={};for(let r in e){let i=e[r];m(n)<50&&/^[A-Za-z_$][\w.:-]{0,63}$/.test(r)&&(i===null||p(i)||t&&Array.isArray(i)&&i.every(p))&&(n[r]=Array.isArray(i)?i.slice(0,25):i)}return n}function y(){let e={};for(let[t,n]of new URLSearchParams(location.search))t.startsWith(`utm_`)&&(e[t.slice(4)]=n);let t=document.referrer&&new URL(document.referrer);return{r:t&&t.host!=location.host?t.origin:void 0,u:m(e)?e:void 0}}function b(e,t,n,r){let i=``;if(n&&!e.matches(`input,select,textarea`)){i=e.innerText;for(let t of e.querySelectorAll(`*`)){let e=u(t,r)&&t.innerText;e&&(i=i.includes(e)?i.replace(e,``):``)}}let a=e.href;return{selector:c(e),text:n&&(h(i)||h(l(e)))||void 0,role:s(e),href:typeof a==`string`&&a.split(/[?#]/)[0]||void 0,x:t.pageX|0,y:t.pageY|0,vw:innerWidth,vh:innerHeight}}function x(n={}){let r,i=``,a,o,s=[],p,x,S,C=!1,w,T,E,D={},O,k={},A={},j=[],M=e=>{let n=t.get(`a:d`);return!n&&e&&t.set(`a:d`,n=`d_${d()}`),n},N=()=>r&&(T??(!w&&r.anonymous?M(!0):void 0)),P=()=>{let e=N();if(!e)return null;let n=t.get(`a:s`),o=e=>typeof e==`string`?e:void 0;return{v:1,key:i,sdk:a,actor:e,device:T&&M()||void 0,guide_key:E,traits:m(D)?D:void 0,user:r.identities&&w?{id:w,email:o(D.email),name:o(D.name)}:void 0,groups:m(k)?k:void 0,context:{platform:`web`,locale:navigator.language,referrer:n?.r,utm:n?.u}}};function F(e){let n=Date.now(),r=t.get(`a:s`);(!r||n-r.t>18e5)&&(r={id:d(),t:n,...y()},x.push({id:d(),name:`$session_start`,ts:e.ts,session:r.id})),r.t=n,t.set(`a:s`,r),x.push({...e,session:r.id})}let I=()=>p==`granted`&&N()&&j.splice(0).forEach(F);function L(e,t={}){if(!r||p==`denied`)return;let n={...A,...t.props},i={id:d(),name:e,ts:Date.now(),page:t.el&&O,...t,props:m(n)?n:void 0};p==`granted`&&N()?F(i):j.length<100&&w!==``&&j.push(i)}function R(e,t){let n=JSON.stringify(D)==JSON.stringify(D=v(t,!1));if(e==w&&e)return void(T&&!n&&L(`$identify`));if(x.flush(),w&&!e&&(j=[],g(`a:d`)),w=e||w&&``,T=E=void 0,!e)return void(k={});Promise.all([f(`${r.hash_key}:${e}`),f(`${i}:${e}`)]).then(t=>{w==e&&([T,E]=t,L(`$identify`),I())})}function z(e){let t=O={path:e};o.pages&&L(`$pageview`,{page:t}),setTimeout(()=>O==t&&(t.title=document.title),500)}function B(){R(``,{}),A={},j=[],g(`a:d`),g(`a:s`)}function V(){S={url:r.url,storageKey:`playstep:a:q:${i}`,envelope:P,send:p==`denied`?_:n.send},x=e(S)}function H(){let e=[];addEventListener(`click`,t=>{let n=t.target;if(!(n instanceof Element))return;let r=n.closest(`a[href],button,input:not([type=hidden]),select,textarea,summary,[role=button],[role=link],[role=tab],[role=menuitem],[role=checkbox],[role=switch],[data-guide]`);if(u(r??n,s))return;let i=!!r?.matches(`a[href],button,input:not([type=hidden]),select,textarea,summary,[role=button],[role=link],[role=tab],[role=menuitem],[role=checkbox],[role=switch]`)&&o.text!=0;if(o.rage&&(e=e.filter(e=>t.timeStamp-e.t<700&&Math.abs(e.x-t.clientX)<30&&Math.abs(e.y-t.clientY)<30),e.push({t:t.timeStamp,x:t.clientX,y:t.clientY})==3&&L(`$rage_click`,{el:b(r??n,t,i,s)})),!r)return;let a=b(r,t,i,s);if(o.clicks&&L(`$click`,{el:a}),o.dead){let e=!1,t=location.href,n=new MutationObserver(()=>e=!0);n.observe(document,{subtree:!0,childList:!0,attributes:!0}),setTimeout(()=>{n.disconnect(),!e&&t==location.href&&L(`$dead_click`,{el:a})},1e3)}},!0),o.forms&&addEventListener(`submit`,e=>{let t=e.target;t instanceof HTMLFormElement&&!u(t,s)&&L(`$submit`,{el:{selector:c(t),role:`form`,text:h(l(t)||t.getAttribute(`name`))}})},!0)}function U(e,c){if(!(r||!e||c.preview)){if(!crypto.subtle)return void(C||(C=(console.warn(`PlayStep Insights needs a secure context`),!0)));r=e,i=c.appKey,a={name:c.sdkName||`web`,version:`0.11.3`},o={...e.autocapture,...n.autocapture},s=[...e.mask,...n.mask??[]],p=t.get(`a:c`)??e.consent,V(),H()}}return{plugin:(...e)=>{e[0]==`config`?U(e[1].analytics,e[2]):r&&(e[0]==`identify`?R(e[1],e[2]):e[0]==`track`?L(e[1],{props:v(e[2])}):e[0]==`page`?z(e[1]):B())},setConsent:e=>{p=e?`granted`:`denied`,t.set(`a:c`,p),e?(S?.send==_&&V(),I()):(j=[],g(`a:d`),S&&(S.send=_,S.envelope=()=>null,x.flush()))},register:e=>void(A={...A,...v(e)}),unregister:e=>void delete A[e],group:(e,t,n)=>{(e in k||m(k)<5)&&(k[e]=t),L(`$group`,{props:{...v(n),group_type:e,group_id:t}})},flush:()=>x?.flush()}}const S=new WeakMap;function C(e,t){let n=S.get(e);return n||(S.set(e,n=x(t)),e.use(n.plugin)),n}export{C as t};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axceera/playstep-analytics",
3
- "version": "0.11.2",
3
+ "version": "0.11.3",
4
4
  "description": "PlayStep Insights: product analytics for your web app (pages, clicks, forms, your own events) as an add-on to @axceera/playstep. Loaded only when you add it; signed-in users only unless you allow anonymous tracking.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -39,8 +39,8 @@
39
39
  "tsdown": "^0.23.0",
40
40
  "typescript": "~6.0.3",
41
41
  "vitest": "^4.1.11",
42
- "@axceera/playstep": "0.11.2",
43
- "@playstep/spec": "0.1.0"
42
+ "@playstep/spec": "0.1.0",
43
+ "@axceera/playstep": "0.11.3"
44
44
  },
45
45
  "scripts": {
46
46
  "build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsdown",
@@ -1 +0,0 @@
1
- import{createQueue as e,store as t}from"@axceera/playstep/plugin";const n=/^(:|radix-|headlessui-|react-|ember\d|mui-|v-|css-|sc-|jsx-)|\d{3,}|[a-f0-9]{8,}|__/i,r=/active|selected|current|open|hover|focus|disabled|hidden|show|visible|checked|loading/i,i=e=>`"${e.replace(/["\\]/g,`\\$&`)}"`,a=e=>CSS.escape(e);function o(e,t){try{return e.querySelectorAll(t).length===1}catch{return!1}}function s(e){let t=e.getAttribute(`role`),n=e.tagName,r=(e.getAttribute(`type`)??``).toLowerCase();return t===`tab`||t===`menuitem`||t===`link`||t===`button`?t:t===`checkbox`||t===`switch`||n===`INPUT`&&(r===`checkbox`||r===`radio`)?`checkbox`:n===`A`?`link`:n===`BUTTON`||n===`SUMMARY`||n===`INPUT`&&/^(submit|button|reset|image)$/.test(r)?`button`:n===`SELECT`?`select`:n===`INPUT`||n===`TEXTAREA`?`input`:`other`}function c(e){let t=e.ownerDocument,s=e.tagName.toLowerCase(),c=[];e.id&&!n.test(e.id)&&c.push(`#${a(e.id)}`);for(let t of[`data-testid`,`data-test`,`data-cy`,`data-qa`]){let n=e.getAttribute(t);n&&c.push(`[${t}=${i(n)}]`)}for(let t of[`aria-label`,`name`,`title`,`placeholder`]){let n=e.getAttribute(t);n&&n.length<=80&&c.push(`${s}[${t}=${i(n)}]`)}let l=e.getAttribute(`href`);s===`a`&&l&&!/^javascript:/i.test(l)&&l.length<=200&&c.push(`a[href=${i(l)}]`);let u=[...e.classList].filter(e=>/^[a-z][\w-]{1,40}$/i.test(e)&&!n.test(e)&&!r.test(e));u.length&&c.push(`${s}.${u.slice(0,3).map(a).join(`.`)}`);for(let e of c)if(o(t,e))return e;let d=[],f=e;for(;f&&d.length<7;){if(f===t.body){d.unshift(`body`);break}if(f!==e&&f.id&&!n.test(f.id)){d.unshift(`#${a(f.id)}`);break}let r=f.tagName.toLowerCase(),i=f.parentElement?[...f.parentElement.children].filter(e=>e.tagName===f.tagName):[];d.unshift(i.length>1?`${r}:nth-of-type(${i.indexOf(f)+1})`:r),f=f.parentElement}let p=d.join(`>`);return o(t,p)?p:void 0}function l(e){let t=e.getAttribute(`aria-label`)||e.getAttribute(`title`);if(t)return t;let n=e.getAttribute(`aria-labelledby`);if(n)return n.split(/\s+/).map(t=>e.ownerDocument.getElementById(t)?.textContent??``).join(` `);let r=e.labels;return r?.length?r[0].innerText:``}function u(e,t=[]){if(e.closest(`[data-private],[aria-hidden=true],[inert],[data-ps-no-capture],playstep-root,playstep-capture`))return!0;for(let n of t)try{if(e.closest(n))return!0}catch{}return!1}const d=()=>crypto.randomUUID(),f=async e=>[...new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)))].map(e=>e.toString(16).padStart(2,`0`)).join(``),p=e=>/^(string|number|boolean)$/.test(typeof e),m=e=>Object.keys(e).length,h=e=>(e??``).replace(/\s+/g,` `).trim().slice(0,80);function g(e,t=!0){let n={};for(let r in e){let i=e[r];m(n)<50&&/^[A-Za-z_$][\w.:-]{0,63}$/.test(r)&&(i===null||p(i)||t&&Array.isArray(i)&&i.every(p))&&(n[r]=Array.isArray(i)?i.slice(0,25):i)}return n}function _(){let e={};for(let[t,n]of new URLSearchParams(location.search))t.startsWith(`utm_`)&&(e[t.slice(4)]=n);let t;try{t=new URL(document.referrer)}catch{}return{r:t&&t.host!=location.host?t.origin:void 0,u:m(e)?e:void 0}}function v(e,t,n){let r=n&&h(/^(INPUT|SELECT|TEXTAREA)$/.test(e.tagName)?l(e):e.innerText||l(e)),i=e.href;return{selector:c(e),text:r||void 0,role:s(e),href:typeof i==`string`&&i||void 0,x:t.pageX|0,y:t.pageY|0,vw:innerWidth,vh:innerHeight}}function y(n={}){let r,i=``,a,o,s=[],p,y,b,x,S,C={},w,T={},E={},D=[],O=e=>{let n=t.get(`a:d`);return!n&&e&&t.set(`a:d`,n=`d_${d()}`),n||void 0},k=()=>r&&(x??(!b&&r.anonymous?O(!0):void 0)),A=()=>{let e=k();if(!e)return null;let n=t.get(`a:s`),o=e=>typeof e==`string`?e:void 0;return{v:1,key:i,sdk:a,actor:e,device:x&&O()||void 0,guide_key:S,traits:m(C)?C:void 0,user:r.identities&&b?{id:b,email:o(C.email),name:o(C.name)}:void 0,groups:m(T)?T:void 0,context:{platform:`web`,locale:navigator.language,referrer:n?.r,utm:n?.u}}};function j(e){let n=Date.now(),r=t.get(`a:s`);(!r||n-r.t>18e5)&&(r={id:d(),t:n,..._()},y.push({id:d(),name:`$session_start`,ts:e.ts,session:r.id})),r.t=n,t.set(`a:s`,r),y.push({...e,session:r.id})}let M=()=>p==`granted`&&k()&&D.splice(0).forEach(j);function N(e,t={}){if(!r||p==`denied`)return;let n={...E,...t.props},i={id:d(),name:e,ts:Date.now(),page:t.el&&w,...t,props:m(n)?n:void 0};p==`granted`&&k()?j(i):D.length<100&&D.push(i)}function P(e,t){if(C=g(t,!1),e==b&&e)return void(x&&N(`$identify`));if(y.flush(),b=e,x=S=void 0,!e)return void(T={});Promise.all([f(`${r.hash_key}:${e}`),f(`${i}:${e}`)]).then(([t,n])=>{b==e&&(x=`u_${t.slice(0,40)}`,S=`u_${n.slice(0,40)}`,N(`$identify`),M())})}function F(){P(``,{}),E={},D=[],t.set(`a:d`,null),t.set(`a:s`,null)}function I(){let e=[];addEventListener(`click`,t=>{let n=t.target;if(!(n instanceof Element))return;let r=n.closest(`a[href],button,input:not([type=hidden]),select,textarea,summary,[role=button],[role=link],[role=tab],[role=menuitem],[role=checkbox],[role=switch],[data-guide]`);if(u(r??n,s)||(o.rage&&(e=e.filter(e=>t.timeStamp-e.t<700&&Math.abs(e.x-t.clientX)<30&&Math.abs(e.y-t.clientY)<30),e.push({t:t.timeStamp,x:t.clientX,y:t.clientY})==3&&N(`$rage_click`,{el:v(r??n,t,!!r)})),!r))return;let i=v(r,t,!0);if(o.clicks&&N(`$click`,{el:i}),o.dead){let e=!1,t=location.href,n=new MutationObserver(()=>e=!0);n.observe(document,{subtree:!0,childList:!0,attributes:!0}),setTimeout(()=>{n.disconnect(),!e&&t==location.href&&N(`$dead_click`,{el:i})},1e3)}},!0),o.forms&&addEventListener(`submit`,e=>{let t=e.target;t instanceof HTMLFormElement&&!u(t,s)&&N(`$submit`,{el:{selector:c(t),role:`form`,text:h(l(t)||t.getAttribute(`name`))}})},!0)}function L(c,l){!r&&c&&!l.preview&&crypto.subtle&&(r=c,i=l.appKey,a={name:l.sdkName||`web`,version:`0.11.2`},o={...c.autocapture,...n.autocapture},s=[...c.mask,...n.mask??[]],p=t.get(`a:c`)??c.consent,y=e({url:c.url,storageKey:`playstep:a:q:${i}`,envelope:A,send:n.send}),I())}return{plugin:(...e)=>{e[0]==`config`?L(e[1].analytics,e[2]):r&&(e[0]==`identify`?P(e[1],e[2]):e[0]==`track`?N(e[1],{props:g(e[2])}):e[0]==`page`?(w={path:e[1]},o.pages&&N(`$pageview`,{page:{path:e[1],title:document.title}})):F())},setConsent:e=>{p=e?`granted`:`denied`,t.set(`a:c`,p),e?M():(D=[],t.set(`a:d`,null))},register:e=>void(E={...E,...g(e)}),unregister:e=>void delete E[e],group:(e,t,n)=>{(e in T||m(T)<5)&&(T[e]=t),N(`$group`,{props:{...g(n),group_type:e,group_id:t}})},flush:()=>y?.flush()}}const b=new WeakMap;function x(e,t){let n=b.get(e);return n||(b.set(e,n=y(t)),e.use(n.plugin)),n}export{x as t};