@heycatch/sdk 0.8.1-dev.1579 → 0.8.2-dev.1657

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.
@@ -1,2 +1,2 @@
1
- "use strict";var ie=Object.defineProperty;var It=Object.getOwnPropertyDescriptor;var Tt=Object.getOwnPropertyNames;var Mt=Object.prototype.hasOwnProperty;var Rt=(e,t)=>{for(var r in t)ie(e,r,{get:t[r],enumerable:!0})},Nt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Tt(t))!Mt.call(e,o)&&o!==r&&ie(e,o,{get:()=>t[o],enumerable:!(n=It(t,o))||n.enumerable});return e};var Ot=e=>Nt(ie({},"__esModule",{value:!0}),e);var Zr={};Rt(Zr,{HeyCatchProvider:()=>St,SDK_VERSION:()=>I,STAGE:()=>S,analytics:()=>kr});module.exports=Ot(Zr);var $e="project",jt="[a-z0-9]",Er=new RegExp(`^${jt}$`);var Lt=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function se(e){let t=Lt.exec(e);if(t===null)return!1;let[,r="",n=""]=t,o=Number(r),s=Number(n);return o>255||s>255?!1:o===0||o===10||o===127||o===100&&s>=64&&s<=127||o===169&&s===254||o===172&&s>=16&&s<=31||o===192&&s===168}var Dt=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/;function Ht(e){if(e==="::1"||e==="::")return!0;if(e.startsWith("::ffff:")){let t=Dt.exec(e);if(t===null)return se(e.slice(7));let[,r="",n=""]=t,o=Number.parseInt(r,16),s=Number.parseInt(n,16);return se(`${Math.floor(o/256)}.${o%256}.${Math.floor(s/256)}.${s%256}`)}return/^f[cd][0-9a-f]{2}:/.test(e)||/^fe[89ab][0-9a-f]:/.test(e)}function Ft(e){return e.toLowerCase().replace(/^\[/,"").replace(/\]$/,"").replace(/\.+$/,"")}function be(e){let t=Ft(e);return t==="localhost"||t.endsWith(".localhost")||se(t)||Ht(t)}var xt=require("posthog-react-native");var we;function p(e,t,r){function n(c,u){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:u,constr:i,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,u);let a=i.prototype,l=Object.keys(a);for(let h=0;h<l.length;h++){let d=l[h];d in c||(c[d]=a[d].bind(c))}}let o=r?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(c){var u;let a=r?.Parent?new s:this;n(a,c),(u=a._zod).deferred??(u.deferred=[]);for(let l of a._zod.deferred)l();return a}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}var k=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};(we=globalThis).__zod_globalConfig??(we.__zod_globalConfig={});var ce=globalThis.__zod_globalConfig;function M(e){return e&&Object.assign(ce,e),ce}function Ze(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function Pe(e,t){return typeof t=="bigint"?t.toString():t}function Ee(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Ce(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}var ke=Symbol("evaluating");function P(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==ke)return n===void 0&&(n=ke,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}var ae="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Y(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ae(e){if(Y(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Y(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function pe(e){return Ae(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Se=new Set(["string","number","symbol"]);function Ie(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function le(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function b(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Te(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Ar={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function H(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Me(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function fe(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function J(e){return typeof e=="string"?e:e?.message}function R(e,t,r){let n=e.message?e.message:J(e.inst?._zod.def?.error?.(e))??J(t?.error?.(e))??J(r.customError?.(e))??J(r.localeError?.(e))??"Invalid input",{inst:o,continue:s,input:i,...c}=e;return c.path??(c.path=[]),c.message=n,t?.reportInput&&(c.input=i),c}function de(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}var Re=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Pe,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ne=p("$ZodError",Re),U=p("$ZodError",Re,{Parent:Error});var Vt=e=>(t,r,n,o)=>{let s=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new k;if(i.issues.length){let c=new(o?.Err??e)(i.issues.map(u=>R(u,s,M())));throw ae(c,o?.callee),c}return i.value},q=Vt(U),Bt=e=>async(t,r,n,o)=>{let s=n?{...n,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){let c=new(o?.Err??e)(i.issues.map(u=>R(u,s,M())));throw ae(c,o?.callee),c}return i.value},X=Bt(U),Kt=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new k;return s.issues.length?{success:!1,error:new(e??Ne)(s.issues.map(i=>R(i,o,M())))}:{success:!0,data:s.value}},V=Kt(U),Gt=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>R(i,o,M())))}:{success:!0,data:s.value}},B=Gt(U);var Wt="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Jt=new RegExp(`^${Wt}$`);var Oe=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var je=/^-?\d+(?:\.\d+)?$/,Le=/^(?:true|false)$/i;var K=p("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var He=p("$ZodCheckStringFormat",(e,t)=>{var r,n;K.init(e,t),e._zod.onattach.push(o=>{let s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Fe=p("$ZodCheckRegex",(e,t)=>{He.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}});var Ve={major:4,minor:4,patch:3};var $=p("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ve;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let o of n)for(let s of o._zod.onattach)s(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(i,c,u)=>{let a=H(i),l;for(let h of c){if(h._zod.def.when){if(Me(i)||!h._zod.def.when(i))continue}else if(a)continue;let d=i.issues.length,g=h._zod.check(i);if(g instanceof Promise&&u?.async===!1)throw new k;if(l||g instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await g,i.issues.length!==d&&(a||(a=H(i,d)))});else{if(i.issues.length===d)continue;a||(a=H(i,d))}}return l?l.then(()=>i):i},s=(i,c,u)=>{if(H(i))return i.aborted=!0,i;let a=o(c,n,u);if(a instanceof Promise){if(u.async===!1)throw new k;return a.then(l=>e._zod.parse(l,u))}return e._zod.parse(a,u)};e._zod.run=(i,c)=>{if(c.skipChecks)return e._zod.parse(i,c);if(c.direction==="backward"){let a=e._zod.parse({value:i.value,issues:[]},{...c,skipChecks:!0});return a instanceof Promise?a.then(l=>s(l,i,c)):s(a,i,c)}let u=e._zod.parse(i,c);if(u instanceof Promise){if(c.async===!1)throw new k;return u.then(a=>o(a,n,c))}return o(u,n,c)}}P(e,"~standard",()=>({validate:o=>{try{let s=V(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return B(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),Je=p("$ZodString",(e,t)=>{$.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Oe(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}});var Ye=p("$ZodNumber",(e,t)=>{$.init(e,t),e._zod.pattern=e._zod.bag.pattern??je,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}});var qe=p("$ZodBoolean",(e,t)=>{$.init(e,t),e._zod.pattern=Le,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}});function Be(e,t,r){e.issues.length&&t.issues.push(...fe(r,e.issues)),t.value[r]=e.value}var Xe=p("$ZodArray",(e,t)=>{$.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);let s=[];for(let i=0;i<o.length;i++){let c=o[i],u=t.element._zod.run({value:c,issues:[]},n);u instanceof Promise?s.push(u.then(a=>Be(a,r,i))):Be(u,r,i)}return s.length?Promise.all(s).then(()=>r):r}});function Q(e,t,r,n,o,s){let i=r in n;if(e.issues.length){if(o&&s&&!i)return;t.issues.push(...fe(r,e.issues))}if(!i&&!o){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?i&&(t.value[r]=void 0):t.value[r]=e.value}function Yt(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=Te(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function qt(e,t,r,n,o,s){let i=[],c=o.keySet,u=o.catchall._zod,a=u.def.type,l=u.optin==="optional",h=u.optout==="optional";for(let d in t){if(d==="__proto__"||c.has(d))continue;if(a==="never"){i.push(d);continue}let g=u.run({value:t[d],issues:[]},n);g instanceof Promise?e.push(g.then(v=>Q(v,r,d,t,l,h))):Q(g,r,d,t,l,h)}return i.length&&r.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>r):r}var Qe=p("$ZodObject",(e,t)=>{if($.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let c=t.shape;Object.defineProperty(t,"shape",{get:()=>{let u={...c};return Object.defineProperty(t,"shape",{value:u}),u}})}let n=Ee(()=>Yt(t));P(e._zod,"propValues",()=>{let c=t.shape,u={};for(let a in c){let l=c[a]._zod;if(l.values){u[a]??(u[a]=new Set);for(let h of l.values)u[a].add(h)}}return u});let o=Y,s=t.catchall,i;e._zod.parse=(c,u)=>{i??(i=n.value);let a=c.value;if(!o(a))return c.issues.push({expected:"object",code:"invalid_type",input:a,inst:e}),c;c.value={};let l=[],h=i.shape;for(let d of i.keys){let g=h[d],v=g._zod.optin==="optional",G=g._zod.optout==="optional",j=g._zod.run({value:a[d],issues:[]},u);j instanceof Promise?l.push(j.then(m=>Q(m,c,d,a,v,G))):Q(j,c,d,a,v,G)}return s?qt(l,a,c,u,n.value,e):l.length?Promise.all(l).then(()=>c):c}});var et=p("$ZodEnum",(e,t)=>{$.init(e,t);let r=Ze(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(o=>Se.has(typeof o)).map(o=>typeof o=="string"?Ie(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{let i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}});function Ke(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var tt=p("$ZodOptional",(e,t)=>{$.init(e,t),e._zod.optin="optional",e._zod.optout="optional",P(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),P(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Ce(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){let o=r.value,s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>Ke(i,o)):Ke(s,o)}return r.value===void 0?r:t.innerType._zod.run(r,n)}});var rt=p("$ZodDefault",(e,t)=>{$.init(e,t),e._zod.optin="optional",P(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Ge(s,t)):Ge(o,t)}});function Ge(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var nt=p("$ZodCustom",(e,t)=>{K.init(e,t),$.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(s=>We(s,r,n,e));We(o,r,n,e)}});function We(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(de(o))}}function ot(e,t){return new e({type:"string",...b(t)})}function it(e,t){return new e({type:"number",checks:[],...b(t)})}function st(e,t){return new e({type:"boolean",...b(t)})}function me(e,t){return new Fe({check:"string_format",format:"regex",...b(t),pattern:e})}function ct(e,t,r){let n=b(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}var Z=p("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");$.init(e,t),e.def=t,e.type=t.type,e.parse=(r,n)=>q(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>V(e,r,n),e.parseAsync=async(r,n)=>X(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>B(e,r,n),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]},{parent:!0}),e.with=e.check,e.clone=(r,n)=>le(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.apply=r=>r(e)}),Qt=p("ZodMiniString",(e,t)=>{Je.init(e,t),Z.init(e,t)});function A(e){return ot(Qt,e)}var er=p("ZodMiniNumber",(e,t)=>{Ye.init(e,t),Z.init(e,t)});function he(e){return it(er,e)}var tr=p("ZodMiniBoolean",(e,t)=>{qe.init(e,t),Z.init(e,t)});function E(e){return st(tr,e)}var rr=p("ZodMiniArray",(e,t)=>{Xe.init(e,t),Z.init(e,t)});function _e(e,t){return new rr({type:"array",element:e,...b(t)})}var nr=p("ZodMiniObject",(e,t)=>{Qe.init(e,t),Z.init(e,t),P(e,"shape",()=>t.shape)});function ge(e,t){let r={type:"object",shape:e??{},...b(t)};return new nr(r)}var or=p("ZodMiniEnum",(e,t)=>{et.init(e,t),Z.init(e,t),e.options=Object.values(t.entries)});function ut(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new or({type:"enum",entries:r,...b(t)})}var ir=p("ZodMiniOptional",(e,t)=>{tt.init(e,t),Z.init(e,t)});function x(e){return new ir({type:"optional",innerType:e})}var sr=p("ZodMiniDefault",(e,t)=>{rt.init(e,t),Z.init(e,t)});function N(e,t){return new sr({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():pe(t)}})}var cr=p("ZodMiniCustom",(e,t)=>{nt.init(e,t),Z.init(e,t)});function xe(e,t){return ct(cr,e??(()=>!0),t)}var ee="https://in.dev.heycatch.ai",S="dev",I="0.8.1-dev.1579",at="phc_CqKdgm7xbFBs3mSdtqzrHNTfzTRKrwRmCrEB9aftENY9";function pt(e=S){return e!=="dev"?null:`[HeyCatch] WARNING: this is an internal development build (v${I}). Events are being sent to the HeyCatch development environment and will NEVER appear in your dashboard. Reinstall the latest stable version - resolve it with \`npm view @heycatch/sdk version\` - or re-run the install guide: https://heycatch.ai/agents.md`}var O="unknown",lr=["localStorage","cookie","memory","localStorage+cookie","sessionStorage"];var lt=ge({projectKey:A({error:'config.projectKey is missing or malformed \u2014 expected a string starting with "hck_pk_". Copy it from your project page in the HeyCatch dashboard.'}).check(me(/^hck_pk_/,{error:'config.projectKey is missing or malformed \u2014 expected a string starting with "hck_pk_". Copy it from your project page in the HeyCatch dashboard.'})),tracingHosts:N(_e(A()),[]),install:N(ge({framework:N(A(),O),frameworkVersion:N(A(),O),agent:N(A(),O)}),{framework:O,frameworkVersion:O,agent:O}),autocapture:x(E()),maskAllText:x(E()),maskAllElementAttributes:x(E()),propertyDenylist:x(_e(A())),sanitizeProperties:x(xe(e=>typeof e=="function")),beforeSend:x(xe(e=>typeof e=="function"||Array.isArray(e)&&e.every(t=>typeof t=="function"))),persistence:x(ut(lr)),disablePersistence:x(E()),cookieExpirationDays:x(he()),optOutCapturingByDefault:x(E()),respectDnt:x(E()),requestBatching:x(E()),flushIntervalMs:x(he())});var fr=5e3,dr=60,mr=1e3,hr=60,_r=new Set(["$set"]),ve="heycatch_volume_cap_reached",ft=3,gr=6e4;function te({bucket:e,perMinute:t,now:r}){if(e===void 0)return t;let n=Math.max(0,r-e.at);return Math.min(t,e.tokens+n*t/gr)}function xr(e){return e===void 0||e.length===0?!1:be(vr(e))}function vr(e){if(e.startsWith("[")){let r=e.indexOf("]");return r===-1?e:e.slice(0,r+1)}let t=e.indexOf(":");return t!==-1&&t===e.lastIndexOf(":")?e.slice(0,t):e}function dt(e){let{$session_id:t,$host:r}=e.properties;return{sessionId:typeof t=="string"?t:"",host:typeof r=="string"?r:void 0}}var ht=4;function mt(e){if(e!==void 0)return typeof e=="object"&&e!==null&&"tokens"in e&&typeof e.tokens=="number"&&Number.isFinite(e.tokens)&&e.tokens>=0&&"at"in e&&typeof e.at=="number"&&Number.isFinite(e.at)?{tokens:e.tokens,at:e.at}:!1}function zr(e){if(typeof e=="object"&&e!==null&&"sessionId"in e&&typeof e.sessionId=="string"&&"count"in e&&typeof e.count=="number"&&Number.isInteger(e.count)&&e.count>=0&&"markerAttempts"in e&&typeof e.markerAttempts=="number"&&Number.isInteger(e.markerAttempts)&&e.markerAttempts>=0){let t=mt("person"in e?e.person:void 0),r=mt("localhost"in e?e.localhost:void 0);if(t!==!1&&r!==!1)return{sessionId:e.sessionId,count:e.count,markerAttempts:e.markerAttempts,person:t,localhost:r}}return null}function yr(e){if(e===null)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t.flatMap(r=>{let n=zr(r);return n===null?[]:[n]}).slice(0,ht)}catch{}return[]}function _t({store:e,warn:t,emitMarker:r,cap:n=fr,personUpdateBudget:o=dr,localhostFreeEvents:s=mr,localhostRatePerMinute:i=hr,now:c=Date.now}){let u=[],a=!1,l=!1,h=!1,d=!1;function g(){if(e===void 0||a)return u;try{return yr(e.read())}catch{return u}}function v(m){let w=g().filter(f=>f.sessionId!==m.sessionId);u=[m,...w].slice(0,ht);try{e?.write(JSON.stringify(u))}catch{a=!0}}function G(m){let w=g().find(_=>_.sessionId===m),f=u.find(_=>_.sessionId===m),y=[w,f].filter(_=>_!==void 0),W=c();function L(_,D){let C;for(let{[_]:T}of y)T!==void 0&&te({bucket:T,perMinute:D,now:W})<te({bucket:C,perMinute:D,now:W})&&(C=T);return C}return{sessionId:m,count:Math.max(0,...y.map(_=>_.count)),markerAttempts:Math.max(0,...y.map(_=>_.markerAttempts)),person:L("person",o),localhost:L("localhost",i)}}function j(m,w){let f=w,y=c(),{sessionId:W,host:L}=dt(m);f.person!==void 0&&f.person.at>y&&(f={...f,person:{...f.person,at:y}},v(f)),f.localhost!==void 0&&f.localhost.at>y&&(f={...f,localhost:{...f.localhost,at:y}},v(f));let _=_r.has(m.event),D=_?te({bucket:f.person,perMinute:o,now:y}):0;if(_&&D<1)return h||(h=!0,t(`[HeyCatch] setPersonProperties is being called more than ${o} times a minute - call it when a property changes, not on every render. Dropping the extra updates for now; other events are unaffected.`)),null;let C=f.count>=s&&xr(L),T=C?te({bucket:f.localhost,perMinute:i,now:y}):0;return C&&T<1?(d||(d=!0,t(`[HeyCatch] this local dev session (${L??"unknown host"}, session ${W||"unknown"}) sent ${s} events - throttling it to ${i} a minute so a dev loop cannot flood your analytics. Production traffic is unaffected.`)),null):(v({...f,count:f.count+1,..._?{person:{tokens:D-1,at:y}}:{},...C?{localhost:{tokens:T-1,at:y}}:{}}),m)}return m=>{if(m===null||m.event===ve)return m;let{sessionId:w}=dt(m),f=G(w);return f.count<n?j(m,f):(l||(l=!0,t(`[HeyCatch] this session sent ${n} events, the per-session cap - dropping the rest until a new session starts (session ${w||"unknown"}). A tracking call inside a render loop or an effect is the usual cause.`)),f.markerAttempts<ft&&(v({...f,markerAttempts:ft}),r({cap:n,sessionId:w})||v({...f,markerAttempts:f.markerAttempts+1})),null)}}function gt(e){let t=_t({warn:r=>{console.warn(r)},emitMarker:({cap:r})=>{let n=e();return n?.capture(ve,{heycatch_session_event_cap:r}),n!==null}});return r=>r===null||t({event:r.event,properties:r.properties??{}})===null?null:r}var re=null;function z(){return re}var ze=null;function vt(){ze?.()}function zt(e){if(re!==null)return;let t=lt.safeParse(e);if(!t.success){let i=t.error.issues[0]?.message??"init() requires a config object with { projectKey }.";console.error(`[HeyCatch] ${i}`);return}let r=new xt.PostHog(at,{host:ee,preloadFeatureFlags:!1,disableRemoteFeatureFlags:!0,sendFeatureFlagEvent:!1,disableSurveys:!0,...t.data.optOutCapturingByDefault===void 0?{}:{defaultOptIn:!t.data.optOutCapturingByDefault},before_send:[gt(()=>re)]}),{install:n}=t.data,o={heycatch_framework:n.framework,heycatch_framework_version:n.frameworkVersion,heycatch_agent:n.agent};ze=()=>{r.register({heycatch_sdk_version:I,heycatch_sdk_stage:S,heycatch_project_key:t.data.projectKey,...o}),r.group($e,t.data.projectKey,{key:t.data.projectKey,sdk_version:I,sdk_stage:S,framework:n.framework,framework_version:n.frameworkVersion,agent:n.agent,api_host:ee})},ze(),re=r,console.info(`[HeyCatch] SDK v${I} (${S}) initialized \u2192 ${ee}`);let s=pt();s!==null&&console.warn(s)}function yt(e){return t=>{console.error(`[HeyCatch] consent ${e} could not be saved - capture state may reset on the next app launch:`,t)}}function $t(){z()?.optIn().catch(yt("opt-in"))}function bt(){z()?.optOut().catch(yt("opt-out"))}var wt=require("posthog-react-native");function kt(e,t,r){let n=z();if(n!==null){if(typeof e!="string"||e.length===0){console.error("[HeyCatch] setIdentity() requires a non-empty string user id. Pass a stable internal user id from your auth provider \u2014 not an email or session token.");return}n.getPersistedProperty(wt.PostHogPersistedProperty.PersonMode)==="identified"&&n.getDistinctId()!==e&&ye(),n.identify(e,{...t?{$set:t}:{},...r?{$set_once:r}:{}})}}function ye(){let e=z();e!==null&&(e.reset(),vt())}function ne(e,t){let r=z();if(r!==null){if(typeof e!="string"||e.length===0){console.error("[HeyCatch] trackScreen() requires a non-empty screen name.");return}r.screen(e,t?t:void 0)}}function Zt(e,t,r){let n=z();if(n!==null){if(typeof e!="string"||e.length===0){console.error("[HeyCatch] trackEvent() requires a non-empty event name.");return}if(e.startsWith("$")){console.error(`[HeyCatch] trackEvent() event names cannot start with "$" (got "${e}") - that prefix is reserved for built-in events.`);return}n.capture(e,{...t,...r?.set?{$set:r.set}:{},...r?.setOnce?{$set_once:r.setOnce}:{},heycatch_custom_user_event:!0})}}function Pt(e,t){let r=z();r!==null&&(!e&&!t||r.capture("$set",{...e?{$set:e}:{},...t?{$set_once:t}:{}}))}var Ct=require("posthog-react-native"),At=require("react");var oe=require("react/jsx-runtime");function $r(){try{if(typeof require!="function")return null;let e=require("expo-router");return typeof e=="object"&&e!==null&&"usePathname"in e&&typeof e.usePathname=="function"&&"useGlobalSearchParams"in e&&typeof e.useGlobalSearchParams=="function"?{usePathname:e.usePathname,useGlobalSearchParams:e.useGlobalSearchParams}:null}catch{return null}}var Et=$r();function br(e){let t=JSON.parse(e);if(typeof t!="object"||t===null)return{};let r={};for(let[n,o]of Object.entries(t)){if(typeof o=="string"||typeof o=="number"||typeof o=="boolean"){r[n]=o;continue}Array.isArray(o)&&(r[n]=o.filter(s=>typeof s=="string").join(","))}return r}function wr({router:e}){let{useGlobalSearchParams:t,usePathname:r}=e,n=r(),o=JSON.stringify(t());return(0,At.useEffect)(()=>{ne(n,br(o))},[n,o]),null}function St({children:e}){let t=z();return t===null?(console.error("[HeyCatch] HeyCatchProvider mounted before init() - call analytics.init({ projectKey }) at module scope of the root layout."),e):(0,oe.jsxs)(Ct.PostHogProvider,{autocapture:{captureScreens:!1,captureTouches:!0},client:t,children:[Et===null?null:(0,oe.jsx)(wr,{router:Et}),e]})}var kr={init:zt,optInCapturing:$t,optOutCapturing:bt,resetIdentity:ye,setIdentity:kt,setPersonProperties:Pt,trackEvent:Zt,trackScreen:ne};0&&(module.exports={HeyCatchProvider,SDK_VERSION,STAGE,analytics});
1
+ "use strict";var se=Object.defineProperty;var Dt=Object.getOwnPropertyDescriptor;var Ft=Object.getOwnPropertyNames;var Ht=Object.prototype.hasOwnProperty;var Ut=(e,t)=>{for(var r in t)se(e,r,{get:t[r],enumerable:!0})},Vt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ft(t))!Ht.call(e,o)&&o!==r&&se(e,o,{get:()=>t[o],enumerable:!(n=Dt(t,o))||n.enumerable});return e};var Bt=e=>Vt(se({},"__esModule",{value:!0}),e);var Br={};Ut(Br,{HeyCatchProvider:()=>Lt,SDK_VERSION:()=>T,STAGE:()=>C,analytics:()=>Vr});module.exports=Bt(Br);var Pe="project",Kt="[a-z0-9]",Gr=new RegExp(`^${Kt}$`);var Gt=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function ce(e){let t=Gt.exec(e);if(t===null)return!1;let[,r="",n=""]=t,o=Number(r),i=Number(n);return o>255||i>255?!1:o===0||o===10||o===127||o===100&&i>=64&&i<=127||o===169&&i===254||o===172&&i>=16&&i<=31||o===192&&i===168}var Wt=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/;function Jt(e){if(e==="::1"||e==="::")return!0;if(e.startsWith("::ffff:")){let t=Wt.exec(e);if(t===null)return ce(e.slice(7));let[,r="",n=""]=t,o=Number.parseInt(r,16),i=Number.parseInt(n,16);return ce(`${Math.floor(o/256)}.${o%256}.${Math.floor(i/256)}.${i%256}`)}return/^f[cd][0-9a-f]{2}:/.test(e)||/^fe[89ab][0-9a-f]:/.test(e)}function Yt(e){return e.toLowerCase().replace(/^\[/,"").replace(/\]$/,"").replace(/\.+$/,"")}function Ee(e){let t=Yt(e);return t==="localhost"||t.endsWith(".localhost")||ce(t)||Jt(t)}var Pt=require("posthog-react-native");var Se;function p(e,t,r){function n(c,u){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:u,constr:s,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,u);let a=s.prototype,l=Object.keys(a);for(let h=0;h<l.length;h++){let d=l[h];d in c||(c[d]=a[d].bind(c))}}let o=r?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function s(c){var u;let a=r?.Parent?new i:this;n(a,c),(u=a._zod).deferred??(u.deferred=[]);for(let l of a._zod.deferred)l();return a}return Object.defineProperty(s,"init",{value:n}),Object.defineProperty(s,Symbol.hasInstance,{value:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}var k=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};(Se=globalThis).__zod_globalConfig??(Se.__zod_globalConfig={});var ue=globalThis.__zod_globalConfig;function R(e){return e&&Object.assign(ue,e),ue}function Ce(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function Te(e,t){return typeof t=="bigint"?t.toString():t}function Ie(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Re(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}var Ae=Symbol("evaluating");function P(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Ae)return n===void 0&&(n=Ae,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}var pe="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function q(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Me(e){if(q(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(q(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function le(e){return Me(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Ne=new Set(["string","number","symbol"]);function Oe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function fe(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function b(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function je(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Jr={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function F(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Le(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function de(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Y(e){return typeof e=="string"?e:e?.message}function M(e,t,r){let n=e.message?e.message:Y(e.inst?._zod.def?.error?.(e))??Y(t?.error?.(e))??Y(r.customError?.(e))??Y(r.localeError?.(e))??"Invalid input",{inst:o,continue:i,input:s,...c}=e;return c.path??(c.path=[]),c.message=n,t?.reportInput&&(c.input=s),c}function me(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}var De=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Te,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Fe=p("$ZodError",De),U=p("$ZodError",De,{Parent:Error});var Xt=e=>(t,r,n,o)=>{let i=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise)throw new k;if(s.issues.length){let c=new(o?.Err??e)(s.issues.map(u=>M(u,i,R())));throw pe(c,o?.callee),c}return s.value},X=Xt(U),Qt=e=>async(t,r,n,o)=>{let i=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){let c=new(o?.Err??e)(s.issues.map(u=>M(u,i,R())));throw pe(c,o?.callee),c}return s.value},Q=Qt(U),er=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new k;return i.issues.length?{success:!1,error:new(e??Fe)(i.issues.map(s=>M(s,o,R())))}:{success:!0,data:i.value}},V=er(U),tr=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>M(s,o,R())))}:{success:!0,data:i.value}},B=tr(U);var rr="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",nr=new RegExp(`^${rr}$`);var He=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Ue=/^-?\d+(?:\.\d+)?$/,Ve=/^(?:true|false)$/i;var K=p("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Ke=p("$ZodCheckStringFormat",(e,t)=>{var r,n;K.init(e,t),e._zod.onattach.push(o=>{let i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Ge=p("$ZodCheckRegex",(e,t)=>{Ke.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}});var Je={major:4,minor:4,patch:3};var $=p("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Je;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let o of n)for(let i of o._zod.onattach)i(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(s,c,u)=>{let a=F(s),l;for(let h of c){if(h._zod.def.when){if(Le(s)||!h._zod.def.when(s))continue}else if(a)continue;let d=s.issues.length,g=h._zod.check(s);if(g instanceof Promise&&u?.async===!1)throw new k;if(l||g instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await g,s.issues.length!==d&&(a||(a=F(s,d)))});else{if(s.issues.length===d)continue;a||(a=F(s,d))}}return l?l.then(()=>s):s},i=(s,c,u)=>{if(F(s))return s.aborted=!0,s;let a=o(c,n,u);if(a instanceof Promise){if(u.async===!1)throw new k;return a.then(l=>e._zod.parse(l,u))}return e._zod.parse(a,u)};e._zod.run=(s,c)=>{if(c.skipChecks)return e._zod.parse(s,c);if(c.direction==="backward"){let a=e._zod.parse({value:s.value,issues:[]},{...c,skipChecks:!0});return a instanceof Promise?a.then(l=>i(l,s,c)):i(a,s,c)}let u=e._zod.parse(s,c);if(u instanceof Promise){if(c.async===!1)throw new k;return u.then(a=>o(a,n,c))}return o(u,n,c)}}P(e,"~standard",()=>({validate:o=>{try{let i=V(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return B(e,o).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),et=p("$ZodString",(e,t)=>{$.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??He(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}});var tt=p("$ZodNumber",(e,t)=>{$.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ue,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),r}});var rt=p("$ZodBoolean",(e,t)=>{$.init(e,t),e._zod.pattern=Ve,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}});function Ye(e,t,r){e.issues.length&&t.issues.push(...de(r,e.issues)),t.value[r]=e.value}var nt=p("$ZodArray",(e,t)=>{$.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);let i=[];for(let s=0;s<o.length;s++){let c=o[s],u=t.element._zod.run({value:c,issues:[]},n);u instanceof Promise?i.push(u.then(a=>Ye(a,r,s))):Ye(u,r,s)}return i.length?Promise.all(i).then(()=>r):r}});function ee(e,t,r,n,o,i){let s=r in n;if(e.issues.length){if(o&&i&&!s)return;t.issues.push(...de(r,e.issues))}if(!s&&!o){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?s&&(t.value[r]=void 0):t.value[r]=e.value}function or(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=je(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function ir(e,t,r,n,o,i){let s=[],c=o.keySet,u=o.catchall._zod,a=u.def.type,l=u.optin==="optional",h=u.optout==="optional";for(let d in t){if(d==="__proto__"||c.has(d))continue;if(a==="never"){s.push(d);continue}let g=u.run({value:t[d],issues:[]},n);g instanceof Promise?e.push(g.then(y=>ee(y,r,d,t,l,h))):ee(g,r,d,t,l,h)}return s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>r):r}var ot=p("$ZodObject",(e,t)=>{if($.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let c=t.shape;Object.defineProperty(t,"shape",{get:()=>{let u={...c};return Object.defineProperty(t,"shape",{value:u}),u}})}let n=Ie(()=>or(t));P(e._zod,"propValues",()=>{let c=t.shape,u={};for(let a in c){let l=c[a]._zod;if(l.values){u[a]??(u[a]=new Set);for(let h of l.values)u[a].add(h)}}return u});let o=q,i=t.catchall,s;e._zod.parse=(c,u)=>{s??(s=n.value);let a=c.value;if(!o(a))return c.issues.push({expected:"object",code:"invalid_type",input:a,inst:e}),c;c.value={};let l=[],h=s.shape;for(let d of s.keys){let g=h[d],y=g._zod.optin==="optional",W=g._zod.optout==="optional",j=g._zod.run({value:a[d],issues:[]},u);j instanceof Promise?l.push(j.then(m=>ee(m,c,d,a,y,W))):ee(j,c,d,a,y,W)}return i?ir(l,a,c,u,n.value,e):l.length?Promise.all(l).then(()=>c):c}});var it=p("$ZodEnum",(e,t)=>{$.init(e,t);let r=Ce(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(o=>Ne.has(typeof o)).map(o=>typeof o=="string"?Oe(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{let s=o.value;return n.has(s)||o.issues.push({code:"invalid_value",values:r,input:s,inst:e}),o}});function qe(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var st=p("$ZodOptional",(e,t)=>{$.init(e,t),e._zod.optin="optional",e._zod.optout="optional",P(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),P(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Re(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){let o=r.value,i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(s=>qe(s,o)):qe(i,o)}return r.value===void 0?r:t.innerType._zod.run(r,n)}});var ct=p("$ZodDefault",(e,t)=>{$.init(e,t),e._zod.optin="optional",P(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>Xe(i,t)):Xe(o,t)}});function Xe(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var ut=p("$ZodCustom",(e,t)=>{K.init(e,t),$.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(i=>Qe(i,r,n,e));Qe(o,r,n,e)}});function Qe(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(me(o))}}function at(e,t){return new e({type:"string",...b(t)})}function pt(e,t){return new e({type:"number",checks:[],...b(t)})}function lt(e,t){return new e({type:"boolean",...b(t)})}function he(e,t){return new Ge({check:"string_format",format:"regex",...b(t),pattern:e})}function ft(e,t,r){let n=b(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}var Z=p("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");$.init(e,t),e.def=t,e.type=t.type,e.parse=(r,n)=>X(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>V(e,r,n),e.parseAsync=async(r,n)=>Q(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>B(e,r,n),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]},{parent:!0}),e.with=e.check,e.clone=(r,n)=>fe(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.apply=r=>r(e)}),cr=p("ZodMiniString",(e,t)=>{et.init(e,t),Z.init(e,t)});function A(e){return at(cr,e)}var ur=p("ZodMiniNumber",(e,t)=>{tt.init(e,t),Z.init(e,t)});function _e(e){return pt(ur,e)}var ar=p("ZodMiniBoolean",(e,t)=>{rt.init(e,t),Z.init(e,t)});function E(e){return lt(ar,e)}var pr=p("ZodMiniArray",(e,t)=>{nt.init(e,t),Z.init(e,t)});function ge(e,t){return new pr({type:"array",element:e,...b(t)})}var lr=p("ZodMiniObject",(e,t)=>{ot.init(e,t),Z.init(e,t),P(e,"shape",()=>t.shape)});function xe(e,t){let r={type:"object",shape:e??{},...b(t)};return new lr(r)}var fr=p("ZodMiniEnum",(e,t)=>{it.init(e,t),Z.init(e,t),e.options=Object.values(t.entries)});function dt(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new fr({type:"enum",entries:r,...b(t)})}var dr=p("ZodMiniOptional",(e,t)=>{st.init(e,t),Z.init(e,t)});function x(e){return new dr({type:"optional",innerType:e})}var mr=p("ZodMiniDefault",(e,t)=>{ct.init(e,t),Z.init(e,t)});function N(e,t){return new mr({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():le(t)}})}var hr=p("ZodMiniCustom",(e,t)=>{ut.init(e,t),Z.init(e,t)});function ye(e,t){return ft(hr,e??(()=>!0),t)}var te="https://in.dev.heycatch.ai",C="dev",T="0.8.2-dev.1657",mt="phc_CqKdgm7xbFBs3mSdtqzrHNTfzTRKrwRmCrEB9aftENY9";function ht(e=C){return e!=="dev"?null:`[HeyCatch] WARNING: this is an internal development build (v${T}). Events are being sent to the HeyCatch development environment and will NEVER appear in your dashboard. Reinstall the latest stable version - resolve it with \`npm view @heycatch/sdk version\` - or re-run the install guide: https://heycatch.ai/agents.md`}var O="unknown",yr=["localStorage","cookie","memory","localStorage+cookie","sessionStorage"];var _t=xe({projectKey:A({error:'config.projectKey is missing or malformed \u2014 expected a string starting with "hck_pk_". Copy it from your project page in the HeyCatch dashboard.'}).check(he(/^hck_pk_/,{error:'config.projectKey is missing or malformed \u2014 expected a string starting with "hck_pk_". Copy it from your project page in the HeyCatch dashboard.'})),tracingHosts:N(ge(A()),[]),install:N(xe({framework:N(A(),O),frameworkVersion:N(A(),O),agent:N(A(),O)}),{framework:O,frameworkVersion:O,agent:O}),autocapture:x(E()),maskAllText:x(E()),maskAllElementAttributes:x(E()),propertyDenylist:x(ge(A())),sanitizeProperties:x(ye(e=>typeof e=="function")),beforeSend:x(ye(e=>typeof e=="function"||Array.isArray(e)&&e.every(t=>typeof t=="function"))),persistence:x(dt(yr)),disablePersistence:x(E()),cookieExpirationDays:x(_e()),optOutCapturingByDefault:x(E()),respectDnt:x(E()),requestBatching:x(E()),flushIntervalMs:x(_e())});var gt="[redacted]",vr=/(^|[#&?])(access_token|refresh_token|token_hash|token)=[^\s#&"'<>]+/gi,zr=/(^|[^\w-])eyJ[\w-]+\.[\w-]+\.[\w-]+/g;function xt(e){return e.replaceAll(vr,`$1$2=${gt}`).replaceAll(zr,`$1${gt}`)}var $r=new Set(["$anon_distinct_id","distinct_id"]),br=["$set","$set_once"];function ve(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ze(e){return typeof e=="string"?xt(e):Array.isArray(e)?wr(e):ve(e)?yt(e,()=>!0):e}function wr(e){let t=e.map(r=>ze(r));return t.some((r,n)=>r!==e[n])?t:e}function yt(e,t){let r=!1,n=[];for(let[o,i]of Object.entries(e)){let s=t(o)?ze(i):i;s!==i&&(r=!0),n.push([o,s])}return r?Object.fromEntries(n):e}function vt(e){if(!ve(e))return e;try{let t=!1,r={...e},{properties:n}=e;if(ve(n)){let o=yt(n,i=>!$r.has(i));o!==n&&(t=!0,r.properties=o)}for(let o of br){let i=e[o],s=ze(i);s!==i&&(t=!0,r[o]=s)}return t?r:e}catch{return e}}var kr=5e3,Zr=60,Pr=1e3,Er=60,Sr=new Set(["$set"]),$e="heycatch_volume_cap_reached",zt=3,Ar=6e4;function re({bucket:e,perMinute:t,now:r}){if(e===void 0)return t;let n=Math.max(0,r-e.at);return Math.min(t,e.tokens+n*t/Ar)}function Cr(e){return e===void 0||e.length===0?!1:Ee(Tr(e))}function Tr(e){if(e.startsWith("[")){let r=e.indexOf("]");return r===-1?e:e.slice(0,r+1)}let t=e.indexOf(":");return t!==-1&&t===e.lastIndexOf(":")?e.slice(0,t):e}function $t(e){let{$session_id:t,$host:r}=e.properties;return{sessionId:typeof t=="string"?t:"",host:typeof r=="string"?r:void 0}}var wt=4;function bt(e){if(e!==void 0)return typeof e=="object"&&e!==null&&"tokens"in e&&typeof e.tokens=="number"&&Number.isFinite(e.tokens)&&e.tokens>=0&&"at"in e&&typeof e.at=="number"&&Number.isFinite(e.at)?{tokens:e.tokens,at:e.at}:!1}function Ir(e){if(typeof e=="object"&&e!==null&&"sessionId"in e&&typeof e.sessionId=="string"&&"count"in e&&typeof e.count=="number"&&Number.isInteger(e.count)&&e.count>=0&&"markerAttempts"in e&&typeof e.markerAttempts=="number"&&Number.isInteger(e.markerAttempts)&&e.markerAttempts>=0){let t=bt("person"in e?e.person:void 0),r=bt("localhost"in e?e.localhost:void 0);if(t!==!1&&r!==!1)return{sessionId:e.sessionId,count:e.count,markerAttempts:e.markerAttempts,person:t,localhost:r}}return null}function Rr(e){if(e===null)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t.flatMap(r=>{let n=Ir(r);return n===null?[]:[n]}).slice(0,wt)}catch{}return[]}function kt({store:e,warn:t,emitMarker:r,cap:n=kr,personUpdateBudget:o=Zr,localhostFreeEvents:i=Pr,localhostRatePerMinute:s=Er,now:c=Date.now}){let u=[],a=!1,l=!1,h=!1,d=!1;function g(){if(e===void 0||a)return u;try{return Rr(e.read())}catch{return u}}function y(m){let w=g().filter(f=>f.sessionId!==m.sessionId);u=[m,...w].slice(0,wt);try{e?.write(JSON.stringify(u))}catch{a=!0}}function W(m){let w=g().find(_=>_.sessionId===m),f=u.find(_=>_.sessionId===m),z=[w,f].filter(_=>_!==void 0),J=c();function L(_,D){let S;for(let{[_]:I}of z)I!==void 0&&re({bucket:I,perMinute:D,now:J})<re({bucket:S,perMinute:D,now:J})&&(S=I);return S}return{sessionId:m,count:Math.max(0,...z.map(_=>_.count)),markerAttempts:Math.max(0,...z.map(_=>_.markerAttempts)),person:L("person",o),localhost:L("localhost",s)}}function j(m,w){let f=w,z=c(),{sessionId:J,host:L}=$t(m);f.person!==void 0&&f.person.at>z&&(f={...f,person:{...f.person,at:z}},y(f)),f.localhost!==void 0&&f.localhost.at>z&&(f={...f,localhost:{...f.localhost,at:z}},y(f));let _=Sr.has(m.event),D=_?re({bucket:f.person,perMinute:o,now:z}):0;if(_&&D<1)return h||(h=!0,t(`[HeyCatch] setPersonProperties is being called more than ${o} times a minute - call it when a property changes, not on every render. Dropping the extra updates for now; other events are unaffected.`)),null;let S=f.count>=i&&Cr(L),I=S?re({bucket:f.localhost,perMinute:s,now:z}):0;return S&&I<1?(d||(d=!0,t(`[HeyCatch] this local dev session (${L??"unknown host"}, session ${J||"unknown"}) sent ${i} events - throttling it to ${s} a minute so a dev loop cannot flood your analytics. Production traffic is unaffected.`)),null):(y({...f,count:f.count+1,..._?{person:{tokens:D-1,at:z}}:{},...S?{localhost:{tokens:I-1,at:z}}:{}}),m)}return m=>{if(m===null||m.event===$e)return m;let{sessionId:w}=$t(m),f=W(w);return f.count<n?j(m,f):(l||(l=!0,t(`[HeyCatch] this session sent ${n} events, the per-session cap - dropping the rest until a new session starts (session ${w||"unknown"}). A tracking call inside a render loop or an effect is the usual cause.`)),f.markerAttempts<zt&&(y({...f,markerAttempts:zt}),r({cap:n,sessionId:w})||y({...f,markerAttempts:f.markerAttempts+1})),null)}}function Zt(e){let t=kt({warn:r=>{console.warn(r)},emitMarker:({cap:r})=>{let n=e();return n?.capture($e,{heycatch_session_event_cap:r}),n!==null}});return r=>r===null||t({event:r.event,properties:r.properties??{}})===null?null:r}var ne=null;function v(){return ne}var be=null;function Et(){be?.()}function St(e){if(ne!==null)return;let t=_t.safeParse(e);if(!t.success){let s=t.error.issues[0]?.message??"init() requires a config object with { projectKey }.";console.error(`[HeyCatch] ${s}`);return}let r=new Pt.PostHog(mt,{host:te,preloadFeatureFlags:!1,disableRemoteFeatureFlags:!0,sendFeatureFlagEvent:!1,disableSurveys:!0,...t.data.optOutCapturingByDefault===void 0?{}:{defaultOptIn:!t.data.optOutCapturingByDefault},before_send:[Zt(()=>ne),vt]}),{install:n}=t.data,o={heycatch_framework:n.framework,heycatch_framework_version:n.frameworkVersion,heycatch_agent:n.agent};be=()=>{r.register({heycatch_sdk_version:T,heycatch_sdk_stage:C,heycatch_project_key:t.data.projectKey,...o}),r.group(Pe,t.data.projectKey,{key:t.data.projectKey,sdk_version:T,sdk_stage:C,framework:n.framework,framework_version:n.frameworkVersion,agent:n.agent,api_host:te})},be(),ne=r,console.info(`[HeyCatch] SDK v${T} (${C}) initialized \u2192 ${te}`);let i=ht();i!==null&&console.warn(i)}function At(e){return t=>{console.error(`[HeyCatch] consent ${e} could not be saved - capture state may reset on the next app launch:`,t)}}function Ct(){v()?.optIn().catch(At("opt-in"))}function Tt(){v()?.optOut().catch(At("opt-out"))}var It=require("posthog-react-native");function Rt(e,t,r){let n=v();if(n!==null){if(typeof e!="string"||e.length===0){console.error("[HeyCatch] setIdentity() requires a non-empty string user id. Pass a stable internal user id from your auth provider \u2014 not an email or session token.");return}n.getPersistedProperty(It.PostHogPersistedProperty.PersonMode)==="identified"&&n.getDistinctId()!==e&&we(),n.identify(e,{...t?{$set:t}:{},...r?{$set_once:r}:{}})}}function we(){let e=v();e!==null&&(e.reset(),Et())}function oe(e,t){let r=v();if(r!==null){if(typeof e!="string"||e.length===0){console.error("[HeyCatch] trackScreen() requires a non-empty screen name.");return}r.screen(e,t?t:void 0)}}function Mt(e,t,r){let n=v();if(n!==null){if(typeof e!="string"||e.length===0){console.error("[HeyCatch] trackEvent() requires a non-empty event name.");return}if(e.startsWith("$")){console.error(`[HeyCatch] trackEvent() event names cannot start with "$" (got "${e}") - that prefix is reserved for built-in events.`);return}n.capture(e,{...t,...r?.set?{$set:r.set}:{},...r?.setOnce?{$set_once:r.setOnce}:{},heycatch_custom_user_event:!0})}}function Nt(e,t){let r=v();r!==null&&(!e&&!t||r.capture("$set",{...e?{$set:e}:{},...t?{$set_once:t}:{}}))}var jt=require("posthog-react-native"),ie=require("react");function Mr(e){return typeof e=="object"&&e!==null&&"usePathname"in e&&typeof e.usePathname=="function"&&"useGlobalSearchParams"in e&&typeof e.useGlobalSearchParams=="function"}function Nr(){try{if(typeof require!="function")return null;let e=require("expo-router");return Mr(e)?e:null}catch{return null}}var ke=Nr();var Or=new Set(["code","jwt","otp","pin","pwd","sid","sig"]),jr=["credential","email","passcode","passwd","password","secret","session","signature","token"],Lr="#",Dr=/[^\s@,]+@[^\s@,]+\.[^\s@,]+/;function Fr(e){return e.replaceAll(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[\s_-]+/).filter(t=>t.length>0)}function Hr(e,t){if(e===Lr)return!0;let r=e.toLowerCase().replaceAll(/[_-]/g,"");return r.startsWith("auth")||r.includes("key")||jr.some(n=>r.includes(n))||Fr(e).some(n=>Or.has(n))?!0:typeof t=="string"&&Dr.test(t)}function Ot(e){let t=JSON.parse(e);if(typeof t!="object"||t===null)return{};let r={};for(let[n,o]of Object.entries(t)){let i;if(typeof o=="string"||typeof o=="number"||typeof o=="boolean")i=o;else if(Array.isArray(o))i=o.filter(s=>typeof s=="string").join(",");else continue;Hr(n,i)||(r[n]=i)}return r}var G=require("react/jsx-runtime");function Ur({router:e}){let{useGlobalSearchParams:t,usePathname:r}=e,n=r(),o=JSON.stringify(t());return(0,ie.useEffect)(()=>{oe(n,Ot(o))},[n,o]),null}var Ze=class extends ie.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(t){console.error("[HeyCatch] Automatic screen views are off: an Expo Router hook threw. Call analytics.trackScreen(name) from your navigation instead.",t)}render(){return this.state.failed?null:this.props.children}};function Lt({children:e,trackScreens:t=!0}){let r=v();return r===null?(console.error("[HeyCatch] HeyCatchProvider mounted before init() - call analytics.init({ projectKey }) at module scope of the root layout."),e):(0,G.jsxs)(jt.PostHogProvider,{autocapture:{captureScreens:!1,captureTouches:!0},client:r,children:[!t||ke===null?null:(0,G.jsx)(Ze,{children:(0,G.jsx)(Ur,{router:ke})}),e]})}var Vr={init:St,optInCapturing:Ct,optOutCapturing:Tt,resetIdentity:we,setIdentity:Rt,setPersonProperties:Nt,trackEvent:Mt,trackScreen:oe};0&&(module.exports={HeyCatchProvider,SDK_VERSION,STAGE,analytics});
2
2
  //# sourceMappingURL=react-native.cjs.map
@@ -1,5 +1,3 @@
1
- import { d as HeyCatchPersonProperties, b as HeyCatchConfig, e as HeyCatchProperties, j as TrackOptions } from './shared-C0-GQTbz.cjs';
2
- export { H as HeyCatchBeforeSend, a as HeyCatchCapturedEvent, c as HeyCatchPersistence, f as HeyCatchSanitizeProperties, P as PersonPropertyUpdate, S as SDK_VERSION, h as STAGE, i as ServerTrackOptions } from './shared-C0-GQTbz.cjs';
3
1
  import { ReactNode } from 'react';
4
2
 
5
3
  /**
@@ -18,6 +16,113 @@ declare function optInCapturing(): void;
18
16
  /** The withdraw half. No-op before `init()`. */
19
17
  declare function optOutCapturing(): void;
20
18
 
19
+ /**
20
+ * Event properties a customer's app can send with `track`.
21
+ *
22
+ * Deliberately not `unknown`: these values are serialised onto the wire and
23
+ * rendered in a dashboard, so a nested object or a function would either be
24
+ * dropped upstream or arrive as `[object Object]`. Restricting the type puts
25
+ * that failure at the call site, in the customer's editor.
26
+ */
27
+ type HeyCatchProperties = Record<string, string | number | boolean | null>;
28
+ /**
29
+ * Person properties, with the canonical keys the dashboard reads.
30
+ *
31
+ * The named keys are the contract: `email` and `name` drive how a person is
32
+ * displayed, `plan` powers plan-level breakdowns, `signup_date` anchors
33
+ * account age. Use these exact names whenever the app has the value -
34
+ * customer A writing `plan` while customer B writes `tier` is what makes
35
+ * every cross-project feature impossible.
36
+ *
37
+ * Everything else is deliberately open: extra context about the user
38
+ * (payment state, feature usage, whatever is useful) passes through as-is,
39
+ * nested values included - an unlisted key must never be a type error at
40
+ * the customer's call site.
41
+ */
42
+ interface HeyCatchPersonProperties {
43
+ /** How the dashboard shows the person. A property - never the identity. */
44
+ email?: string;
45
+ /** Display name, alongside `email`. */
46
+ name?: string;
47
+ /** The app's own plan name (`free`, `pro`, …). Values are yours; the key is the contract. */
48
+ plan?: string;
49
+ /** ISO 8601. Belongs in set-once, so a later sign-in cannot move it. */
50
+ signup_date?: string;
51
+ /** Anything else useful about the user - passes through untouched. */
52
+ [key: string]: unknown;
53
+ }
54
+ /**
55
+ * Person properties, in the two flavours every analytics backend distinguishes.
56
+ *
57
+ * - `set` overwrites on every send - use for values that change (`plan`,
58
+ * `last_seen_at`).
59
+ * - `setOnce` writes only if the person does not already have the key - use for
60
+ * values that describe the beginning and must not be overwritten by a later
61
+ * visit (`signup_date`, `initial_referrer`).
62
+ *
63
+ * Named `set` / `setOnce` rather than the transport's own `$set` / `$set_once`:
64
+ * the `$` names are an implementation detail of who we send to, and this is a
65
+ * published customer-facing API that must not change if that ever does.
66
+ */
67
+ interface PersonPropertyUpdate {
68
+ set?: HeyCatchPersonProperties;
69
+ setOnce?: HeyCatchPersonProperties;
70
+ }
71
+ /**
72
+ * Options for `trackEvent`, as bundler-resolved projects see them. This is
73
+ * the shape behind the `browser` and `default` type conditions - and
74
+ * `moduleResolution: "bundler"` (Next.js, Vite) type-checks a whole
75
+ * project, route handlers included, against it, which is why `userId` must
76
+ * exist here even though the browser ignores it: one tsconfig cannot hold
77
+ * two type surfaces per file. Pure-Node backends (`nodenext`) resolve the
78
+ * `node` condition instead and get {@link ServerTrackOptions}, where the
79
+ * requirement is enforced at compile time.
80
+ *
81
+ * Delivery timing is deliberately not an option: the browser batches (and
82
+ * the transport flushes the queue on page unload), the server sends
83
+ * immediately - per-environment behaviour is the SDK's call, not the
84
+ * caller's.
85
+ */
86
+ interface TrackOptions extends PersonPropertyUpdate {
87
+ /**
88
+ * Who the event belongs to. REQUIRED on the server - there is no ambient
89
+ * person in a webhook, and the server entry's own types (and its runtime
90
+ * guard) enforce it. Ignored in the browser, where the session already
91
+ * knows. Must be the same stable internal user id passed to
92
+ * `setIdentity`.
93
+ */
94
+ userId?: string;
95
+ /**
96
+ * Server only, and only meaningful when the event happens during the
97
+ * user's OWN request (an API route, a server action): pass the incoming
98
+ * request and the event joins their live browser session - the web SDK
99
+ * stamps a session header on same-origin requests automatically. A
100
+ * webhook has no request to pass. Ignored in the browser.
101
+ */
102
+ request?: TracingRequest;
103
+ }
104
+ /**
105
+ * The slice of an incoming request the server entry reads. Both shapes in
106
+ * the wild satisfy it: a Fetch `Request` (Next route handlers, Hono, Bun -
107
+ * `headers.get`) and a Node/Express `req` (`headers` as a plain
108
+ * lowercase-keyed object), so the same call works in either.
109
+ */
110
+ interface TracingRequest {
111
+ headers: {
112
+ get: (name: string) => string | null;
113
+ } | Record<string, string | string[] | undefined>;
114
+ }
115
+ /**
116
+ * Options for the server `trackEvent` - REQUIRED, with a REQUIRED
117
+ * `userId`: a server process has no ambient person, so every event must
118
+ * say who it belongs to. Must be the same stable internal id the app
119
+ * passes to `setIdentity` in the browser; that is what joins the two. The
120
+ * server entry exports this shape as its `TrackOptions`.
121
+ */
122
+ interface ServerTrackOptions extends TrackOptions {
123
+ userId: string;
124
+ }
125
+
21
126
  /**
22
127
  * Link the device's anonymous visitor to the authenticated user. Same
23
128
  * contract as the web entry: a stable internal user id - never an email or
@@ -32,6 +137,153 @@ declare function setIdentity(userId: string, properties?: HeyCatchPersonProperti
32
137
  */
33
138
  declare function resetIdentity(): void;
34
139
 
140
+ /**
141
+ * Which HeyCatch backend this bundle was built against - `dev` or `prod`.
142
+ * Introspection for debugging ("which stage bundle is this page running?"),
143
+ * and stamped on every event as `heycatch_sdk_stage`. Describes OUR backend,
144
+ * not the customer's own app environment.
145
+ */
146
+ declare const STAGE: "dev" | "prod";
147
+ declare const SDK_VERSION: string;
148
+ /**
149
+ * One captured event, as {@link HeyCatchBeforeSend} sees it just before it
150
+ * is queued for sending.
151
+ *
152
+ * Declared structurally, listing only the fields the SDK can promise. The
153
+ * index signature carries the underlying transport's own extra keys through
154
+ * untouched, so nothing is lost and nothing here has to move when they
155
+ * change.
156
+ */
157
+ interface HeyCatchCapturedEvent {
158
+ /** Event name - an autocapture name like `$autocapture`, or your own. */
159
+ event: string;
160
+ /** The event's property bag, as it will be sent. */
161
+ properties: Record<string, unknown>;
162
+ [key: string]: unknown;
163
+ }
164
+ /**
165
+ * Runs on every event right before it is queued. Return the event to keep
166
+ * it (mutated or not), or `null` to drop it.
167
+ *
168
+ * The SDK never calls this itself and never reads its return value - it
169
+ * forwards the function to the transport, whose own code calls it.
170
+ */
171
+ type HeyCatchBeforeSend = (event: HeyCatchCapturedEvent | null) => HeyCatchCapturedEvent | null;
172
+ /** The transport's older, deprecated hook. Prefer {@link HeyCatchBeforeSend}. */
173
+ type HeyCatchSanitizeProperties = (properties: Record<string, unknown>, eventName: string) => Record<string, unknown>;
174
+ /** Where the SDK may persist the distinct id and super properties. */
175
+ type HeyCatchPersistence = 'localStorage' | 'cookie' | 'memory' | 'localStorage+cookie' | 'sessionStorage';
176
+ /**
177
+ * Frameworks the install guides can detect. **Written out as a union, not
178
+ * derived from the array below**, because
179
+ * `apps/landing-web/tests/agent-install-guides.spec.ts` matches this
180
+ * declaration as source text to assert the set agrees with the guide's
181
+ * detection table. Collapsing it to `(typeof …)[number]` leaves that guard
182
+ * matching nothing.
183
+ *
184
+ * For the same reason, do not restate the declaration's opening line anywhere
185
+ * above it - including in a comment. The guard takes the FIRST match in the
186
+ * file, so a prose copy of it wins and yields zero ids. (Written here after
187
+ * doing exactly that; the spec's vacuity check is what caught it.)
188
+ */
189
+ type KnownFramework = 'nextjs' | 'vite-react' | 'react' | 'vue' | 'svelte' | 'astro' | 'angular' | 'react-native' | 'web';
190
+ /** Coding agents that run the install. `other` is the catch-all. */
191
+ type KnownInstallAgent = 'lovable' | 'bolt' | 'v0' | 'replit' | 'cursor' | 'claude-code' | 'codex' | 'windsurf' | 'other';
192
+ /**
193
+ * Who installed the SDK and into what. Stamped as super-properties on
194
+ * every event - the dashboard reads them off the event stream, so there
195
+ * is no separate install call to make or to fail.
196
+ *
197
+ * `(string & {})` keeps the known ids as editor completions while still
198
+ * accepting anything: a framework we haven't listed yet must not block
199
+ * an install.
200
+ */
201
+ interface HeyCatchInstall {
202
+ /** Framework id from the install guide, e.g. `nextjs`. */
203
+ framework?: KnownFramework | (string & {});
204
+ /** That framework's major version, e.g. `15`. */
205
+ frameworkVersion?: string;
206
+ /** The agent doing the install, e.g. `claude-code`. */
207
+ agent?: KnownInstallAgent | (string & {});
208
+ }
209
+ /** Configuration for {@link init}. */
210
+ interface HeyCatchConfig {
211
+ /** Your project's publishable key (`hck_pk_...`). */
212
+ projectKey: string;
213
+ /** Install metadata, stamped on every event. Omit any field you can't determine. */
214
+ install?: HeyCatchInstall;
215
+ /**
216
+ * Hostnames of the app's own backends on OTHER origins (e.g.
217
+ * `api.example.com`) whose requests should carry the session header for
218
+ * server-side `trackEvent({ request })` linking. Same-origin requests
219
+ * are covered automatically - omit this unless the API lives elsewhere.
220
+ * Each listed backend must allow {@link TRACING_HEADERS} in its CORS
221
+ * preflight; one that refuses them fails that first request, and the
222
+ * headers stop going to it for the rest of the page (logged once).
223
+ */
224
+ tracingHosts?: string[];
225
+ /**
226
+ * Turn off autocapture (clicks and form submissions). Pageviews,
227
+ * page-leaves, and rage-clicks are captured separately and are NOT
228
+ * affected by this one. Costs the recap's friction signals - the web
229
+ * entry logs this once at `init()` so the tradeoff isn't silent.
230
+ */
231
+ autocapture?: boolean;
232
+ /**
233
+ * Strip autocaptured elements' text content. Costs the recap's friction
234
+ * labels - logged once at `init()`.
235
+ */
236
+ maskAllText?: boolean;
237
+ /**
238
+ * Strip autocaptured elements' attributes. Costs debugging context on
239
+ * autocaptured events - logged once at `init()`.
240
+ */
241
+ maskAllElementAttributes?: boolean;
242
+ /**
243
+ * Property keys to drop from every captured event. HeyCatch's own
244
+ * `heycatch_*` attribution keys cannot be denylisted - they are what
245
+ * attributes an event to your project, so they are filtered back out
246
+ * (and named in the console) rather than silently honoured.
247
+ */
248
+ propertyDenylist?: string[];
249
+ /** @deprecated Superseded by {@link HeyCatchConfig.beforeSend}. */
250
+ sanitizeProperties?: HeyCatchSanitizeProperties;
251
+ /** Runs on every event right before it is queued; return `null` to drop it. */
252
+ beforeSend?: HeyCatchBeforeSend | HeyCatchBeforeSend[];
253
+ /** Where the SDK persists the distinct id and super properties. */
254
+ persistence?: HeyCatchPersistence;
255
+ /** Disable persistence entirely - every pageload starts a new anonymous person. */
256
+ disablePersistence?: boolean;
257
+ /** Days before the persistence cookie expires. Defaults to 365. */
258
+ cookieExpirationDays?: number;
259
+ /**
260
+ * Start with capturing off until the app calls
261
+ * `analytics.optInCapturing()` - a proper consent gate instead of the
262
+ * "don't call init" workaround. Browser storage is held off too, not
263
+ * just sending, so no distinct id is written before consent.
264
+ */
265
+ optOutCapturingByDefault?: boolean;
266
+ /** Honor the browser's Do Not Track signal. */
267
+ respectDnt?: boolean;
268
+ /**
269
+ * Batch captured events for a few seconds before sending (the default).
270
+ * Set `false` on a multi-page site - one where each click is a full page
271
+ * load - because a visitor who navigates away inside the batch window
272
+ * takes the batch with them; iOS Safari in particular does not reliably
273
+ * let the unload send through. A single-page app can leave it unset.
274
+ * Browser only.
275
+ */
276
+ requestBatching?: boolean;
277
+ /**
278
+ * How long captured events wait for a batch, in milliseconds. Defaults to
279
+ * 3000; the accepted range is 250-5000, and a value outside it falls back
280
+ * to the default with a console warning. The gentler alternative to
281
+ * `requestBatching: false` when you want to keep batching but shrink the
282
+ * window. Browser only.
283
+ */
284
+ flushIntervalMs?: number;
285
+ }
286
+
35
287
  declare function init(config: HeyCatchConfig): void;
36
288
 
37
289
  /**
@@ -67,9 +319,14 @@ declare function setPersonProperties(set?: HeyCatchPersonProperties, setOnce?: H
67
319
  * structurally required) and automatic screen views on Expo Router.
68
320
  * Everything else - lifecycle events, identity, business events - works
69
321
  * from `init` alone.
322
+ *
323
+ * `trackScreens={false}` turns the automatic screen views off, for an app
324
+ * that already calls `analytics.trackScreen` itself and would otherwise
325
+ * count every screen twice.
70
326
  */
71
- declare function HeyCatchProvider({ children, }: {
327
+ declare function HeyCatchProvider({ children, trackScreens, }: {
72
328
  children: ReactNode;
329
+ trackScreens?: boolean;
73
330
  }): ReactNode;
74
331
 
75
332
  /**
@@ -108,4 +365,4 @@ declare const analytics: {
108
365
  readonly trackScreen: typeof trackScreen;
109
366
  };
110
367
 
111
- export { HeyCatchConfig, HeyCatchPersonProperties, HeyCatchProperties, HeyCatchProvider, TrackOptions, analytics };
368
+ export { type HeyCatchBeforeSend, type HeyCatchCapturedEvent, type HeyCatchConfig, type HeyCatchPersistence, type HeyCatchPersonProperties, type HeyCatchProperties, HeyCatchProvider, type HeyCatchSanitizeProperties, type PersonPropertyUpdate, SDK_VERSION, STAGE, type ServerTrackOptions, type TrackOptions, analytics };