@depsmith/depsmith-sdk 0.7.0 → 0.8.0

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
@@ -30,6 +30,52 @@ Multiple instances: `new DepsmithSdkClient(config)` (the `DepsmithSdk` export is
30
30
  - **Sessions**: 30-min inactivity rotation, persisted across reloads
31
31
  - **Never throws**: all public methods are guarded; enable `debug: true` to see internal warnings
32
32
 
33
+ ## Page names and types
34
+
35
+ Every `$page_view` carries `$page_name`, `$page_source` (`auto` / `manual`) and, when known,
36
+ `$page_type`. Titles are unique per product or article, so give pages readable names with
37
+ `pageNames`; the raw title stays in `context.page.title`:
38
+
39
+ ```ts
40
+ DepsmithSdk.init({
41
+ apiKey: 'your-key',
42
+ endpoint: 'https://collector.example.com',
43
+ autocapture: true,
44
+ // `*` = one path segment, `**` = the rest. First match wins, in insertion order.
45
+ pageNames: { '/products/*': 'Product', '/collections/*': 'Collection', '/': 'Home' },
46
+ });
47
+
48
+ DepsmithSdk.page('Checkout', { step: 2 }, { type: 'checkout' }); // explicit name and type win
49
+ ```
50
+
51
+ A pattern match sets `$page_type` to the same name.
52
+
53
+ ## Autocapture defaults
54
+
55
+ `autocapture: true` turns on page views (`pageviews: 'path'`: a new view when the path changes,
56
+ not on a query-string or `#` change; `'all'` for every URL change), interactive clicks and form
57
+ starts/submits. **Scroll depth is off by default**: set `autocapture: { scrolls: true }` for
58
+ `scroll_depth` events. It is also what measures `$page_max_scroll`, so without it `$page_leave`
59
+ carries no `$page_max_scroll`.
60
+
61
+ ## Naming elements for autocapture
62
+
63
+ Give the elements you want to chart a stable name with `data-depsmith-sdk-id`. It becomes the
64
+ whole `$ac_selector`, whatever the element's classes or parents, and survives redesigns and
65
+ rebuilds:
66
+
67
+ ```html
68
+ <button class="Button_primary__3kLmN" data-depsmith-sdk-id="add-to-cart">Add to cart</button>
69
+ <!-- $ac_selector: button[data-depsmith-sdk-id="add-to-cart"] -->
70
+ ```
71
+
72
+ Without one, the selector uses `data-testid` / `data-test` / `data-cy`, a non-generated `id`,
73
+ `name`, `aria-label`, or the tag and up to two classes, skipping hashed CSS-in-JS / CSS-module
74
+ classes, utility classes and generated ids, and never a position (`:nth-of-type`). Add your own
75
+ "generated" patterns with `autocapture.selectorIgnore: ['^js-']`. `pageNames` also takes `[pattern, name]` pairs
76
+ (explicit order) or a function `(location) => string | undefined`, which names pages but sets no
77
+ type. `page()` without a name goes through the same rules, so both paths agree.
78
+
33
79
  ## Development
34
80
 
35
81
  ```bash
@@ -1,2 +1,2 @@
1
- function _(e,t){let r=[],n=e;for(;n&&n!==document.documentElement&&r.length<t;){let s=n.tagName.toLowerCase();if(n.id){r.unshift(`${s}#${n.id}`);break}let i=Array.from(n.classList).slice(0,3);i.length&&(s+=`.${i.join(".")}`);let u=n.parentElement;if(u){let a=Array.from(u.children).filter(l=>l.tagName===n.tagName);a.length>1&&(s+=`:nth-of-type(${a.indexOf(n)+1})`)}r.unshift(s),n=u}return r.join(" > ")}function h(e,t){if(e.closest("[data-depsmith-sdk-no-capture]"))return!0;for(let r of t)try{if(e.closest(r))return!0}catch{}return!1}var C=new Set(["password","email","tel","hidden","number"]);function $(e){if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e.closest("[data-depsmith-sdk-mask]"))return;let t=e.textContent?.trim().replace(/\s+/g," ");return t?t.slice(0,255):void 0}function k(e){return e instanceof HTMLInputElement?C.has(e.type)||!!e.closest("[data-depsmith-sdk-mask]"):!1}function x(e){if(e.closest("[data-depsmith-sdk-mask]"))return;let t=e.getAttribute("aria-label");return t?w(t):void 0}function S(e){if(e.closest("[data-depsmith-sdk-mask]"))return;let t=e.closest("label");if(t){let n=L(t,e);if(n)return n}let r=e.closest("fieldset")?.querySelector(":scope > legend");return r?L(r,e):void 0}function L(e,t){let r=e.textContent??"";return e!==t&&e.contains(t)&&(r=r.replace(t.textContent??"","")),w(r)||void 0}function y(e,t){let r={};if(t.length===0||e.closest("[data-depsmith-sdk-mask]"))return r;for(let n of t)try{let i=e.closest(`[data-${n}]`)?.getAttribute(`data-${n}`);i&&(r[`$ac_attr_${n.replace(/-/g,"_")}`]=w(i))}catch{}return r}function w(e){return e.trim().replace(/\s+/g," ").slice(0,255)}var R='a, button, [role="button"], input[type="submit"], input[type="button"], [data-depsmith-sdk-capture]';function G(e,t){let r=[];e.clicks&&r.push(N(e,t));let n=null;e.forms&&(n=z(e,t),r.push(n.stop));let s=null;e.scrolls&&(s=q(t),r.push(s.stop));let i=()=>t.pageLeave(s?.maxDepth()),u=[...e.pageviews?[i]:[],...s?[s.rearm]:[],...n?[n.rearm]:[],...e.pageviews?[t.page]:[]];return e.pageviews&&(t.page(),t.armUnloadLeave(i)),u.length>0&&r.push(Y(()=>{for(let a of u)a()})),()=>{for(let a of r.splice(0))a()}}function T(e,t){let r={$ac_selector:_(e,t.selectorMaxDepth),$ac_tag:e.tagName.toLowerCase()};e.id&&(r.$ac_id=e.id);let n=e.getAttribute("class")?.trim().replace(/\s+/g," ");n&&(r.$ac_classes=n.slice(0,255));let s=x(e);s&&(r.$ac_aria_label=s);let i=S(e);return i&&(r.$ac_parent_label=i),{...r,...y(e,t.attributes)}}function H(){return{$ac_viewport_w:window.innerWidth,$ac_viewport_h:window.innerHeight}}var I=/\.(pdf|zip|7z|rar|gz|tar|docx?|xlsx?|pptx?|csv|txt|rtf|mp4|mov|avi|mp3|wav|dmg|pkg|exe|apk)$/i;function M(e){if(!(e instanceof HTMLAnchorElement)||!e.href)return;let t;try{t=new URL(e.href).pathname}catch{return}let r=decodeURIComponent(t.slice(t.lastIndexOf("/")+1)),n=I.exec(t);if(!(!n&&!e.hasAttribute("download"))&&r)return{ext:n?n[1].toLowerCase():"",name:r}}var P=1e3,F=4,O=1e3;function D(){let e=null,t=[],r=!1;return(n,s,i,u)=>(n!==e&&(e=n,t=[],r=!1),t=t.filter(a=>s-a.t<=P),t.length===0&&(r=!1),t.push({t:s,x:i,y:u}),r||t.length<F?null:(r=!0,{count:t.length,begin:t[0].t,end:s,clicks:t.slice()}))}function N(e,t){let r=e.clicks!=="all",n=D(),s=null,i=a=>{if(!s||Date.now()-s.at>O)return;let l={...s.properties,$ac_kind:"error_click",$fr_error_message:String(a.message??"").slice(0,255)},c=a.error;c instanceof Error&&(l.$fr_error_type=c.name,c.stack&&(l.$fr_error_stack=c.stack.slice(0,1e3))),a.filename&&(l.$fr_error_file=a.filename),a.lineno&&(l.$fr_error_line=a.lineno),a.colno&&(l.$fr_error_column=a.colno),t.emit(l),s=null},u=a=>{let l=a.target;if(!(l instanceof Element))return;let c=l.closest(R);if(r&&!c)return;let o=c??l;if(h(o,e.ignoredSelectors))return;let d=M(o),f={$ac_kind:d?"file_download":"click",...T(o,e),$ac_x:a.clientX,$ac_y:a.clientY,...H()},E=$(o);E&&(f.$ac_text=E),o instanceof HTMLAnchorElement&&o.href&&(f.$ac_href=o.href),d&&(f.$ac_file_name=d.name,d.ext&&(f.$ac_file_ext=d.ext)),t.emit(f);let m=n(o,Date.now(),a.clientX,a.clientY);m&&t.emit({...f,$ac_kind:"rage_click",$fr_click_count:m.count,$fr_begin:m.begin,$fr_end:m.end,$fr_duration_ms:m.end-m.begin,$fr_clicks:m.clicks.map(p=>`${p.t-m.begin},${p.x},${p.y}`)}),s={at:Date.now(),properties:f}};return document.documentElement.addEventListener("click",u,{capture:!0,passive:!0}),window.addEventListener("error",i),()=>{document.documentElement.removeEventListener("click",u,{capture:!0}),window.removeEventListener("error",i)}}function A(e){let t={$ac_form_id:e.id||null},r=e.getAttribute("name");r&&(t.$ac_form_name=r);let n=e.getAttribute("action");return n&&(t.$ac_form_action=n),t}function z(e,t){let r=new WeakSet,n=c=>{let o=c.target;if(!(o instanceof HTMLFormElement)||h(o,e.ignoredSelectors))return;let d=Array.from(o.elements).filter(f=>f instanceof HTMLInputElement&&!k(f)).map(f=>f.name||f.id).filter(Boolean).slice(0,50);t.emit({$ac_kind:"form_submit",$ac_selector:_(o,e.selectorMaxDepth),...A(o),$ac_form_fields:d})},s=c=>{let o=c.closest("form");!o||r.has(o)||h(o,e.ignoredSelectors)||h(c,e.ignoredSelectors)||(r.add(o),t.emit({$ac_kind:"form_start",$ac_selector:_(o,e.selectorMaxDepth),...A(o)}))},i=c=>{c.target instanceof Element&&s(c.target)},u=c=>{let o=c.target;!(o instanceof Element)||(s(o),!(o instanceof HTMLSelectElement||o instanceof HTMLInputElement&&(o.type==="checkbox"||o.type==="radio"))||h(o,e.ignoredSelectors))||t.emit({$ac_kind:"change",...T(o,e),...H()})},a=document.documentElement,l={capture:!0,passive:!0};return a.addEventListener("submit",n,l),a.addEventListener("input",i,l),a.addEventListener("change",u,l),{stop:()=>{a.removeEventListener("submit",n,{capture:!0}),a.removeEventListener("input",i,{capture:!0}),a.removeEventListener("change",u,{capture:!0})},rearm:()=>{r=new WeakSet}}}var v=[25,50,75,100],W=240;function q(e){let t=0,r=-1,n=0,s=!1,i,u=()=>{r=i?i.scrollHeight-i.clientHeight:document.documentElement.scrollHeight-window.innerHeight},a=()=>Math.min(100,Math.round((i?i.scrollTop:window.scrollY)/r*100)),l=()=>{if(n=0,r<=0&&u(),r<=0||a()<v[t]||(u(),r<=0))return;let p=a();for(;t<v.length&&p>=v[t];)e.emit({$ac_kind:"scroll_depth",$ac_depth:v[t]}),t++;t>=v.length&&m()},c=p=>{if(i&&!i.isConnected&&(i=void 0),i===null&&r===0&&(i=void 0),i===void 0){let g=p.target;if(!(g instanceof Element)||g===document.documentElement||document.documentElement.scrollHeight>window.innerHeight)i=null;else{let b=g;if(b.scrollHeight-b.clientHeight<W)return;i=b}r=-1,f()}else if(i&&p.target!==i)return;n===0&&(n=U(l))},o=()=>{r=-1},d=null,f=()=>{if(!(typeof ResizeObserver>"u"))try{if(d?.disconnect(),d=new ResizeObserver(o),d.observe(i??document.documentElement),i){let p=i.children;for(let g=0;g<p.length;g++)d.observe(p[g])}}catch{d=null}},E=()=>{s||(s=!0,window.addEventListener("scroll",c,{capture:!0,passive:!0}),window.addEventListener("resize",o,{passive:!0}),window.addEventListener("orientationchange",o,{passive:!0}),f())},m=()=>{s&&(s=!1,window.removeEventListener("scroll",c,{capture:!0}),window.removeEventListener("resize",o),window.removeEventListener("orientationchange",o),d?.disconnect(),d=null)};return E(),{maxDepth:()=>t>0?v[t-1]:0,stop:()=>{n!==0&&X(n),n=0,m()},rearm:()=>{t=0,r=-1,i=void 0,E()}}}function U(e){return typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(e,16)}function X(e){typeof cancelAnimationFrame=="function"?cancelAnimationFrame(e):clearTimeout(e)}function Y(e){let t=location.href,r=()=>{location.href!==t&&(t=location.href,e())},n=history.pushState.bind(history),s=history.replaceState.bind(history);return history.pushState=(...i)=>{n(...i),r()},history.replaceState=(...i)=>{s(...i),r()},window.addEventListener("popstate",r),()=>{history.pushState=n,history.replaceState=s,window.removeEventListener("popstate",r)}}export{G as startAutocapture};
1
+ var T="[data-depsmith-sdk-mask]",$=["data-depsmith-sdk-id","data-testid","data-test","data-cy"];function x(e,t,n=[]){let r=[],o=e;for(;o&&o!==document.documentElement&&r.length<t;){let i=o.tagName.toLowerCase(),a;for(let s of $){let d=o.getAttribute(s);if(d&&(s===$[0]||!y(d,n))){a=`${i}[${s}="${v(d)}"]`;break}}if(!a&&o.id&&!y(o.id,n)&&(a=`${i}#${v(o.id)}`),a){r.unshift(a);break}let c=o.getAttribute("name"),l=o.closest(T)?null:o.getAttribute("aria-label"),u=Array.from(o.classList).filter(s=>!y(s,n)).slice(0,2);r.unshift(c?`${i}[name="${v(c)}"]`:l?`${i}[aria-label="${v(l)}"]`:[i,...u.map(v)].join(".")),o=o.parentElement}return r.join(" > ")}function y(e,t=[]){return P.some(n=>n.test(e))||t.some(n=>n.test(e))}var P=[/^(?:css|sc|jsx|emotion|svelte)-/,/__?(?=[a-z\d]*\d)(?=[a-z\d]*[a-z])[a-z\d]{5,}$/i,/[:[/]|\d{4}/,/^ember\d/,/^-?(?:[pm][trblxy]?|[wh]|(?:min|max)-[wh]|gap|space-[xy]|z|text|bg|border|rounded|shadow|font|leading|opacity|col|row|justify|overflow|translate|duration|transition)-/,/^(?:flex|inline|grid-cols)(?:-|$)|^(?:grid|block|hidden|relative|absolute|fixed|sticky|container|truncate|uppercase|sr-only)$/];function k(e,t){let n=[];for(let r of e)try{n.push(new RegExp(r))}catch{t?.(`autocapture.selectorIgnore: invalid pattern ignored "${r}"`)}return n}function v(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):e.replace(/[^\w-]/g,"\\$&")}function b(e,t){if(e.closest("[data-depsmith-sdk-no-capture]"))return!0;for(let n of t)try{if(e.closest(n))return!0}catch{}return!1}var z=new Set(["password","email","tel","hidden","number"]);function H(e){if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e.closest("[data-depsmith-sdk-mask]"))return;let t=e.textContent?.trim().replace(/\s+/g," ");return t?t.slice(0,255):void 0}function C(e){return e instanceof HTMLInputElement?z.has(e.type)||!!e.closest("[data-depsmith-sdk-mask]"):!1}function I(e){if(e.closest("[data-depsmith-sdk-mask]"))return;let t=e.getAttribute("aria-label");return t?L(t):void 0}function R(e){if(e.closest("[data-depsmith-sdk-mask]"))return;let t=e.closest("label");if(t){let r=A(t,e);if(r)return r}let n=e.closest("fieldset")?.querySelector(":scope > legend");return n?A(n,e):void 0}var _=60,W=500,B="h1,h2,h3,h4,h5,h6";function M(e){if(e.closest(T))return;let t=e.localName,n=e instanceof HTMLInputElement&&/^(?:submit|button|reset)$/.test(e.type);if(t==="input"&&!n||t==="textarea")return;let r=(a,c)=>a?.trim()?{label:L(a),source:c}:void 0,o=e.getAttribute("aria-labelledby")?.split(/\s+/).map(a=>{let c=a&&document.getElementById(a);return c&&!c.closest(T)?c.textContent:""}).join(" "),i=r(e.getAttribute("aria-label"),"aria_label")??r(o,"aria_labelledby");return i||t==="select"?i??r(e.getAttribute("title"),"title"):U(e)??r(e.getAttribute("title"),"title")??r(e.querySelector("img")?.getAttribute("alt"),"alt")??(n?r(e.value,"value"):void 0)}function U(e){let t={left:W},n=!!e.querySelector(B),{text:r,heading:o}=S(e,t,n);if(!r)return;if(r.length<=_)return{label:r,source:"text"};let i=o&&S(o,t,!1).text;return i?{label:i.slice(0,_),source:"heading"}:{label:r.slice(0,_),source:"text"}}function S(e,t,n){let r="",o,i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,{acceptNode:a=>a.nodeType===1&&X(a)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT});for(let a=i.nextNode();a&&t.left-- >0&&(a.nodeType===3?r+=a.nodeValue.replace(/\s+/g," "):n&&!o&&/^h[1-6]$/.test(a.localName)&&(o=a),!(r.length>_+1&&(o||!n)));a=i.nextNode());return{text:r.replace(/\s+/g," ").trim(),heading:o}}function X(e){return/^(?:svg|script|style)$/.test(e.localName)||e.getAttribute("aria-hidden")==="true"||e.hasAttribute("hidden")||e.hasAttribute("data-depsmith-sdk-mask")}function A(e,t){let n=e.textContent??"";return e!==t&&e.contains(t)&&(n=n.replace(t.textContent??"","")),L(n)||void 0}function N(e,t){let n={};if(t.length===0||e.closest("[data-depsmith-sdk-mask]"))return n;for(let r of t)try{let i=e.closest(`[data-${r}]`)?.getAttribute(`data-${r}`);i&&(n[`$ac_attr_${r.replace(/-/g,"_")}`]=L(i))}catch{}return n}function L(e){return e.trim().replace(/\s+/g," ").slice(0,255)}var G='a, button, [role="button"], input[type="submit"], input[type="button"], [data-depsmith-sdk-capture]';function de(e,t){let n=[],r={...e,ignore:k(e.selectorIgnore??[],t.warn)};r.clicks&&n.push(Q(r,t));let o=null;r.forms&&(o=Z(r,t),n.push(o.stop));let i=null;r.scrolls&&(i=te(t),n.push(i.stop));let a=()=>t.pageLeave(i?.maxDepth()),c=[...r.pageviews?[a]:[],...i?[i.rearm]:[],...o?[o.rearm]:[],...r.pageviews?[()=>t.page(oe)]:[]];return r.pageviews&&(t.page(),t.armUnloadLeave(a)),c.length>0&&n.push(ce(r.pageviews==="all"?se:ae,()=>{for(let l of c)l()})),()=>{for(let l of n.splice(0))l()}}function D(e,t){let n={$ac_selector:x(e,t.selectorMaxDepth,t.ignore),$ac_tag:e.tagName.toLowerCase()};e.id&&(n.$ac_id=e.id);let r=e.getAttribute("class")?.trim().replace(/\s+/g," ");r&&(n.$ac_classes=r.slice(0,255));let o=I(e);o&&(n.$ac_aria_label=o);let i=R(e);i&&(n.$ac_parent_label=i);let a=M(e);return a&&(n.$ac_label=a.label,n.$ac_label_source=a.source),{...n,...N(e,t.attributes)}}function O(){return{$ac_viewport_w:window.innerWidth,$ac_viewport_h:window.innerHeight}}var j=/\.(pdf|zip|7z|rar|gz|tar|docx?|xlsx?|pptx?|csv|txt|rtf|mp4|mov|avi|mp3|wav|dmg|pkg|exe|apk)$/i;function q(e){if(!(e instanceof HTMLAnchorElement)||!e.href)return;let t;try{t=new URL(e.href).pathname}catch{return}let n=decodeURIComponent(t.slice(t.lastIndexOf("/")+1)),r=j.exec(t);if(!(!r&&!e.hasAttribute("download"))&&n)return{ext:r?r[1].toLowerCase():"",name:n}}var K=1e3,Y=4,V=1e3;function J(){let e=null,t=[],n=!1;return(r,o,i,a)=>(r!==e&&(e=r,t=[],n=!1),t=t.filter(c=>o-c.t<=K),t.length===0&&(n=!1),t.push({t:o,x:i,y:a}),n||t.length<Y?null:(n=!0,{count:t.length,begin:t[0].t,end:o,clicks:t.slice()}))}function Q(e,t){let n=e.clicks!=="all",r=J(),o=null,i=c=>{if(!o||Date.now()-o.at>V)return;let l={...o.properties,$ac_kind:"error_click",$fr_error_message:String(c.message??"").slice(0,255)},u=c.error;u instanceof Error&&(l.$fr_error_type=u.name,u.stack&&(l.$fr_error_stack=u.stack.slice(0,1e3))),c.filename&&(l.$fr_error_file=c.filename),c.lineno&&(l.$fr_error_line=c.lineno),c.colno&&(l.$fr_error_column=c.colno),t.emit(l),o=null},a=c=>{let l=c.target;if(!(l instanceof Element))return;let u=l.closest(G);if(n&&!u)return;let s=u??l;if(b(s,e.ignoredSelectors))return;let d=q(s),f={$ac_kind:d?"file_download":"click",...D(s,e),$ac_x:c.clientX,$ac_y:c.clientY,...O()},h=H(s);h&&(f.$ac_text=h),s instanceof HTMLAnchorElement&&s.href&&(f.$ac_href=s.href),d&&(f.$ac_file_name=d.name,d.ext&&(f.$ac_file_ext=d.ext)),t.emit(f);let m=r(s,Date.now(),c.clientX,c.clientY);m&&t.emit({...f,$ac_kind:"rage_click",$fr_click_count:m.count,$fr_begin:m.begin,$fr_end:m.end,$fr_duration_ms:m.end-m.begin,$fr_clicks:m.clicks.map(p=>`${p.t-m.begin},${p.x},${p.y}`)}),o={at:Date.now(),properties:f}};return document.documentElement.addEventListener("click",a,{capture:!0,passive:!0}),window.addEventListener("error",i),()=>{document.documentElement.removeEventListener("click",a,{capture:!0}),window.removeEventListener("error",i)}}function F(e){let t={$ac_form_id:e.id||null},n=e.getAttribute("name");n&&(t.$ac_form_name=n);let r=e.getAttribute("action");return r&&(t.$ac_form_action=r),t}function Z(e,t){let n=new WeakSet,r=u=>{let s=u.target;if(!(s instanceof HTMLFormElement)||b(s,e.ignoredSelectors))return;let d=Array.from(s.elements).filter(f=>f instanceof HTMLInputElement&&!C(f)).map(f=>f.name||f.id).filter(Boolean).slice(0,50);t.emit({$ac_kind:"form_submit",$ac_selector:x(s,e.selectorMaxDepth,e.ignore),...F(s),$ac_form_fields:d})},o=u=>{let s=u.closest("form");!s||n.has(s)||b(s,e.ignoredSelectors)||b(u,e.ignoredSelectors)||(n.add(s),t.emit({$ac_kind:"form_start",$ac_selector:x(s,e.selectorMaxDepth,e.ignore),...F(s)}))},i=u=>{u.target instanceof Element&&o(u.target)},a=u=>{let s=u.target;!(s instanceof Element)||(o(s),!(s instanceof HTMLSelectElement||s instanceof HTMLInputElement&&(s.type==="checkbox"||s.type==="radio"))||b(s,e.ignoredSelectors))||t.emit({$ac_kind:"change",...D(s,e),...O()})},c=document.documentElement,l={capture:!0,passive:!0};return c.addEventListener("submit",r,l),c.addEventListener("input",i,l),c.addEventListener("change",a,l),{stop:()=>{c.removeEventListener("submit",r,{capture:!0}),c.removeEventListener("input",i,{capture:!0}),c.removeEventListener("change",a,{capture:!0})},rearm:()=>{n=new WeakSet}}}var E=[25,50,75,100],ee=240;function te(e){let t=0,n=-1,r=0,o=!1,i,a=()=>{n=i?i.scrollHeight-i.clientHeight:document.documentElement.scrollHeight-window.innerHeight},c=()=>Math.min(100,Math.round((i?i.scrollTop:window.scrollY)/n*100)),l=()=>{if(r=0,n<=0&&a(),n<=0||c()<E[t]||(a(),n<=0))return;let p=c();for(;t<E.length&&p>=E[t];)e.emit({$ac_kind:"scroll_depth",$ac_depth:E[t]}),t++;t>=E.length&&m()},u=p=>{if(i&&!i.isConnected&&(i=void 0),i===null&&n===0&&(i=void 0),i===void 0){let g=p.target;if(!(g instanceof Element)||g===document.documentElement||document.documentElement.scrollHeight>window.innerHeight)i=null;else{let w=g;if(w.scrollHeight-w.clientHeight<ee)return;i=w}n=-1,f()}else if(i&&p.target!==i)return;r===0&&(r=ne(l))},s=()=>{n=-1},d=null,f=()=>{if(!(typeof ResizeObserver>"u"))try{if(d?.disconnect(),d=new ResizeObserver(s),d.observe(i??document.documentElement),i){let p=i.children;for(let g=0;g<p.length;g++)d.observe(p[g])}}catch{d=null}},h=()=>{o||(o=!0,window.addEventListener("scroll",u,{capture:!0,passive:!0}),window.addEventListener("resize",s,{passive:!0}),window.addEventListener("orientationchange",s,{passive:!0}),f())},m=()=>{o&&(o=!1,window.removeEventListener("scroll",u,{capture:!0}),window.removeEventListener("resize",s),window.removeEventListener("orientationchange",s),d?.disconnect(),d=null)};return h(),{maxDepth:()=>t>0?E[t-1]:0,stop:()=>{r!==0&&re(r),r=0,m()},rearm:()=>{t=0,n=-1,i=void 0,h()}}}function ne(e){return typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(e,16)}function re(e){typeof cancelAnimationFrame=="function"?cancelAnimationFrame(e):clearTimeout(e)}var ie=300;function oe(e,t){let n=setTimeout(t,ie),r;try{r=new MutationObserver(()=>{document.title!==e&&t()}),r.observe(document.head,{childList:!0,subtree:!0,characterData:!0})}catch{}return()=>{clearTimeout(n),r?.disconnect()}}var ae=e=>e.pathname,se=e=>e.href;function ce(e,t){let n=e(location),r=()=>{let a=e(location);a!==n&&(n=a,t())},o=history.pushState.bind(history),i=history.replaceState.bind(history);return history.pushState=(...a)=>{o(...a),r()},history.replaceState=(...a)=>{i(...a),r()},window.addEventListener("popstate",r),()=>{history.pushState=o,history.replaceState=i,window.removeEventListener("popstate",r)}}export{de as startAutocapture};
2
2
  //# sourceMappingURL=autocapture.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/autocapture/selector.ts","../src/autocapture/index.ts"],"sourcesContent":["/** CSS selector generation for autocaptured elements, capped at a configurable depth. */\nexport function elementSelector(element: Element, maxDepth: number): string {\n const parts: string[] = [];\n let current: Element | null = element;\n\n while (current && current !== document.documentElement && parts.length < maxDepth) {\n let part = current.tagName.toLowerCase();\n if (current.id) {\n parts.unshift(`${part}#${current.id}`);\n break; // ids are unique enough — stop here\n }\n const classes = Array.from(current.classList).slice(0, 3);\n if (classes.length) part += `.${classes.join('.')}`;\n\n const parent: Element | null = current.parentElement;\n if (parent) {\n const siblings = Array.from(parent.children).filter((c) => c.tagName === current!.tagName);\n if (siblings.length > 1) part += `:nth-of-type(${siblings.indexOf(current) + 1})`;\n }\n parts.unshift(part);\n current = parent;\n }\n\n return parts.join(' > ');\n}\n\n/** True when the element (or an ancestor) opts out of autocapture. */\nexport function isIgnored(element: Element, ignoredSelectors: string[]): boolean {\n if (element.closest('[data-depsmith-sdk-no-capture]')) return true;\n for (const selector of ignoredSelectors) {\n try {\n if (element.closest(selector)) return true;\n } catch {\n // invalid selector in config — skip it\n }\n }\n return false;\n}\n\nconst SENSITIVE_INPUT_TYPES = new Set(['password', 'email', 'tel', 'hidden', 'number']);\n\n/** Element text, aggressively masked: never inputs, never [data-depsmith-sdk-mask], 255-char cap. */\nexport function safeText(element: Element): string | undefined {\n if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement) return undefined;\n if (element.closest('[data-depsmith-sdk-mask]')) return undefined;\n const text = element.textContent?.trim().replace(/\\s+/g, ' ');\n return text ? text.slice(0, 255) : undefined;\n}\n\nexport function isSensitiveField(input: Element): boolean {\n if (!(input instanceof HTMLInputElement)) return false;\n return SENSITIVE_INPUT_TYPES.has(input.type) || !!input.closest('[data-depsmith-sdk-mask]');\n}\n\n/**\n * Author-written label text for an element, masked like `safeText`.\n *\n * `aria-label` first, then the element's own accessible name sources in the order a screen\n * reader would reach them. This is what makes an icon button legible in analytics: a `<button>`\n * whose only content is an `<svg>` has no text at all today, so every close, delete and\n * favourite control on a page is indistinguishable.\n */\nexport function ariaLabel(element: Element): string | undefined {\n if (element.closest('[data-depsmith-sdk-mask]')) return undefined;\n const label = element.getAttribute('aria-label');\n return label ? clip(label) : undefined;\n}\n\n/**\n * The nearest enclosing label for a control: its `<label>`, or the `<legend>` of its\n * `<fieldset>`.\n *\n * Bounded to those two, deliberately. \"Nearest label text from a parent\" invites walking up\n * until something has text, which on a real page reaches a section heading or the whole form and\n * reports that as the field's label — worse than reporting nothing. Both of these are elements\n * whose stated purpose IS to name the thing inside them.\n *\n * Returns the label's text WITHOUT the control's own, so a `<label>` wrapping its input does not\n * echo a value back; and nothing at all under a mask.\n */\nexport function parentLabel(element: Element): string | undefined {\n if (element.closest('[data-depsmith-sdk-mask]')) return undefined;\n const label = element.closest('label');\n if (label) {\n const text = labelText(label, element);\n if (text) return text;\n }\n const legend = element.closest('fieldset')?.querySelector(':scope > legend');\n return legend ? labelText(legend, element) : undefined;\n}\n\n/** Text of `container`, minus any text contributed by `exclude`. */\nfunction labelText(container: Element, exclude: Element): string | undefined {\n let text = container.textContent ?? '';\n if (container !== exclude && container.contains(exclude)) {\n text = text.replace(exclude.textContent ?? '', '');\n }\n const clipped = clip(text);\n return clipped || undefined;\n}\n\n/**\n * Allow-listed `data-*` values as `$ac_attr_<name>`.\n *\n * Read from the element or the nearest ancestor that has it, because the attribute is usually on\n * the product card rather than the button inside it. Masked subtrees yield nothing.\n */\nexport function dataAttributes(element: Element, names: readonly string[]): Record<string, string> {\n const out: Record<string, string> = {};\n if (names.length === 0 || element.closest('[data-depsmith-sdk-mask]')) return out;\n for (const name of names) {\n // `name` comes from config; an invalid attribute name would make closest() throw.\n try {\n const source = element.closest(`[data-${name}]`);\n const value = source?.getAttribute(`data-${name}`);\n if (value) out[`$ac_attr_${name.replace(/-/g, '_')}`] = clip(value);\n } catch {\n /* unusable attribute name in config — skip it */\n }\n }\n return out;\n}\n\n/** Collapse whitespace and cap, the same treatment safeText gives element text. */\nfunction clip(value: string): string {\n return value.trim().replace(/\\s+/g, ' ').slice(0, 255);\n}\n","/**\n * Web autocapture engine — lazily loaded so the core bundle stays under 10KB gz.\n * Clicks (delegation), form submits (values never captured), scroll depth\n * (quartiles), and SPA pageviews (History API patch). See API_SPEC §3 for the\n * reserved $autocapture event.\n */\nimport type { AutocaptureConfig } from '../config';\nimport type { Properties } from '../types';\nimport {\n ariaLabel,\n dataAttributes,\n elementSelector,\n isIgnored,\n isSensitiveField,\n parentLabel,\n safeText,\n} from './selector';\n\nexport interface AutocaptureHooks {\n /** Emits a $autocapture event through the client pipeline. */\n emit(properties: Properties): void;\n /**\n * Emits a $page_view through the client pipeline, for the landing page and every SPA\n * navigation. The client dedupes by URL, so calling it twice for one page emits once.\n */\n page(): void;\n /**\n * Emits a $page_leave for the page being left. `maxScroll` is the deepest quartile reached,\n * or undefined when scroll tracking is off.\n */\n pageLeave(maxScroll?: number): void;\n /**\n * Hands the client the unload-time `$page_leave` trigger, to call from its own `pagehide`\n * handler.\n *\n * Autocapture cannot own that listener. It is loaded from a dynamic import, so its listener\n * is always registered after the client's — and the client's drains the queue with\n * `sendBeacon`. A `$page_leave` captured after that drain never leaves the page.\n */\n armUnloadLeave(leave: () => void): void;\n}\n\n/** Elements a click is attributed to when `clicks: 'interactive'`. */\nconst INTERACTIVE_SELECTOR =\n 'a, button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"], [data-depsmith-sdk-capture]';\n\nexport function startAutocapture(\n config: Required<AutocaptureConfig>,\n hooks: AutocaptureHooks\n): () => void {\n const teardowns: Array<() => void> = [];\n\n if (config.clicks) teardowns.push(captureClicks(config, hooks));\n\n let forms: FormTracker | null = null;\n if (config.forms) {\n forms = captureForms(config, hooks);\n teardowns.push(forms.stop);\n }\n\n let scroll: ScrollTracker | null = null;\n if (config.scrolls) {\n scroll = captureScrollDepth(hooks);\n teardowns.push(scroll.stop);\n }\n\n const leave = (): void => hooks.pageLeave(scroll?.maxDepth());\n\n /**\n * Run on SPA navigation. Composed explicitly rather than by push order, because the order is\n * load-bearing in two places:\n *\n * 1. `$page_leave` must precede `$page_view`. It describes the page being LEFT, and the\n * client reads the outgoing URL from its page tracker — which the pageview then advances.\n * 2. `$page_leave` must precede `scroll.rearm`, which zeroes the quartiles that\n * `$page_max_scroll` reports.\n */\n const onNavigate: Array<() => void> = [\n ...(config.pageviews ? [leave] : []),\n ...(scroll ? [scroll.rearm] : []),\n // `form_start` is once per form per PAGE VIEW, so a route change has to forget what it saw.\n // Without this, a checkout wizard that keeps one <form> across steps reports a start on\n // step one and nothing afterwards.\n ...(forms ? [forms.rearm] : []),\n ...(config.pageviews ? [hooks.page] : []),\n ];\n\n if (config.pageviews) {\n // The first page a visitor lands on was never recorded: `hooks.page` was wired only to\n // navigation, so a plain multi-page site reported no pageviews at all and an SPA missed its\n // entry page. Fire once here, after the features above are armed, so the landing pageview\n // carries the same state a route change would. The client dedupes by URL, so this cannot\n // double-fire with a framework that replaceState()s to the same URL during hydration.\n hooks.page();\n // The other half of the pair: this `leave` covers SPA route changes, the client's `pagehide`\n // handler covers leaving the document for good.\n hooks.armUnloadLeave(leave);\n }\n\n // One History patch feeding every navigation-sensitive feature, rather than one per\n // feature. Scroll depth needs the same signal pageviews do — without it, a re-armed\n // quartile set on an SPA route change is unreachable once the listener has detached.\n if (onNavigate.length > 0) {\n teardowns.push(\n observeNavigation(() => {\n for (const fn of onNavigate) fn();\n })\n );\n }\n\n return () => {\n for (const stop of teardowns.splice(0)) stop();\n };\n}\n\n/**\n * Identity and labelling shared by `click`, `file_download` and `change`.\n *\n * `id` and `classes` are emitted even under a mask: they are structural, they are already inside\n * `$ac_selector`, and suppressing them there while publishing the selector would be theatre.\n * Everything that can carry author or user text — aria-label, the enclosing label, allow-listed\n * data values — goes through the masking helpers in selector.ts instead.\n */\nfunction elementProperties(element: Element, config: Required<AutocaptureConfig>): Properties {\n const properties: Properties = {\n $ac_selector: elementSelector(element, config.selectorMaxDepth),\n $ac_tag: element.tagName.toLowerCase(),\n };\n if (element.id) properties.$ac_id = element.id;\n // Capped like every other unbounded string: a utility-CSS page puts thirty classes on a button.\n const classes = element.getAttribute('class')?.trim().replace(/\\s+/g, ' ');\n if (classes) properties.$ac_classes = classes.slice(0, 255);\n const aria = ariaLabel(element);\n if (aria) properties.$ac_aria_label = aria;\n const parent = parentLabel(element);\n if (parent) properties.$ac_parent_label = parent;\n return { ...properties, ...dataAttributes(element, config.attributes) };\n}\n\n/** Viewport, for reading click coordinates against the layout they happened in. */\nfunction viewport(): Properties {\n // innerWidth/innerHeight are plain property reads — no layout flush, unlike scrollHeight.\n return { $ac_viewport_w: window.innerWidth, $ac_viewport_h: window.innerHeight };\n}\n\n/**\n * Extensions that make a link a download rather than a navigation.\n *\n * Deliberately not images: a click on a `.png` is almost always \"open the photo\", and counting\n * every lightbox as a file download would bury the handful of real ones. A `download` attribute\n * always wins regardless of extension, which is the author stating intent.\n */\nconst DOWNLOAD_EXTENSIONS =\n /\\.(pdf|zip|7z|rar|gz|tar|docx?|xlsx?|pptx?|csv|txt|rtf|mp4|mov|avi|mp3|wav|dmg|pkg|exe|apk)$/i;\n\n/** `{ext, name}` when this element is a link to a file, else undefined. */\nfunction fileTarget(element: Element): { ext: string; name: string } | undefined {\n if (!(element instanceof HTMLAnchorElement) || !element.href) return undefined;\n let path: string;\n try {\n // The pathname, so `?v=2#page` cannot hide the extension or end up in the file name.\n path = new URL(element.href).pathname;\n } catch {\n return undefined;\n }\n const name = decodeURIComponent(path.slice(path.lastIndexOf('/') + 1));\n const match = DOWNLOAD_EXTENSIONS.exec(path);\n // `download` is the author's own declaration, so it counts even with no extension at all.\n if (!match && !element.hasAttribute('download')) return undefined;\n if (!name) return undefined;\n return { ext: match ? match[1]!.toLowerCase() : '', name };\n}\n\n/** Clicks on one element within this window count towards a rage click. */\nconst RAGE_WINDOW_MS = 1000;\n/** How many clicks make it rage rather than impatience. */\nconst RAGE_THRESHOLD = 4;\n/** How long after a click a script error is still attributed to it. */\nconst ERROR_CLICK_WINDOW_MS = 1000;\n\ninterface RageClick {\n count: number;\n begin: number;\n end: number;\n clicks: Array<{ t: number; x: number; y: number }>;\n}\n\n/**\n * Rage clicks: four or more clicks on the SAME element within a second (spec item 13).\n *\n * Keyed on the element, not on a position: a user hammering a button that has moved underneath them\n * is still raging at that button, and a coordinate-keyed detector would miss exactly the case where\n * the UI is shifting — the one most likely to be frustrating in the first place.\n *\n * Reports on the fourth click, not when the burst ends on a timer: a timer needs the burst to finish\n * before reporting, so a rage that ends in a navigation — the common shape — would be lost to the\n * unload.\n *\n * And exactly ONCE per burst. Reporting every click past the threshold looked reasonable and was\n * measured at 37 events for one benchmark walk, nearly doubling its upload volume — one angry user\n * producing seventeen events is the firehose this engine avoids everywhere else. The signal is \"this\n * element was rage-clicked\", which one event carries; `$fr_click_count` is therefore the threshold\n * rather than the burst's eventual size, and that is a deliberate trade rather than an oversight.\n */\nfunction rageTracker(): (element: Element, now: number, x: number, y: number) => RageClick | null {\n let target: Element | null = null;\n let clicks: Array<{ t: number; x: number; y: number }> = [];\n let reported = false;\n\n return (element, now, x, y) => {\n if (element !== target) {\n target = element;\n clicks = [];\n reported = false;\n }\n // Drop clicks that fell outside the window, so a slowly repeated click never accumulates.\n clicks = clicks.filter((click) => now - click.t <= RAGE_WINDOW_MS);\n // The window emptying is what ends a burst, so a later burst on the same element reports again.\n if (clicks.length === 0) reported = false;\n clicks.push({ t: now, x, y });\n if (reported || clicks.length < RAGE_THRESHOLD) return null;\n reported = true;\n return { count: clicks.length, begin: clicks[0]!.t, end: now, clicks: clicks.slice() };\n };\n}\n\nfunction captureClicks(config: Required<AutocaptureConfig>, hooks: AutocaptureHooks): () => void {\n // `true` means \"capture clicks\", not \"capture every click on the page\" — it resolves to\n // the interactive gate like the default does. Emitting a $autocapture for a tap on a\n // product image or a bare layout <div> is a firehose that costs a queue write per event\n // and buries the clicks that carry intent, so it takes an explicit 'all' to ask for it.\n const interactiveOnly = config.clicks !== 'all';\n const rage = rageTracker();\n /** The most recent click, so a script error just after one can be attributed to it. */\n let lastClick: { at: number; properties: Properties } | null = null;\n\n /**\n * `error_click`: a script error within ERROR_CLICK_WINDOW_MS of a click (spec item 13).\n *\n * Attribution by proximity in time, which is the honest limit of what a listener can know — an\n * error carries no reference to the interaction that caused it. The window is deliberately short\n * for that reason: the longer it is, the more unrelated errors get blamed on the last click.\n */\n const onError = (event: ErrorEvent): void => {\n if (!lastClick || Date.now() - lastClick.at > ERROR_CLICK_WINDOW_MS) return;\n const properties: Properties = {\n ...lastClick.properties,\n $ac_kind: 'error_click',\n $fr_error_message: String(event.message ?? '').slice(0, 255),\n };\n const error: unknown = event.error;\n if (error instanceof Error) {\n properties.$fr_error_type = error.name;\n // Capped hard: a stack is unbounded, and the top frames are where the cause is.\n if (error.stack) properties.$fr_error_stack = error.stack.slice(0, 1000);\n }\n if (event.filename) properties.$fr_error_file = event.filename;\n if (event.lineno) properties.$fr_error_line = event.lineno;\n if (event.colno) properties.$fr_error_column = event.colno;\n hooks.emit(properties);\n // One error per click: a single failure often fires repeatedly (a render loop), and each one\n // would otherwise be blamed on the same click.\n lastClick = null;\n };\n\n const onClick = (event: MouseEvent): void => {\n const target = event.target;\n if (!(target instanceof Element)) return;\n const interactive = target.closest(INTERACTIVE_SELECTOR);\n if (interactiveOnly && !interactive) return;\n const element = interactive ?? target;\n if (isIgnored(element, config.ignoredSelectors)) return;\n\n const file = fileTarget(element);\n const properties: Properties = {\n // A download REPLACES the click rather than adding an event, so one interaction stays one\n // event and existing click counts do not double when this ships.\n $ac_kind: file ? 'file_download' : 'click',\n ...elementProperties(element, config),\n $ac_x: event.clientX,\n $ac_y: event.clientY,\n ...viewport(),\n };\n const text = safeText(element);\n if (text) properties.$ac_text = text;\n if (element instanceof HTMLAnchorElement && element.href) properties.$ac_href = element.href;\n if (file) {\n properties.$ac_file_name = file.name;\n if (file.ext) properties.$ac_file_ext = file.ext;\n }\n\n hooks.emit(properties);\n\n // A SEPARATE event, not a flag on the click: a rage click is a different question, and folding\n // it in would make \"how many clicks did this button get\" undercount by four.\n const burst = rage(element, Date.now(), event.clientX, event.clientY);\n if (burst) {\n hooks.emit({\n ...properties,\n $ac_kind: 'rage_click',\n $fr_click_count: burst.count,\n $fr_begin: burst.begin,\n $fr_end: burst.end,\n $fr_duration_ms: burst.end - burst.begin,\n // The individual clicks, so a heat map can show the burst rather than only its size. Times\n // and coordinates only — no content, like everything else here.\n //\n // Encoded as \"<msFromBegin>,<x>,<y>\" strings rather than objects, because the schema allows\n // at most ONE level of nesting in properties (event.schema.json propertyValue) and an array\n // of objects is two. Offsets rather than absolute times: they stay small, and $fr_begin\n // already carries the epoch.\n $fr_clicks: burst.clicks.map((click) => `${click.t - burst.begin},${click.x},${click.y}`),\n });\n }\n lastClick = { at: Date.now(), properties };\n };\n\n document.documentElement.addEventListener('click', onClick, { capture: true, passive: true });\n window.addEventListener('error', onError);\n return () => {\n document.documentElement.removeEventListener('click', onClick, { capture: true });\n window.removeEventListener('error', onError);\n };\n}\n\n/** `name` and `action` of a form, on both `form_start` and `form_submit`. */\nfunction formProperties(form: HTMLFormElement): Properties {\n const properties: Properties = { $ac_form_id: form.id || null };\n const name = form.getAttribute('name');\n if (name) properties.$ac_form_name = name;\n // The resolved attribute, not form.action — that falls back to the current page URL when the\n // attribute is absent, which reports a destination the markup never declared.\n const action = form.getAttribute('action');\n if (action) properties.$ac_form_action = action;\n return properties;\n}\n\ninterface FormTracker {\n stop(): void;\n /** Forgets which forms were started, so a new SPA route can report its own form_start. */\n rearm(): void;\n}\n\n/**\n * `form_start`, `change` and `form_submit`.\n *\n * `form_start` answers the question a submit-only view cannot: who began a form and gave up.\n * It fires once per form per page view — on the first `input` or `change` inside it — because the\n * useful signal is \"this form was attempted\", and one event per keystroke would be a firehose\n * that also tells you when someone typed, which is closer to user data than to behaviour.\n *\n * `change` covers selects, checkboxes and radios only. Text inputs are excluded deliberately:\n * their change event fires on blur with the field complete, so it would mark exactly the moments a\n * value exists — and the value is the one thing never captured here.\n */\nfunction captureForms(config: Required<AutocaptureConfig>, hooks: AutocaptureHooks): FormTracker {\n // Identity-keyed, so a form removed from the DOM is collectable rather than pinned by this set.\n let started = new WeakSet<HTMLFormElement>();\n\n const onSubmit = (event: Event): void => {\n const form = event.target;\n if (!(form instanceof HTMLFormElement)) return;\n if (isIgnored(form, config.ignoredSelectors)) return;\n\n // Field NAMES only — values are never captured (privacy by construction).\n const fields = Array.from(form.elements)\n .filter((el): el is HTMLInputElement => el instanceof HTMLInputElement && !isSensitiveField(el))\n .map((el) => el.name || el.id)\n .filter(Boolean)\n .slice(0, 50);\n\n hooks.emit({\n $ac_kind: 'form_submit',\n $ac_selector: elementSelector(form, config.selectorMaxDepth),\n ...formProperties(form),\n $ac_form_fields: fields,\n });\n };\n\n /** First interaction with a field inside a form, for form_start. */\n const noteFormStart = (target: Element): void => {\n const form = target.closest('form');\n if (!form || started.has(form)) return;\n if (isIgnored(form, config.ignoredSelectors) || isIgnored(target, config.ignoredSelectors)) {\n return;\n }\n started.add(form);\n hooks.emit({\n $ac_kind: 'form_start',\n $ac_selector: elementSelector(form, config.selectorMaxDepth),\n ...formProperties(form),\n });\n };\n\n const onInput = (event: Event): void => {\n if (event.target instanceof Element) noteFormStart(event.target);\n };\n\n /**\n * One `change` listener for both kinds, not two.\n *\n * A change is a form_start candidate AND possibly a `change` event, and registering a handler\n * per concern put three new listeners on `document.documentElement` — which the A/B benchmark\n * gates on (`listeners_at_init_delta`), because every document-level capture listener is on the\n * path of every event of that type on the page.\n */\n const onChange = (event: Event): void => {\n const target = event.target;\n if (!(target instanceof Element)) return;\n noteFormStart(target);\n\n const isChoice =\n target instanceof HTMLSelectElement ||\n (target instanceof HTMLInputElement && (target.type === 'checkbox' || target.type === 'radio'));\n if (!isChoice || isIgnored(target, config.ignoredSelectors)) return;\n // No text, no href and no value: WHICH control changed, never what it was changed to. Not\n // even checked/selected — that is the value in a one-bit disguise.\n //\n // No $ac_x/$ac_y either: a change can come from a keyboard or an assistive device, and there\n // is no pointer position to report. Fabricating 0,0 would read as a click in the corner.\n hooks.emit({ $ac_kind: 'change', ...elementProperties(target, config), ...viewport() });\n };\n\n const root = document.documentElement;\n const options = { capture: true, passive: true } as const;\n root.addEventListener('submit', onSubmit, options);\n root.addEventListener('input', onInput, options);\n root.addEventListener('change', onChange, options);\n return {\n stop: () => {\n root.removeEventListener('submit', onSubmit, { capture: true });\n root.removeEventListener('input', onInput, { capture: true });\n root.removeEventListener('change', onChange, { capture: true });\n },\n rearm: () => {\n started = new WeakSet<HTMLFormElement>();\n },\n };\n}\n\nconst QUARTILES = [25, 50, 75, 100] as const;\n\n/**\n * Vertical overflow an element needs before it counts as the page's scroller.\n *\n * Roughly a phone viewport. Below it a box is an in-page control — a size-guide popover, a\n * variant list, a sticky mini-cart — and reporting \"100% scroll depth\" because someone\n * flicked through six shipping options would be worse than reporting nothing.\n */\nconst MIN_HOST_SCROLLABLE_PX = 240;\n\ninterface ScrollTracker {\n stop(): void;\n /** Re-arms the quartiles for a new SPA route, re-attaching if we had detached at 100%. */\n rearm(): void;\n /**\n * Deepest quartile crossed on the current page, for `$page_leave`'s `$page_max_scroll`.\n * Reads the already-crossed quartile rather than live layout, so asking for it during\n * `pagehide` — where there is no budget for a layout read — costs nothing.\n */\n maxDepth(): number;\n}\n\n/**\n * Scroll-depth quartiles, without a layout read per scroll event.\n *\n * The previous version read `document.documentElement.scrollHeight` inside the scroll\n * handler. That forces a synchronous style + layout flush, and scroll fires at input\n * frequency — so it was a forced reflow per frame, for the life of the page, and the\n * listener stayed attached long after all four quartiles had fired.\n *\n * Three changes make it cheap:\n * - handling is coalesced into one `requestAnimationFrame` callback per frame;\n * - the scrollable height is cached, invalidated whenever the document actually resizes,\n * and otherwise re-measured only when the cached value says we are about to cross a\n * quartile — so a lazily growing page still reports accurately, at ≤4 layout reads;\n * - the listener detaches once 100% is reached, since there is nothing left to report.\n *\n * Depth is measured against whichever box actually scrolls. Listening on `window` only\n * ever sees the viewport, so a theme whose `documentElement` and `body` are both\n * `overflow: hidden` — the content scrolling inside a wrapper instead, which is common on\n * modern Shopify themes — emitted nothing at all, for the life of the page, with no error\n * and no way to tell from the outside that the feature was inert.\n *\n * The document has ABSOLUTE PRECEDENCE in that choice: if the document can scroll at all,\n * depth is the document's, no matter which box happened to scroll first. An in-page\n * scroller is only ever adopted on a page where the document is flat. That ordering is what\n * keeps this strictly additive — every page that reported correctly before still does, and\n * the wrapper themes that reported nothing now report too.\n *\n * Invalidation watches the DOCUMENT, not just the window. `resize` fires for the viewport\n * only, so in-page height changes — a filter removing rows, an accordion collapsing, a\n * dismissed banner — left a stale, too-large `scrollable` behind, and `percent()` then\n * under-reported forever: no further quartile could ever fire. The same staleness made a\n * first measurement of exactly 0 (content one viewport tall, lazy content still to land)\n * permanent, because 0 does not satisfy the `< 0` re-measure guard.\n */\nfunction captureScrollDepth(hooks: AutocaptureHooks): ScrollTracker {\n /** Index into QUARTILES; everything below it has already been emitted. */\n let reached = 0;\n /** Cached scrollable extent of {@link host}. -1 means \"needs measuring\". */\n let scrollable = -1;\n /** Pending frame handle, or 0 when none is scheduled. */\n let frame = 0;\n let attached = false;\n /**\n * What depth is measured against, as a three-state value: `undefined` is \"not resolved\n * yet\", `null` is the viewport, an Element is an in-page scroller.\n *\n * Resolved from the first qualifying scroll event rather than searched for, so a\n * container that only exists after hydration is picked up for free — and so resolution\n * costs one layout read for the life of the page instead of a DOM walk at init.\n */\n let host: Element | null | undefined;\n\n const measure = (): void => {\n scrollable = host\n ? host.scrollHeight - host.clientHeight\n : document.documentElement.scrollHeight - window.innerHeight;\n };\n\n const percent = (): number =>\n Math.min(100, Math.round(((host ? host.scrollTop : window.scrollY) / scrollable) * 100));\n\n const evaluate = (): void => {\n frame = 0;\n // `<= 0`, not `< 0`: a page that measured as unscrollable must be re-measured rather\n // than written off, or content arriving after first paint never becomes reportable.\n // Costs nothing in the steady state — an unscrollable page emits no scroll events.\n if (scrollable <= 0) measure();\n if (scrollable <= 0) return;\n // Cheap path: cached metrics say we have not reached the next quartile, so there is\n // nothing to report and no reason to touch layout.\n if (percent() < QUARTILES[reached]!) return;\n\n // About to emit — confirm against live layout, since the page may have grown since we\n // last measured (lazy images, infinite scroll) and the cached value would over-report.\n measure();\n if (scrollable <= 0) return;\n const depth = percent();\n while (reached < QUARTILES.length && depth >= QUARTILES[reached]!) {\n hooks.emit({ $ac_kind: 'scroll_depth', $ac_depth: QUARTILES[reached]! });\n reached++;\n }\n if (reached >= QUARTILES.length) detach();\n };\n\n const onScroll = (event: Event): void => {\n // Give the host back when it can no longer be the page, and let the next branch resolve\n // again. Two ways that happens:\n //\n // - an ELEMENT host went away. A wrapper re-mounted without a history change — a\n // filter rebuilding the product grid — leaves a detached node whose metrics freeze.\n // - the VIEWPORT was adopted, has since measured as genuinely unscrollable, and\n // something else just scrolled. Only reachable once `evaluate` has measured a real\n // zero, so it costs nothing on a page that scrolls, and it keeps the viewport's\n // precedence below from being a one-way door on a theme that fires a stray window\n // scroll before its wrapper ever moves.\n //\n // `reached` deliberately survives both: still the same route, so quartiles already\n // reported must not report a second time.\n if (host && !host.isConnected) host = undefined;\n if (host === null && scrollable === 0) host = undefined;\n\n if (host === undefined) {\n // Resolved from the first scroll that actually happens, rather than by searching the\n // DOM at init: a wrapper that only exists after hydration is picked up for free, and\n // the layout reads below are paid once for the life of the page, not once per frame.\n const target = event.target;\n // THE PAGE WINS WHENEVER THE PAGE CAN SCROLL AT ALL — whatever fired this event.\n // `scroll_depth` has always meant \"how far down the page\", and on an ordinary page an\n // in-page box (a size-guide modal, a cart drawer, a sticky filter rail) is a control\n // WITHIN the page, not a replacement for it. Resolving by \"whichever box scrolled\n // first\" instead meant a shopper who nudged a modal before reading the page lost page\n // depth for the rest of the route — a page that reported correctly before the in-page\n // path existed. Anchoring on the document means this can only ever ADD coverage.\n //\n // The two tests are ordered so the common case costs nothing: a scroll from the\n // document's own scrollport IS the page and needs no measurement, so the viewport\n // path's layout-read budget is exactly what it was before in-page scrollers existed.\n // Only a scroll from some other box has to ask how far the document can go.\n //\n // No `MIN_HOST_SCROLLABLE_PX` on that second test, on purpose: the threshold exists to\n // tell a page from a control, and the document is never a control. A document with\n // 100px of overflow is still the page, and was always reported as one.\n //\n // The document measurement is not cached: a zero means \"cannot scroll YET\", and a page\n // that starts one viewport tall and grows when lazy content lands has to be able to\n // change that answer without waiting on a resize that may never come.\n //\n // The scrollport test is deliberately NOT `target === window`. A Window identity check\n // is unreliable across realms — under vitest's jsdom the event's Window and the\n // module's `window` are different objects, and the same holds inside an iframe — so it\n // silently failed and every viewport scroll was discarded. Window and Document are the\n // two scroll targets that are not Elements, and `documentElement` is the Element that\n // means the same thing; none of that needs identity. `body` is pointedly excluded: it\n // is a viewport proxy in the standard shape but a scroll container in its own right\n // under `html { overflow: hidden } body { overflow: auto }`, where the viewport\n // metrics it would send us to read are inert — which is how that theme reported\n // nothing. It goes to the element path below and is measured for real.\n if (\n !(target instanceof Element) ||\n target === document.documentElement ||\n document.documentElement.scrollHeight > window.innerHeight\n ) {\n host = null;\n } else {\n // The document cannot scroll and something else did: the wrapper-scroller theme, or\n // the `body { overflow: auto }` variant of it, which lands here too because `body`\n // is a real scroll container in that shape and `body.scrollTop` is the live value.\n //\n // A horizontal carousel has no vertical overflow and is filtered out here, as is a\n // small popover — neither is \"the page\", and reporting depth for a box the shopper\n // barely touched would be worse than reporting nothing. Returning without\n // committing leaves the host unresolved, so a real wrapper can still claim it.\n const box = target as Element;\n if (box.scrollHeight - box.clientHeight < MIN_HOST_SCROLLABLE_PX) return;\n host = box;\n }\n scrollable = -1; // metrics now come from a different box\n observeHost();\n // Not the box we report depth for: a mini-cart drawer scrolled to its end must not\n // read as \"the shopper reached the bottom of the page\".\n //\n // Only an ELEMENT host filters by target. Once the viewport is the host there is\n // nothing to filter against: depth comes from `window.scrollY`, which no in-page box\n // can move, so a stray scroll from a drawer costs one coalesced frame and emits\n // nothing. Not asking also means it no longer matters whether an engine targets\n // `document` or `body` for a page scroll — a distinction that was load-bearing here\n // and is not worth depending on.\n } else if (host && event.target !== host) {\n return;\n }\n if (frame !== 0) return; // a frame is already pending — coalesce into it\n frame = scheduleFrame(evaluate);\n };\n\n // Content height and viewport both change here, so the cache is no longer trustworthy.\n const onResize = (): void => {\n scrollable = -1;\n };\n\n /**\n * Catches content-height changes, which `resize` does not report. Without it a page that\n * SHRINKS keeps a too-large cached height and silently stops reporting quartiles.\n * Absent in older Safari and in jsdom, where the window listeners remain the fallback.\n *\n * Re-pointed at the host once one is resolved: an in-page scroller's content can grow\n * while the document's never changes, so observing the document would miss it entirely.\n *\n * An element host is observed together with its children, because the host's own box is\n * its SCROLLPORT — pinned to the viewport (`height: 100vh`) in every theme that scrolls a\n * wrapper, so it does not resize when the content inside it does. Observing it alone gave\n * the host path none of the shrink protection the document path has a test for: a wrapper\n * primed at 20,000px and then collapsed kept the stale extent, and scrolling to its true\n * bottom read ~16% and emitted nothing further. The children are what actually change\n * height. `documentElement` is no substitute here — in exactly these themes it is pinned\n * to 100vh as well.\n */\n let observer: ResizeObserver | null = null;\n const observeHost = (): void => {\n if (typeof ResizeObserver === 'undefined') return;\n try {\n observer?.disconnect();\n observer = new ResizeObserver(onResize);\n observer.observe(host ?? document.documentElement);\n // Index loop, not `for…of`: HTMLCollection is not iterable under this tsconfig's lib,\n // and a spread would cost an array per resolution for no gain.\n if (host) {\n const content = host.children;\n for (let i = 0; i < content.length; i++) observer.observe(content[i]!);\n }\n } catch {\n observer = null; // never let instrumentation break the page\n }\n };\n\n const attach = (): void => {\n if (attached) return;\n attached = true;\n // CAPTURE phase — that single flag is the whole fix. Scroll events do not bubble, so a\n // plain window listener sees only the viewport, and a theme that scrolls an inner\n // wrapper (documentElement and body both `overflow: hidden`, common on modern Shopify\n // themes) emitted nothing at all, silently, for the life of the page. The capture\n // phase runs from the root down to the target, so it delivers scroll from ANY element\n // even though the event never bubbles back up — one listener, both shapes, no DOM\n // search, and the listener stays on `window` exactly as before.\n window.addEventListener('scroll', onScroll, { capture: true, passive: true });\n window.addEventListener('resize', onResize, { passive: true });\n window.addEventListener('orientationchange', onResize, { passive: true });\n observeHost();\n };\n\n const detach = (): void => {\n if (!attached) return;\n attached = false;\n // The capture flag is part of the listener's identity — omitting it here would leave\n // the listener attached for the life of the page.\n window.removeEventListener('scroll', onScroll, { capture: true });\n window.removeEventListener('resize', onResize);\n window.removeEventListener('orientationchange', onResize);\n observer?.disconnect();\n observer = null;\n };\n\n attach();\n\n return {\n // `reached` is the index of the NEXT quartile to emit, so the deepest already crossed is\n // the one before it. 0 before any quartile is reached.\n maxDepth: () => (reached > 0 ? QUARTILES[reached - 1]! : 0),\n stop: () => {\n if (frame !== 0) cancelFrame(frame);\n frame = 0;\n detach();\n },\n rearm: () => {\n reached = 0;\n scrollable = -1;\n // A new route can scroll a different box — a PDP with a document-level scroll after\n // a collection page that scrolled an inner wrapper. Re-resolve rather than keep\n // measuring the old route's container, which may no longer be in the document.\n host = undefined;\n attach();\n },\n };\n}\n\n/** rAF where available; a macrotask in jsdom and other non-visual hosts. */\nfunction scheduleFrame(fn: () => void): number {\n if (typeof requestAnimationFrame === 'function') return requestAnimationFrame(fn);\n return setTimeout(fn, 16) as unknown as number;\n}\n\nfunction cancelFrame(handle: number): void {\n if (typeof cancelAnimationFrame === 'function') cancelAnimationFrame(handle);\n else clearTimeout(handle);\n}\n\n/**\n * Calls `onNavigate` when the History API or a popstate changes the URL.\n * Returns a teardown that restores the original History methods.\n */\nfunction observeNavigation(onNavigate: () => void): () => void {\n let lastUrl = location.href;\n const emitIfChanged = (): void => {\n if (location.href === lastUrl) return;\n lastUrl = location.href;\n onNavigate();\n };\n\n const originalPush = history.pushState.bind(history);\n const originalReplace = history.replaceState.bind(history);\n\n history.pushState = (...args: Parameters<History['pushState']>) => {\n originalPush(...args);\n emitIfChanged();\n };\n history.replaceState = (...args: Parameters<History['replaceState']>) => {\n originalReplace(...args);\n emitIfChanged();\n };\n window.addEventListener('popstate', emitIfChanged);\n\n return () => {\n history.pushState = originalPush;\n history.replaceState = originalReplace;\n window.removeEventListener('popstate', emitIfChanged);\n };\n}\n"],"mappings":"AACO,SAASA,EAAgBC,EAAkBC,EAA0B,CAC1E,IAAMC,EAAkB,CAAC,EACrBC,EAA0BH,EAE9B,KAAOG,GAAWA,IAAY,SAAS,iBAAmBD,EAAM,OAASD,GAAU,CACjF,IAAIG,EAAOD,EAAQ,QAAQ,YAAY,EACvC,GAAIA,EAAQ,GAAI,CACdD,EAAM,QAAQ,GAAGE,CAAI,IAAID,EAAQ,EAAE,EAAE,EACrC,KACF,CACA,IAAME,EAAU,MAAM,KAAKF,EAAQ,SAAS,EAAE,MAAM,EAAG,CAAC,EACpDE,EAAQ,SAAQD,GAAQ,IAAIC,EAAQ,KAAK,GAAG,CAAC,IAEjD,IAAMC,EAAyBH,EAAQ,cACvC,GAAIG,EAAQ,CACV,IAAMC,EAAW,MAAM,KAAKD,EAAO,QAAQ,EAAE,OAAQE,GAAMA,EAAE,UAAYL,EAAS,OAAO,EACrFI,EAAS,OAAS,IAAGH,GAAQ,gBAAgBG,EAAS,QAAQJ,CAAO,EAAI,CAAC,IAChF,CACAD,EAAM,QAAQE,CAAI,EAClBD,EAAUG,CACZ,CAEA,OAAOJ,EAAM,KAAK,KAAK,CACzB,CAGO,SAASO,EAAUT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AAoB,WAAYF,CAAa,CACtD,CACF","names":["elementSelector","element","maxDepth","parts","current","part","classes","parent","siblings","c","isIgnored","ignoredSelectors","selector","SENSITIVE_INPUT_TYPES","safeText","text","isSensitiveField","input","ariaLabel","label","clip","parentLabel","labelText","legend","container","exclude","dataAttributes","names","out","name","value","INTERACTIVE_SELECTOR","startAutocapture","config","hooks","teardowns","captureClicks","forms","captureForms","scroll","captureScrollDepth","leave","onNavigate","observeNavigation","fn","stop","elementProperties","element","properties","elementSelector","classes","aria","ariaLabel","parent","parentLabel","dataAttributes","viewport","DOWNLOAD_EXTENSIONS","fileTarget","path","name","match","RAGE_WINDOW_MS","RAGE_THRESHOLD","ERROR_CLICK_WINDOW_MS","rageTracker","target","clicks","reported","now","x","y","click","interactiveOnly","rage","lastClick","onError","event","error","onClick","interactive","isIgnored","file","text","safeText","burst","formProperties","form","action","started","onSubmit","fields","el","isSensitiveField","noteFormStart","onInput","onChange","root","options","QUARTILES","MIN_HOST_SCROLLABLE_PX","reached","scrollable","frame","attached","host","measure","percent","evaluate","depth","detach","onScroll","box","observeHost","scheduleFrame","onResize","observer","content","i","attach","cancelFrame","handle","lastUrl","emitIfChanged","originalPush","originalReplace","args"]}
1
+ {"version":3,"sources":["../src/autocapture/selector.ts","../src/autocapture/index.ts"],"sourcesContent":["const MASK = '[data-depsmith-sdk-mask]';\n\n/**\n * Attributes that name an element on purpose, best first. The first is the SDK's own, documented\n * for clients; the rest are what test suites already put on the elements that matter.\n */\nconst STABLE_ATTRIBUTES = ['data-depsmith-sdk-id', 'data-testid', 'data-test', 'data-cy'];\n\n/**\n * A CSS selector for an autocaptured element that survives a redeploy, capped at `maxDepth`\n * levels.\n *\n * Each level is the first of: a stable attribute (above), an `id`, a `name`, an `aria-label`, or\n * the tag with at most two classes — skipping any id, class or test-attribute value that\n * {@link looksGenerated}. The walk stops at the first level named by a stable attribute or an\n * id: those identify the element already, and the ancestors above them only add churn.\n *\n * What it no longer does, and why:\n * - **No `:nth-of-type`.** Position among siblings changes whenever a list or layout does, and it\n * gave every product card's \"Add to cart\" its own selector, so one button could not be counted\n * across cards. The selector names the kind of element, not its position.\n * - **No hashed or utility classes, no generated ids.** CSS-in-JS and CSS-module hashes change\n * every build, utility classes whenever styling is tweaked, and one generated id used to decide\n * the whole selector, because the walk stopped at the first id it saw.\n *\n * `aria-label` is content, and can carry personal text (\"Remove John's card\"), so it is never a\n * selector part under `[data-depsmith-sdk-mask]` — the same rule `$ac_aria_label` follows.\n */\nexport function elementSelector(\n element: Element,\n maxDepth: number,\n ignore: readonly RegExp[] = []\n): string {\n const parts: string[] = [];\n let current: Element | null = element;\n\n while (current && current !== document.documentElement && parts.length < maxDepth) {\n const tag = current.tagName.toLowerCase();\n let part: string | undefined;\n for (const attribute of STABLE_ATTRIBUTES) {\n const value = current.getAttribute(attribute);\n // `data-depsmith-sdk-id` is exempt from the generated check: the client chose that value.\n // A `data-testid=\"order-12345\"` is not — otherwise every order row gets its own selector.\n if (value && (attribute === STABLE_ATTRIBUTES[0] || !looksGenerated(value, ignore))) {\n part = `${tag}[${attribute}=\"${cssEscape(value)}\"]`;\n break;\n }\n }\n if (!part && current.id && !looksGenerated(current.id, ignore)) {\n part = `${tag}#${cssEscape(current.id)}`;\n }\n if (part) {\n parts.unshift(part);\n break; // named on purpose — the ancestors add nothing but churn\n }\n const name = current.getAttribute('name');\n const aria = current.closest(MASK) ? null : current.getAttribute('aria-label');\n const classes = Array.from(current.classList)\n .filter((token) => !looksGenerated(token, ignore))\n .slice(0, 2);\n parts.unshift(\n name\n ? `${tag}[name=\"${cssEscape(name)}\"]`\n : aria\n ? `${tag}[aria-label=\"${cssEscape(aria)}\"]`\n : [tag, ...classes.map(cssEscape)].join('.')\n );\n current = current.parentElement;\n }\n\n return parts.join(' > ');\n}\n\n/**\n * True when an id, class or test-attribute value is a build artefact rather than a name:\n * - a CSS-in-JS prefix: `css-1x2y3z`, `sc-a1b2c3`, `jsx-123`, `emotion-0`, `svelte-xyz`\n * - a CSS-module hash suffix: `Button_primary__3kLmN` (`_` or `__`, then 5+ mixed letters and\n * digits)\n * - `:`, `[` or `/` anywhere (React `useId`'s `:r1:`, Tailwind's `md:flex` and `w-[320px]`), or a\n * run of four digits (`shopify-section-template--16089385943297__main`, `order-12345`)\n * - a framework id like `ember123`\n * - a Tailwind-style utility class: `p-4`, `mt-2`, `w-full`, `text-sm`, `bg-white`, `flex`, …\n * - anything matching one of the client's `autocapture.selectorIgnore` patterns\n */\nexport function looksGenerated(token: string, extra: readonly RegExp[] = []): boolean {\n return GENERATED.some((rule) => rule.test(token)) || extra.some((rule) => rule.test(token));\n}\n\nconst GENERATED = [\n /^(?:css|sc|jsx|emotion|svelte)-/,\n /__?(?=[a-z\\d]*\\d)(?=[a-z\\d]*[a-z])[a-z\\d]{5,}$/i,\n /[:[/]|\\d{4}/,\n /^ember\\d/,\n // Utility prefixes. Deliberately not the ones that double as ordinary BEM names — `top-`,\n // `order-`, `content-`, `items-` — where dropping `order-summary` would cost a real name.\n // The common families only: each word here is bytes in the lazy chunk, and a miss merely keeps\n // a class — `selectorIgnore` covers the rest.\n /^-?(?:[pm][trblxy]?|[wh]|(?:min|max)-[wh]|gap|space-[xy]|z|text|bg|border|rounded|shadow|font|leading|opacity|col|row|justify|overflow|translate|duration|transition)-/,\n /^(?:flex|inline|grid-cols)(?:-|$)|^(?:grid|block|hidden|relative|absolute|fixed|sticky|container|truncate|uppercase|sr-only)$/,\n];\n\n/**\n * `autocapture.selectorIgnore`, compiled once. Regex SOURCES rather than RegExp objects, so the\n * option stays expressible in config.schema.json. An entry that does not compile is skipped\n * with a warning, the way `isIgnored` skips an invalid selector.\n */\nexport function compileIgnore(\n sources: readonly string[],\n warn?: (message: string) => void\n): RegExp[] {\n const out: RegExp[] = [];\n for (const source of sources) {\n try {\n out.push(new RegExp(source));\n } catch {\n warn?.(`autocapture.selectorIgnore: invalid pattern ignored \"${source}\"`);\n }\n }\n return out;\n}\n\n/** `CSS.escape` where the browser has it; a conservative fallback elsewhere (jsdom). */\nfunction cssEscape(value: string): string {\n return typeof CSS !== 'undefined' && CSS.escape\n ? CSS.escape(value)\n : value.replace(/[^\\w-]/g, '\\\\$&');\n}\n\n/** True when the element (or an ancestor) opts out of autocapture. */\nexport function isIgnored(element: Element, ignoredSelectors: string[]): boolean {\n if (element.closest('[data-depsmith-sdk-no-capture]')) return true;\n for (const selector of ignoredSelectors) {\n try {\n if (element.closest(selector)) return true;\n } catch {\n // invalid selector in config — skip it\n }\n }\n return false;\n}\n\nconst SENSITIVE_INPUT_TYPES = new Set(['password', 'email', 'tel', 'hidden', 'number']);\n\n/** Element text, aggressively masked: never inputs, never [data-depsmith-sdk-mask], 255-char cap. */\nexport function safeText(element: Element): string | undefined {\n if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement) return undefined;\n if (element.closest('[data-depsmith-sdk-mask]')) return undefined;\n const text = element.textContent?.trim().replace(/\\s+/g, ' ');\n return text ? text.slice(0, 255) : undefined;\n}\n\nexport function isSensitiveField(input: Element): boolean {\n if (!(input instanceof HTMLInputElement)) return false;\n return SENSITIVE_INPUT_TYPES.has(input.type) || !!input.closest('[data-depsmith-sdk-mask]');\n}\n\n/**\n * Author-written label text for an element, masked like `safeText`.\n *\n * `aria-label` first, then the element's own accessible name sources in the order a screen\n * reader would reach them. This is what makes an icon button legible in analytics: a `<button>`\n * whose only content is an `<svg>` has no text at all today, so every close, delete and\n * favourite control on a page is indistinguishable.\n */\nexport function ariaLabel(element: Element): string | undefined {\n if (element.closest('[data-depsmith-sdk-mask]')) return undefined;\n const label = element.getAttribute('aria-label');\n return label ? clip(label) : undefined;\n}\n\n/**\n * The nearest enclosing label for a control: its `<label>`, or the `<legend>` of its\n * `<fieldset>`.\n *\n * Bounded to those two, deliberately. \"Nearest label text from a parent\" invites walking up\n * until something has text, which on a real page reaches a section heading or the whole form and\n * reports that as the field's label — worse than reporting nothing. Both of these are elements\n * whose stated purpose IS to name the thing inside them.\n *\n * Returns the label's text WITHOUT the control's own, so a `<label>` wrapping its input does not\n * echo a value back; and nothing at all under a mask.\n */\nexport function parentLabel(element: Element): string | undefined {\n if (element.closest('[data-depsmith-sdk-mask]')) return undefined;\n const label = element.closest('label');\n if (label) {\n const text = labelText(label, element);\n if (text) return text;\n }\n const legend = element.closest('fieldset')?.querySelector(':scope > legend');\n return legend ? labelText(legend, element) : undefined;\n}\n\n/** Where `$ac_label` came from, sent as `$ac_label_source` so a wrong label can be traced. */\nexport type LabelSource =\n | 'aria_label'\n | 'aria_labelledby'\n | 'text'\n | 'heading'\n | 'title'\n | 'alt'\n | 'value';\n\n/** Visible text longer than this is a container's, not a control's: use its heading instead. */\nconst LABEL_TEXT_MAX = 60;\n/** Nodes the visible-text walk may visit, so a click on a page-level wrapper stays cheap. */\nconst LABEL_WALK_BUDGET = 500;\nconst HEADINGS = 'h1,h2,h3,h4,h5,h6';\n\n/**\n * The one readable name for an element (`$ac_label`), first non-blank of:\n *\n * 1. `aria-label`\n * 2. `aria-labelledby` — the referenced elements' text, skipping any under a mask\n * 3. visible text — skipping `aria-hidden=\"true\"`, `[hidden]`, `<svg>`, `<script>`, `<style>`\n * and masked subtrees. Over 60 characters it is a container (a product card wrapped in a\n * link), so its first heading's text is used instead (`heading`), else it is cut at 60\n * 4. `title`\n * 5. the `alt` of the first `<img>` inside\n * 6. the `value` of `input[type=submit|button|reset]` — a button label, not typed text\n *\n * Readable text first, before any id: the field exists for charts and labels.\n *\n * Never a label: anything inside `[data-depsmith-sdk-mask]`, and any other `<input>` or a\n * `<textarea>` — not even from `aria-label` (decision D4; `$ac_aria_label` and\n * `$ac_parent_label` still describe those). A `<select>` uses only `aria-label`,\n * `aria-labelledby` and `title`: its text is every option joined, which names nothing.\n */\nexport function elementLabel(element: Element): { label: string; source: LabelSource } | undefined {\n if (element.closest(MASK)) return undefined;\n const tag = element.localName;\n const button =\n element instanceof HTMLInputElement && /^(?:submit|button|reset)$/.test(element.type);\n if ((tag === 'input' && !button) || tag === 'textarea') return undefined;\n\n const found = (label: string | null | undefined, source: LabelSource) =>\n label?.trim() ? { label: clip(label), source } : undefined;\n\n const byIds = element\n .getAttribute('aria-labelledby')\n ?.split(/\\s+/)\n .map((id) => {\n const target = id && document.getElementById(id);\n return target && !target.closest(MASK) ? target.textContent : '';\n })\n .join(' ');\n const named =\n found(element.getAttribute('aria-label'), 'aria_label') ??\n found(byIds, 'aria_labelledby');\n if (named || tag === 'select') return named ?? found(element.getAttribute('title'), 'title');\n\n return (\n visibleLabel(element) ??\n found(element.getAttribute('title'), 'title') ??\n found(element.querySelector('img')?.getAttribute('alt'), 'alt') ??\n (button ? found((element as HTMLInputElement).value, 'value') : undefined)\n );\n}\n\n/** Step 3 of {@link elementLabel}: the visible text, or the heading of a long one. */\nfunction visibleLabel(element: Element): { label: string; source: LabelSource } | undefined {\n const budget = { left: LABEL_WALK_BUDGET };\n // Checked once up front, so a long block with no heading at all stops at 61 characters\n // instead of walking to the budget looking for one.\n const mayHaveHeading = !!element.querySelector(HEADINGS);\n const { text, heading } = walkText(element, budget, mayHaveHeading);\n if (!text) return undefined;\n if (text.length <= LABEL_TEXT_MAX) return { label: text, source: 'text' };\n const headingText = heading && walkText(heading, budget, false).text;\n return headingText\n ? { label: headingText.slice(0, LABEL_TEXT_MAX), source: 'heading' }\n : { label: text.slice(0, LABEL_TEXT_MAX), source: 'text' };\n}\n\n/**\n * Whitespace-collapsed visible text of `root`, and its first visible heading when `findHeading`.\n *\n * Stops when the node budget runs out, or once there is more text than a label may hold and the\n * heading question is settled — found, or not being asked.\n */\nfunction walkText(\n root: Element,\n budget: { left: number },\n findHeading: boolean\n): { text: string; heading?: Element } {\n let text = '';\n let heading: Element | undefined;\n const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT, {\n acceptNode: (node) =>\n node.nodeType === 1 && invisible(node as Element)\n ? NodeFilter.FILTER_REJECT\n : NodeFilter.FILTER_ACCEPT,\n });\n for (let node = walker.nextNode(); node && budget.left-- > 0; node = walker.nextNode()) {\n if (node.nodeType === 3) {\n // Collapsed per piece, so the running length is close to the final one without re-scanning.\n text += node.nodeValue!.replace(/\\s+/g, ' ');\n } else if (findHeading && !heading && /^h[1-6]$/.test((node as Element).localName)) {\n heading = node as Element;\n }\n if (text.length > LABEL_TEXT_MAX + 1 && (heading || !findHeading)) break;\n }\n return { text: text.replace(/\\s+/g, ' ').trim(), heading };\n}\n\n/** Subtrees the visible-text walk skips whole. */\nfunction invisible(element: Element): boolean {\n return (\n /^(?:svg|script|style)$/.test(element.localName) ||\n element.getAttribute('aria-hidden') === 'true' ||\n element.hasAttribute('hidden') ||\n element.hasAttribute('data-depsmith-sdk-mask')\n );\n}\n\n/** Text of `container`, minus any text contributed by `exclude`. */\nfunction labelText(container: Element, exclude: Element): string | undefined {\n let text = container.textContent ?? '';\n if (container !== exclude && container.contains(exclude)) {\n text = text.replace(exclude.textContent ?? '', '');\n }\n const clipped = clip(text);\n return clipped || undefined;\n}\n\n/**\n * Allow-listed `data-*` values as `$ac_attr_<name>`.\n *\n * Read from the element or the nearest ancestor that has it, because the attribute is usually on\n * the product card rather than the button inside it. Masked subtrees yield nothing.\n */\nexport function dataAttributes(element: Element, names: readonly string[]): Record<string, string> {\n const out: Record<string, string> = {};\n if (names.length === 0 || element.closest('[data-depsmith-sdk-mask]')) return out;\n for (const name of names) {\n // `name` comes from config; an invalid attribute name would make closest() throw.\n try {\n const source = element.closest(`[data-${name}]`);\n const value = source?.getAttribute(`data-${name}`);\n if (value) out[`$ac_attr_${name.replace(/-/g, '_')}`] = clip(value);\n } catch {\n /* unusable attribute name in config — skip it */\n }\n }\n return out;\n}\n\n/** Collapse whitespace and cap, the same treatment safeText gives element text. */\nfunction clip(value: string): string {\n return value.trim().replace(/\\s+/g, ' ').slice(0, 255);\n}\n","/**\n * Web autocapture engine — lazily loaded so the core bundle stays under 10KB gz.\n * Clicks (delegation), form submits (values never captured), scroll depth\n * (quartiles), and SPA pageviews (History API patch). See API_SPEC §3 for the\n * reserved $autocapture event.\n */\nimport type { ResolvedAutocaptureConfig } from '../config';\nimport type { Properties } from '../types';\nimport {\n ariaLabel,\n compileIgnore,\n dataAttributes,\n elementLabel,\n elementSelector,\n isIgnored,\n isSensitiveField,\n parentLabel,\n safeText,\n} from './selector';\n\nexport interface AutocaptureHooks {\n /** Emits a $autocapture event through the client pipeline. */\n emit(properties: Properties): void;\n /**\n * Emits a $page_view through the client pipeline, for the landing page and every SPA\n * navigation. The client dedupes by page — the path, or the whole URL under `'all'` — so\n * calling it twice for one page emits once.\n *\n * `watchTitle` is passed for SPA navigations only: the client records the view at once and\n * holds it until the new route's title is in (see {@link watchTitle}). The landing page's title\n * is already set, so its view is sent immediately.\n */\n page(watchTitle?: (titleAtNav: string, done: () => void) => () => void): void;\n /**\n * Emits a $page_leave for the page being left. `maxScroll` is the deepest quartile reached,\n * or undefined when scroll tracking is off.\n */\n pageLeave(maxScroll?: number): void;\n /**\n * Hands the client the unload-time `$page_leave` trigger, to call from its own `pagehide`\n * handler.\n *\n * Autocapture cannot own that listener. It is loaded from a dynamic import, so its listener\n * is always registered after the client's — and the client's drains the queue with\n * `sendBeacon`. A `$page_leave` captured after that drain never leaves the page.\n */\n armUnloadLeave(leave: () => void): void;\n /** A debug-level warning through the client's logger, for config the engine had to skip. */\n warn?(message: string): void;\n}\n\n/** The resolved config plus what the engine compiles from it once, at start. */\ntype EngineConfig = ResolvedAutocaptureConfig & { ignore: RegExp[] };\n\n/** Elements a click is attributed to when `clicks: 'interactive'`. */\nconst INTERACTIVE_SELECTOR =\n 'a, button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"], [data-depsmith-sdk-capture]';\n\nexport function startAutocapture(\n resolved: ResolvedAutocaptureConfig,\n hooks: AutocaptureHooks\n): () => void {\n const teardowns: Array<() => void> = [];\n const config: EngineConfig = {\n ...resolved,\n ignore: compileIgnore(resolved.selectorIgnore ?? [], hooks.warn),\n };\n\n if (config.clicks) teardowns.push(captureClicks(config, hooks));\n\n let forms: FormTracker | null = null;\n if (config.forms) {\n forms = captureForms(config, hooks);\n teardowns.push(forms.stop);\n }\n\n let scroll: ScrollTracker | null = null;\n if (config.scrolls) {\n scroll = captureScrollDepth(hooks);\n teardowns.push(scroll.stop);\n }\n\n const leave = (): void => hooks.pageLeave(scroll?.maxDepth());\n\n /**\n * Run on SPA navigation. Composed explicitly rather than by push order, because the order is\n * load-bearing in two places:\n *\n * 1. `$page_leave` must precede `$page_view`. It describes the page being LEFT, and the\n * client reads the outgoing URL from its page tracker — which the pageview then advances.\n * 2. `$page_leave` must precede `scroll.rearm`, which zeroes the quartiles that\n * `$page_max_scroll` reports.\n */\n const onNavigate: Array<() => void> = [\n ...(config.pageviews ? [leave] : []),\n ...(scroll ? [scroll.rearm] : []),\n // `form_start` is once per form per PAGE VIEW, so a route change has to forget what it saw.\n // Without this, a checkout wizard that keeps one <form> across steps reports a start on\n // step one and nothing afterwards.\n ...(forms ? [forms.rearm] : []),\n ...(config.pageviews ? [() => hooks.page(watchTitle)] : []),\n ];\n\n if (config.pageviews) {\n // The first page a visitor lands on was never recorded: `hooks.page` was wired only to\n // navigation, so a plain multi-page site reported no pageviews at all and an SPA missed its\n // entry page. Fire once here, after the features above are armed, so the landing pageview\n // carries the same state a route change would. The client dedupes by page, so this cannot\n // double-fire with a framework that replaceState()s to the same URL during hydration.\n hooks.page();\n // The other half of the pair: this `leave` covers SPA route changes, the client's `pagehide`\n // handler covers leaving the document for good.\n hooks.armUnloadLeave(leave);\n }\n\n // One History patch feeding every navigation-sensitive feature, rather than one per\n // feature. Scroll depth needs the same signal pageviews do — without it, a re-armed\n // quartile set on an SPA route change is unreachable once the listener has detached.\n //\n // And one PAGE BOUNDARY for all of them: scroll and forms re-arm exactly when a view would be\n // sent, so `$page_max_scroll` describes the view it is attached to. With `pageviews: false`\n // the boundary is still the path — a filter change is not a new page for form_start either.\n if (onNavigate.length > 0) {\n teardowns.push(\n observeNavigation(config.pageviews === 'all' ? hrefKey : pathKey, () => {\n for (const fn of onNavigate) fn();\n })\n );\n }\n\n return () => {\n for (const stop of teardowns.splice(0)) stop();\n };\n}\n\n/**\n * Identity and labelling shared by `click`, `file_download` and `change`.\n *\n * `id` and `classes` are emitted even under a mask: they are structural, they are already inside\n * `$ac_selector`, and suppressing them there while publishing the selector would be theatre.\n * Everything that can carry author or user text — aria-label, the enclosing label, allow-listed\n * data values — goes through the masking helpers in selector.ts instead.\n */\nfunction elementProperties(element: Element, config: EngineConfig): Properties {\n const properties: Properties = {\n $ac_selector: elementSelector(element, config.selectorMaxDepth, config.ignore),\n $ac_tag: element.tagName.toLowerCase(),\n };\n if (element.id) properties.$ac_id = element.id;\n // Capped like every other unbounded string: a utility-CSS page puts thirty classes on a button.\n const classes = element.getAttribute('class')?.trim().replace(/\\s+/g, ' ');\n if (classes) properties.$ac_classes = classes.slice(0, 255);\n const aria = ariaLabel(element);\n if (aria) properties.$ac_aria_label = aria;\n const parent = parentLabel(element);\n if (parent) properties.$ac_parent_label = parent;\n // The one field charts and the event-label tool read. `$ac_text` and `$ac_aria_label` stay as\n // they were; this picks the readable one. Omitted, never \"Unknown\", when nothing names it.\n const label = elementLabel(element);\n if (label) {\n properties.$ac_label = label.label;\n properties.$ac_label_source = label.source;\n }\n return { ...properties, ...dataAttributes(element, config.attributes) };\n}\n\n/** Viewport, for reading click coordinates against the layout they happened in. */\nfunction viewport(): Properties {\n // innerWidth/innerHeight are plain property reads — no layout flush, unlike scrollHeight.\n return { $ac_viewport_w: window.innerWidth, $ac_viewport_h: window.innerHeight };\n}\n\n/**\n * Extensions that make a link a download rather than a navigation.\n *\n * Deliberately not images: a click on a `.png` is almost always \"open the photo\", and counting\n * every lightbox as a file download would bury the handful of real ones. A `download` attribute\n * always wins regardless of extension, which is the author stating intent.\n */\nconst DOWNLOAD_EXTENSIONS =\n /\\.(pdf|zip|7z|rar|gz|tar|docx?|xlsx?|pptx?|csv|txt|rtf|mp4|mov|avi|mp3|wav|dmg|pkg|exe|apk)$/i;\n\n/** `{ext, name}` when this element is a link to a file, else undefined. */\nfunction fileTarget(element: Element): { ext: string; name: string } | undefined {\n if (!(element instanceof HTMLAnchorElement) || !element.href) return undefined;\n let path: string;\n try {\n // The pathname, so `?v=2#page` cannot hide the extension or end up in the file name.\n path = new URL(element.href).pathname;\n } catch {\n return undefined;\n }\n const name = decodeURIComponent(path.slice(path.lastIndexOf('/') + 1));\n const match = DOWNLOAD_EXTENSIONS.exec(path);\n // `download` is the author's own declaration, so it counts even with no extension at all.\n if (!match && !element.hasAttribute('download')) return undefined;\n if (!name) return undefined;\n return { ext: match ? match[1]!.toLowerCase() : '', name };\n}\n\n/** Clicks on one element within this window count towards a rage click. */\nconst RAGE_WINDOW_MS = 1000;\n/** How many clicks make it rage rather than impatience. */\nconst RAGE_THRESHOLD = 4;\n/** How long after a click a script error is still attributed to it. */\nconst ERROR_CLICK_WINDOW_MS = 1000;\n\ninterface RageClick {\n count: number;\n begin: number;\n end: number;\n clicks: Array<{ t: number; x: number; y: number }>;\n}\n\n/**\n * Rage clicks: four or more clicks on the SAME element within a second (spec item 13).\n *\n * Keyed on the element, not on a position: a user hammering a button that has moved underneath them\n * is still raging at that button, and a coordinate-keyed detector would miss exactly the case where\n * the UI is shifting — the one most likely to be frustrating in the first place.\n *\n * Reports on the fourth click, not when the burst ends on a timer: a timer needs the burst to finish\n * before reporting, so a rage that ends in a navigation — the common shape — would be lost to the\n * unload.\n *\n * And exactly ONCE per burst. Reporting every click past the threshold looked reasonable and was\n * measured at 37 events for one benchmark walk, nearly doubling its upload volume — one angry user\n * producing seventeen events is the firehose this engine avoids everywhere else. The signal is \"this\n * element was rage-clicked\", which one event carries; `$fr_click_count` is therefore the threshold\n * rather than the burst's eventual size, and that is a deliberate trade rather than an oversight.\n */\nfunction rageTracker(): (element: Element, now: number, x: number, y: number) => RageClick | null {\n let target: Element | null = null;\n let clicks: Array<{ t: number; x: number; y: number }> = [];\n let reported = false;\n\n return (element, now, x, y) => {\n if (element !== target) {\n target = element;\n clicks = [];\n reported = false;\n }\n // Drop clicks that fell outside the window, so a slowly repeated click never accumulates.\n clicks = clicks.filter((click) => now - click.t <= RAGE_WINDOW_MS);\n // The window emptying is what ends a burst, so a later burst on the same element reports again.\n if (clicks.length === 0) reported = false;\n clicks.push({ t: now, x, y });\n if (reported || clicks.length < RAGE_THRESHOLD) return null;\n reported = true;\n return { count: clicks.length, begin: clicks[0]!.t, end: now, clicks: clicks.slice() };\n };\n}\n\nfunction captureClicks(config: EngineConfig, hooks: AutocaptureHooks): () => void {\n // `true` means \"capture clicks\", not \"capture every click on the page\" — it resolves to\n // the interactive gate like the default does. Emitting a $autocapture for a tap on a\n // product image or a bare layout <div> is a firehose that costs a queue write per event\n // and buries the clicks that carry intent, so it takes an explicit 'all' to ask for it.\n const interactiveOnly = config.clicks !== 'all';\n const rage = rageTracker();\n /** The most recent click, so a script error just after one can be attributed to it. */\n let lastClick: { at: number; properties: Properties } | null = null;\n\n /**\n * `error_click`: a script error within ERROR_CLICK_WINDOW_MS of a click (spec item 13).\n *\n * Attribution by proximity in time, which is the honest limit of what a listener can know — an\n * error carries no reference to the interaction that caused it. The window is deliberately short\n * for that reason: the longer it is, the more unrelated errors get blamed on the last click.\n */\n const onError = (event: ErrorEvent): void => {\n if (!lastClick || Date.now() - lastClick.at > ERROR_CLICK_WINDOW_MS) return;\n const properties: Properties = {\n ...lastClick.properties,\n $ac_kind: 'error_click',\n $fr_error_message: String(event.message ?? '').slice(0, 255),\n };\n const error: unknown = event.error;\n if (error instanceof Error) {\n properties.$fr_error_type = error.name;\n // Capped hard: a stack is unbounded, and the top frames are where the cause is.\n if (error.stack) properties.$fr_error_stack = error.stack.slice(0, 1000);\n }\n if (event.filename) properties.$fr_error_file = event.filename;\n if (event.lineno) properties.$fr_error_line = event.lineno;\n if (event.colno) properties.$fr_error_column = event.colno;\n hooks.emit(properties);\n // One error per click: a single failure often fires repeatedly (a render loop), and each one\n // would otherwise be blamed on the same click.\n lastClick = null;\n };\n\n const onClick = (event: MouseEvent): void => {\n const target = event.target;\n if (!(target instanceof Element)) return;\n const interactive = target.closest(INTERACTIVE_SELECTOR);\n if (interactiveOnly && !interactive) return;\n const element = interactive ?? target;\n if (isIgnored(element, config.ignoredSelectors)) return;\n\n const file = fileTarget(element);\n const properties: Properties = {\n // A download REPLACES the click rather than adding an event, so one interaction stays one\n // event and existing click counts do not double when this ships.\n $ac_kind: file ? 'file_download' : 'click',\n ...elementProperties(element, config),\n $ac_x: event.clientX,\n $ac_y: event.clientY,\n ...viewport(),\n };\n const text = safeText(element);\n if (text) properties.$ac_text = text;\n if (element instanceof HTMLAnchorElement && element.href) properties.$ac_href = element.href;\n if (file) {\n properties.$ac_file_name = file.name;\n if (file.ext) properties.$ac_file_ext = file.ext;\n }\n\n hooks.emit(properties);\n\n // A SEPARATE event, not a flag on the click: a rage click is a different question, and folding\n // it in would make \"how many clicks did this button get\" undercount by four.\n const burst = rage(element, Date.now(), event.clientX, event.clientY);\n if (burst) {\n hooks.emit({\n ...properties,\n $ac_kind: 'rage_click',\n $fr_click_count: burst.count,\n $fr_begin: burst.begin,\n $fr_end: burst.end,\n $fr_duration_ms: burst.end - burst.begin,\n // The individual clicks, so a heat map can show the burst rather than only its size. Times\n // and coordinates only — no content, like everything else here.\n //\n // Encoded as \"<msFromBegin>,<x>,<y>\" strings rather than objects, because the schema allows\n // at most ONE level of nesting in properties (event.schema.json propertyValue) and an array\n // of objects is two. Offsets rather than absolute times: they stay small, and $fr_begin\n // already carries the epoch.\n $fr_clicks: burst.clicks.map((click) => `${click.t - burst.begin},${click.x},${click.y}`),\n });\n }\n lastClick = { at: Date.now(), properties };\n };\n\n document.documentElement.addEventListener('click', onClick, { capture: true, passive: true });\n window.addEventListener('error', onError);\n return () => {\n document.documentElement.removeEventListener('click', onClick, { capture: true });\n window.removeEventListener('error', onError);\n };\n}\n\n/** `name` and `action` of a form, on both `form_start` and `form_submit`. */\nfunction formProperties(form: HTMLFormElement): Properties {\n const properties: Properties = { $ac_form_id: form.id || null };\n const name = form.getAttribute('name');\n if (name) properties.$ac_form_name = name;\n // The resolved attribute, not form.action — that falls back to the current page URL when the\n // attribute is absent, which reports a destination the markup never declared.\n const action = form.getAttribute('action');\n if (action) properties.$ac_form_action = action;\n return properties;\n}\n\ninterface FormTracker {\n stop(): void;\n /** Forgets which forms were started, so a new SPA route can report its own form_start. */\n rearm(): void;\n}\n\n/**\n * `form_start`, `change` and `form_submit`.\n *\n * `form_start` answers the question a submit-only view cannot: who began a form and gave up.\n * It fires once per form per page view — on the first `input` or `change` inside it — because the\n * useful signal is \"this form was attempted\", and one event per keystroke would be a firehose\n * that also tells you when someone typed, which is closer to user data than to behaviour.\n *\n * `change` covers selects, checkboxes and radios only. Text inputs are excluded deliberately:\n * their change event fires on blur with the field complete, so it would mark exactly the moments a\n * value exists — and the value is the one thing never captured here.\n */\nfunction captureForms(config: EngineConfig, hooks: AutocaptureHooks): FormTracker {\n // Identity-keyed, so a form removed from the DOM is collectable rather than pinned by this set.\n let started = new WeakSet<HTMLFormElement>();\n\n const onSubmit = (event: Event): void => {\n const form = event.target;\n if (!(form instanceof HTMLFormElement)) return;\n if (isIgnored(form, config.ignoredSelectors)) return;\n\n // Field NAMES only — values are never captured (privacy by construction).\n const fields = Array.from(form.elements)\n .filter((el): el is HTMLInputElement => el instanceof HTMLInputElement && !isSensitiveField(el))\n .map((el) => el.name || el.id)\n .filter(Boolean)\n .slice(0, 50);\n\n hooks.emit({\n $ac_kind: 'form_submit',\n $ac_selector: elementSelector(form, config.selectorMaxDepth, config.ignore),\n ...formProperties(form),\n $ac_form_fields: fields,\n });\n };\n\n /** First interaction with a field inside a form, for form_start. */\n const noteFormStart = (target: Element): void => {\n const form = target.closest('form');\n if (!form || started.has(form)) return;\n if (isIgnored(form, config.ignoredSelectors) || isIgnored(target, config.ignoredSelectors)) {\n return;\n }\n started.add(form);\n hooks.emit({\n $ac_kind: 'form_start',\n $ac_selector: elementSelector(form, config.selectorMaxDepth, config.ignore),\n ...formProperties(form),\n });\n };\n\n const onInput = (event: Event): void => {\n if (event.target instanceof Element) noteFormStart(event.target);\n };\n\n /**\n * One `change` listener for both kinds, not two.\n *\n * A change is a form_start candidate AND possibly a `change` event, and registering a handler\n * per concern put three new listeners on `document.documentElement` — which the A/B benchmark\n * gates on (`listeners_at_init_delta`), because every document-level capture listener is on the\n * path of every event of that type on the page.\n */\n const onChange = (event: Event): void => {\n const target = event.target;\n if (!(target instanceof Element)) return;\n noteFormStart(target);\n\n const isChoice =\n target instanceof HTMLSelectElement ||\n (target instanceof HTMLInputElement && (target.type === 'checkbox' || target.type === 'radio'));\n if (!isChoice || isIgnored(target, config.ignoredSelectors)) return;\n // No text, no href and no value: WHICH control changed, never what it was changed to. Not\n // even checked/selected — that is the value in a one-bit disguise.\n //\n // No $ac_x/$ac_y either: a change can come from a keyboard or an assistive device, and there\n // is no pointer position to report. Fabricating 0,0 would read as a click in the corner.\n hooks.emit({ $ac_kind: 'change', ...elementProperties(target, config), ...viewport() });\n };\n\n const root = document.documentElement;\n const options = { capture: true, passive: true } as const;\n root.addEventListener('submit', onSubmit, options);\n root.addEventListener('input', onInput, options);\n root.addEventListener('change', onChange, options);\n return {\n stop: () => {\n root.removeEventListener('submit', onSubmit, { capture: true });\n root.removeEventListener('input', onInput, { capture: true });\n root.removeEventListener('change', onChange, { capture: true });\n },\n rearm: () => {\n started = new WeakSet<HTMLFormElement>();\n },\n };\n}\n\nconst QUARTILES = [25, 50, 75, 100] as const;\n\n/**\n * Vertical overflow an element needs before it counts as the page's scroller.\n *\n * Roughly a phone viewport. Below it a box is an in-page control — a size-guide popover, a\n * variant list, a sticky mini-cart — and reporting \"100% scroll depth\" because someone\n * flicked through six shipping options would be worse than reporting nothing.\n */\nconst MIN_HOST_SCROLLABLE_PX = 240;\n\ninterface ScrollTracker {\n stop(): void;\n /** Re-arms the quartiles for a new SPA route, re-attaching if we had detached at 100%. */\n rearm(): void;\n /**\n * Deepest quartile crossed on the current page, for `$page_leave`'s `$page_max_scroll`.\n * Reads the already-crossed quartile rather than live layout, so asking for it during\n * `pagehide` — where there is no budget for a layout read — costs nothing.\n */\n maxDepth(): number;\n}\n\n/**\n * Scroll-depth quartiles, without a layout read per scroll event.\n *\n * The previous version read `document.documentElement.scrollHeight` inside the scroll\n * handler. That forces a synchronous style + layout flush, and scroll fires at input\n * frequency — so it was a forced reflow per frame, for the life of the page, and the\n * listener stayed attached long after all four quartiles had fired.\n *\n * Three changes make it cheap:\n * - handling is coalesced into one `requestAnimationFrame` callback per frame;\n * - the scrollable height is cached, invalidated whenever the document actually resizes,\n * and otherwise re-measured only when the cached value says we are about to cross a\n * quartile — so a lazily growing page still reports accurately, at ≤4 layout reads;\n * - the listener detaches once 100% is reached, since there is nothing left to report.\n *\n * Depth is measured against whichever box actually scrolls. Listening on `window` only\n * ever sees the viewport, so a theme whose `documentElement` and `body` are both\n * `overflow: hidden` — the content scrolling inside a wrapper instead, which is common on\n * modern Shopify themes — emitted nothing at all, for the life of the page, with no error\n * and no way to tell from the outside that the feature was inert.\n *\n * The document has ABSOLUTE PRECEDENCE in that choice: if the document can scroll at all,\n * depth is the document's, no matter which box happened to scroll first. An in-page\n * scroller is only ever adopted on a page where the document is flat. That ordering is what\n * keeps this strictly additive — every page that reported correctly before still does, and\n * the wrapper themes that reported nothing now report too.\n *\n * Invalidation watches the DOCUMENT, not just the window. `resize` fires for the viewport\n * only, so in-page height changes — a filter removing rows, an accordion collapsing, a\n * dismissed banner — left a stale, too-large `scrollable` behind, and `percent()` then\n * under-reported forever: no further quartile could ever fire. The same staleness made a\n * first measurement of exactly 0 (content one viewport tall, lazy content still to land)\n * permanent, because 0 does not satisfy the `< 0` re-measure guard.\n */\nfunction captureScrollDepth(hooks: AutocaptureHooks): ScrollTracker {\n /** Index into QUARTILES; everything below it has already been emitted. */\n let reached = 0;\n /** Cached scrollable extent of {@link host}. -1 means \"needs measuring\". */\n let scrollable = -1;\n /** Pending frame handle, or 0 when none is scheduled. */\n let frame = 0;\n let attached = false;\n /**\n * What depth is measured against, as a three-state value: `undefined` is \"not resolved\n * yet\", `null` is the viewport, an Element is an in-page scroller.\n *\n * Resolved from the first qualifying scroll event rather than searched for, so a\n * container that only exists after hydration is picked up for free — and so resolution\n * costs one layout read for the life of the page instead of a DOM walk at init.\n */\n let host: Element | null | undefined;\n\n const measure = (): void => {\n scrollable = host\n ? host.scrollHeight - host.clientHeight\n : document.documentElement.scrollHeight - window.innerHeight;\n };\n\n const percent = (): number =>\n Math.min(100, Math.round(((host ? host.scrollTop : window.scrollY) / scrollable) * 100));\n\n const evaluate = (): void => {\n frame = 0;\n // `<= 0`, not `< 0`: a page that measured as unscrollable must be re-measured rather\n // than written off, or content arriving after first paint never becomes reportable.\n // Costs nothing in the steady state — an unscrollable page emits no scroll events.\n if (scrollable <= 0) measure();\n if (scrollable <= 0) return;\n // Cheap path: cached metrics say we have not reached the next quartile, so there is\n // nothing to report and no reason to touch layout.\n if (percent() < QUARTILES[reached]!) return;\n\n // About to emit — confirm against live layout, since the page may have grown since we\n // last measured (lazy images, infinite scroll) and the cached value would over-report.\n measure();\n if (scrollable <= 0) return;\n const depth = percent();\n while (reached < QUARTILES.length && depth >= QUARTILES[reached]!) {\n hooks.emit({ $ac_kind: 'scroll_depth', $ac_depth: QUARTILES[reached]! });\n reached++;\n }\n if (reached >= QUARTILES.length) detach();\n };\n\n const onScroll = (event: Event): void => {\n // Give the host back when it can no longer be the page, and let the next branch resolve\n // again. Two ways that happens:\n //\n // - an ELEMENT host went away. A wrapper re-mounted without a history change — a\n // filter rebuilding the product grid — leaves a detached node whose metrics freeze.\n // - the VIEWPORT was adopted, has since measured as genuinely unscrollable, and\n // something else just scrolled. Only reachable once `evaluate` has measured a real\n // zero, so it costs nothing on a page that scrolls, and it keeps the viewport's\n // precedence below from being a one-way door on a theme that fires a stray window\n // scroll before its wrapper ever moves.\n //\n // `reached` deliberately survives both: still the same route, so quartiles already\n // reported must not report a second time.\n if (host && !host.isConnected) host = undefined;\n if (host === null && scrollable === 0) host = undefined;\n\n if (host === undefined) {\n // Resolved from the first scroll that actually happens, rather than by searching the\n // DOM at init: a wrapper that only exists after hydration is picked up for free, and\n // the layout reads below are paid once for the life of the page, not once per frame.\n const target = event.target;\n // THE PAGE WINS WHENEVER THE PAGE CAN SCROLL AT ALL — whatever fired this event.\n // `scroll_depth` has always meant \"how far down the page\", and on an ordinary page an\n // in-page box (a size-guide modal, a cart drawer, a sticky filter rail) is a control\n // WITHIN the page, not a replacement for it. Resolving by \"whichever box scrolled\n // first\" instead meant a shopper who nudged a modal before reading the page lost page\n // depth for the rest of the route — a page that reported correctly before the in-page\n // path existed. Anchoring on the document means this can only ever ADD coverage.\n //\n // The two tests are ordered so the common case costs nothing: a scroll from the\n // document's own scrollport IS the page and needs no measurement, so the viewport\n // path's layout-read budget is exactly what it was before in-page scrollers existed.\n // Only a scroll from some other box has to ask how far the document can go.\n //\n // No `MIN_HOST_SCROLLABLE_PX` on that second test, on purpose: the threshold exists to\n // tell a page from a control, and the document is never a control. A document with\n // 100px of overflow is still the page, and was always reported as one.\n //\n // The document measurement is not cached: a zero means \"cannot scroll YET\", and a page\n // that starts one viewport tall and grows when lazy content lands has to be able to\n // change that answer without waiting on a resize that may never come.\n //\n // The scrollport test is deliberately NOT `target === window`. A Window identity check\n // is unreliable across realms — under vitest's jsdom the event's Window and the\n // module's `window` are different objects, and the same holds inside an iframe — so it\n // silently failed and every viewport scroll was discarded. Window and Document are the\n // two scroll targets that are not Elements, and `documentElement` is the Element that\n // means the same thing; none of that needs identity. `body` is pointedly excluded: it\n // is a viewport proxy in the standard shape but a scroll container in its own right\n // under `html { overflow: hidden } body { overflow: auto }`, where the viewport\n // metrics it would send us to read are inert — which is how that theme reported\n // nothing. It goes to the element path below and is measured for real.\n if (\n !(target instanceof Element) ||\n target === document.documentElement ||\n document.documentElement.scrollHeight > window.innerHeight\n ) {\n host = null;\n } else {\n // The document cannot scroll and something else did: the wrapper-scroller theme, or\n // the `body { overflow: auto }` variant of it, which lands here too because `body`\n // is a real scroll container in that shape and `body.scrollTop` is the live value.\n //\n // A horizontal carousel has no vertical overflow and is filtered out here, as is a\n // small popover — neither is \"the page\", and reporting depth for a box the shopper\n // barely touched would be worse than reporting nothing. Returning without\n // committing leaves the host unresolved, so a real wrapper can still claim it.\n const box = target as Element;\n if (box.scrollHeight - box.clientHeight < MIN_HOST_SCROLLABLE_PX) return;\n host = box;\n }\n scrollable = -1; // metrics now come from a different box\n observeHost();\n // Not the box we report depth for: a mini-cart drawer scrolled to its end must not\n // read as \"the shopper reached the bottom of the page\".\n //\n // Only an ELEMENT host filters by target. Once the viewport is the host there is\n // nothing to filter against: depth comes from `window.scrollY`, which no in-page box\n // can move, so a stray scroll from a drawer costs one coalesced frame and emits\n // nothing. Not asking also means it no longer matters whether an engine targets\n // `document` or `body` for a page scroll — a distinction that was load-bearing here\n // and is not worth depending on.\n } else if (host && event.target !== host) {\n return;\n }\n if (frame !== 0) return; // a frame is already pending — coalesce into it\n frame = scheduleFrame(evaluate);\n };\n\n // Content height and viewport both change here, so the cache is no longer trustworthy.\n const onResize = (): void => {\n scrollable = -1;\n };\n\n /**\n * Catches content-height changes, which `resize` does not report. Without it a page that\n * SHRINKS keeps a too-large cached height and silently stops reporting quartiles.\n * Absent in older Safari and in jsdom, where the window listeners remain the fallback.\n *\n * Re-pointed at the host once one is resolved: an in-page scroller's content can grow\n * while the document's never changes, so observing the document would miss it entirely.\n *\n * An element host is observed together with its children, because the host's own box is\n * its SCROLLPORT — pinned to the viewport (`height: 100vh`) in every theme that scrolls a\n * wrapper, so it does not resize when the content inside it does. Observing it alone gave\n * the host path none of the shrink protection the document path has a test for: a wrapper\n * primed at 20,000px and then collapsed kept the stale extent, and scrolling to its true\n * bottom read ~16% and emitted nothing further. The children are what actually change\n * height. `documentElement` is no substitute here — in exactly these themes it is pinned\n * to 100vh as well.\n */\n let observer: ResizeObserver | null = null;\n const observeHost = (): void => {\n if (typeof ResizeObserver === 'undefined') return;\n try {\n observer?.disconnect();\n observer = new ResizeObserver(onResize);\n observer.observe(host ?? document.documentElement);\n // Index loop, not `for…of`: HTMLCollection is not iterable under this tsconfig's lib,\n // and a spread would cost an array per resolution for no gain.\n if (host) {\n const content = host.children;\n for (let i = 0; i < content.length; i++) observer.observe(content[i]!);\n }\n } catch {\n observer = null; // never let instrumentation break the page\n }\n };\n\n const attach = (): void => {\n if (attached) return;\n attached = true;\n // CAPTURE phase — that single flag is the whole fix. Scroll events do not bubble, so a\n // plain window listener sees only the viewport, and a theme that scrolls an inner\n // wrapper (documentElement and body both `overflow: hidden`, common on modern Shopify\n // themes) emitted nothing at all, silently, for the life of the page. The capture\n // phase runs from the root down to the target, so it delivers scroll from ANY element\n // even though the event never bubbles back up — one listener, both shapes, no DOM\n // search, and the listener stays on `window` exactly as before.\n window.addEventListener('scroll', onScroll, { capture: true, passive: true });\n window.addEventListener('resize', onResize, { passive: true });\n window.addEventListener('orientationchange', onResize, { passive: true });\n observeHost();\n };\n\n const detach = (): void => {\n if (!attached) return;\n attached = false;\n // The capture flag is part of the listener's identity — omitting it here would leave\n // the listener attached for the life of the page.\n window.removeEventListener('scroll', onScroll, { capture: true });\n window.removeEventListener('resize', onResize);\n window.removeEventListener('orientationchange', onResize);\n observer?.disconnect();\n observer = null;\n };\n\n attach();\n\n return {\n // `reached` is the index of the NEXT quartile to emit, so the deepest already crossed is\n // the one before it. 0 before any quartile is reached.\n maxDepth: () => (reached > 0 ? QUARTILES[reached - 1]! : 0),\n stop: () => {\n if (frame !== 0) cancelFrame(frame);\n frame = 0;\n detach();\n },\n rearm: () => {\n reached = 0;\n scrollable = -1;\n // A new route can scroll a different box — a PDP with a document-level scroll after\n // a collection page that scrolled an inner wrapper. Re-resolve rather than keep\n // measuring the old route's container, which may no longer be in the document.\n host = undefined;\n attach();\n },\n };\n}\n\n/** rAF where available; a macrotask in jsdom and other non-visual hosts. */\nfunction scheduleFrame(fn: () => void): number {\n if (typeof requestAnimationFrame === 'function') return requestAnimationFrame(fn);\n return setTimeout(fn, 16) as unknown as number;\n}\n\nfunction cancelFrame(handle: number): void {\n if (typeof cancelAnimationFrame === 'function') cancelAnimationFrame(handle);\n else clearTimeout(handle);\n}\n\n/** Longest a route-change `$page_view` waits for its title before it goes with what it has. */\nconst TITLE_WAIT_MS = 300;\n\n/**\n * Calls `done` once `document.title` differs from `titleAtNav`, or after TITLE_WAIT_MS —\n * whichever is first. Returns a canceller, which the client calls when it flushes early.\n *\n * Observes all of `<head>`, `subtree` and `characterData` included: frameworks replace the\n * `<title>` element as often as they edit its text, and a watch on one node would miss the\n * former. Without MutationObserver (or a `<head>`) the timeout alone decides.\n */\nfunction watchTitle(titleAtNav: string, done: () => void): () => void {\n const timer = setTimeout(done, TITLE_WAIT_MS);\n let observer: MutationObserver | undefined;\n try {\n observer = new MutationObserver(() => {\n if (document.title !== titleAtNav) done();\n });\n observer.observe(document.head, { childList: true, subtree: true, characterData: true });\n } catch {\n /* the timeout still resolves it */\n }\n return () => {\n clearTimeout(timer);\n observer?.disconnect();\n };\n}\n\nconst pathKey = (l: Location): string => l.pathname;\nconst hrefKey = (l: Location): string => l.href;\n\n/**\n * Calls `onNavigate` when the History API or a popstate changes the page, as `key` defines it:\n * the pathname for `pageviews: 'path'` (and `false`), the whole href for `'all'`. The client's\n * page-view dedupe compares the same key, so the two cannot disagree about what a page is.\n * Returns a teardown that restores the original History methods.\n */\nfunction observeNavigation(key: (l: Location) => string, onNavigate: () => void): () => void {\n let last = key(location);\n const emitIfChanged = (): void => {\n const next = key(location);\n if (next === last) return;\n last = next;\n onNavigate();\n };\n\n const originalPush = history.pushState.bind(history);\n const originalReplace = history.replaceState.bind(history);\n\n history.pushState = (...args: Parameters<History['pushState']>) => {\n originalPush(...args);\n emitIfChanged();\n };\n history.replaceState = (...args: Parameters<History['replaceState']>) => {\n originalReplace(...args);\n emitIfChanged();\n };\n window.addEventListener('popstate', emitIfChanged);\n\n return () => {\n history.pushState = originalPush;\n history.replaceState = originalReplace;\n window.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AAO,uBAA0B,WAAmB,sBAAsBA,CAAE,EACzE,WAAWA,EAAI,EAAE,CAC1B,CAEA,SAAS8E,GAAYC,EAAsB,CACrC,OAAO,sBAAyB,WAAY,qBAAqBA,CAAM,EACtE,aAAaA,CAAM,CAC1B,CAGA,IAAMC,GAAgB,IAUtB,SAASpF,GAAWqF,EAAoBC,EAA8B,CACpE,IAAMC,EAAQ,WAAWD,EAAMF,EAAa,EACxCN,EACJ,GAAI,CACFA,EAAW,IAAI,iBAAiB,IAAM,CAChC,SAAS,QAAUO,GAAYC,EAAK,CAC1C,CAAC,EACDR,EAAS,QAAQ,SAAS,KAAM,CAAE,UAAW,GAAM,QAAS,GAAM,cAAe,EAAK,CAAC,CACzF,MAAQ,CAER,CACA,MAAO,IAAM,CACX,aAAaS,CAAK,EAClBT,GAAU,WAAW,CACvB,CACF,CAEA,IAAM3E,GAAWqF,GAAwBA,EAAE,SACrCtF,GAAWsF,GAAwBA,EAAE,KAQ3C,SAASvF,GAAkBwF,EAA8B1F,EAAoC,CAC3F,IAAI2F,EAAOD,EAAI,QAAQ,EACjBE,EAAgB,IAAY,CAChC,IAAMC,EAAOH,EAAI,QAAQ,EACrBG,IAASF,IACbA,EAAOE,EACP7F,EAAW,EACb,EAEM8F,EAAe,QAAQ,UAAU,KAAK,OAAO,EAC7CC,EAAkB,QAAQ,aAAa,KAAK,OAAO,EAEzD,eAAQ,UAAY,IAAIC,IAA2C,CACjEF,EAAa,GAAGE,CAAI,EACpBJ,EAAc,CAChB,EACA,QAAQ,aAAe,IAAII,IAA8C,CACvED,EAAgB,GAAGC,CAAI,EACvBJ,EAAc,CAChB,EACA,OAAO,iBAAiB,WAAYA,CAAa,EAE1C,IAAM,CACX,QAAQ,UAAYE,EACpB,QAAQ,aAAeC,EACvB,OAAO,oBAAoB,WAAYH,CAAa,CACtD,CACF","names":["MASK","STABLE_ATTRIBUTES","elementSelector","element","maxDepth","ignore","parts","current","tag","part","attribute","value","looksGenerated","cssEscape","name","aria","classes","token","extra","GENERATED","rule","compileIgnore","sources","warn","out","source","isIgnored","ignoredSelectors","selector","SENSITIVE_INPUT_TYPES","safeText","text","isSensitiveField","input","ariaLabel","label","clip","parentLabel","labelText","legend","LABEL_TEXT_MAX","LABEL_WALK_BUDGET","HEADINGS","elementLabel","button","found","byIds","id","target","named","visibleLabel","budget","mayHaveHeading","heading","walkText","headingText","root","findHeading","walker","node","invisible","container","exclude","dataAttributes","names","INTERACTIVE_SELECTOR","startAutocapture","resolved","hooks","teardowns","config","compileIgnore","captureClicks","forms","captureForms","scroll","captureScrollDepth","leave","onNavigate","watchTitle","observeNavigation","hrefKey","pathKey","fn","stop","elementProperties","element","properties","elementSelector","classes","aria","ariaLabel","parent","parentLabel","label","elementLabel","dataAttributes","viewport","DOWNLOAD_EXTENSIONS","fileTarget","path","name","match","RAGE_WINDOW_MS","RAGE_THRESHOLD","ERROR_CLICK_WINDOW_MS","rageTracker","target","clicks","reported","now","x","y","click","interactiveOnly","rage","lastClick","onError","event","error","onClick","interactive","isIgnored","file","text","safeText","burst","formProperties","form","action","started","onSubmit","fields","el","isSensitiveField","noteFormStart","onInput","onChange","root","options","QUARTILES","MIN_HOST_SCROLLABLE_PX","reached","scrollable","frame","attached","host","measure","percent","evaluate","depth","detach","onScroll","box","observeHost","scheduleFrame","onResize","observer","content","i","attach","cancelFrame","handle","TITLE_WAIT_MS","titleAtNav","done","timer","l","key","last","emitIfChanged","next","originalPush","originalReplace","args"]}