@heycatch/sdk 0.6.0 → 0.7.0-dev.1029
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 +59 -1
- package/THIRD-PARTY-LICENSES.md +360 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +43 -76
- package/dist/index.d.ts +43 -76
- package/dist/index.js +2 -2
- package/dist/react-native.cjs +2 -0
- package/dist/react-native.d.cts +110 -0
- package/dist/react-native.d.ts +110 -0
- package/dist/react-native.js +2 -0
- package/dist/server.cjs +3 -0
- package/dist/server.d.cts +105 -0
- package/dist/server.d.ts +105 -0
- package/dist/server.js +3 -0
- package/dist/shared-CaIZ-Tgs.d.cts +251 -0
- package/dist/shared-CaIZ-Tgs.d.ts +251 -0
- package/package.json +53 -10
- package/AGENTS.md +0 -132
- package/docs/short-links.md +0 -69
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var V=Object.defineProperty;var ft=Object.getOwnPropertyDescriptor;var mt=Object.getOwnPropertyNames;var dt=Object.prototype.hasOwnProperty;var ht=(e,t)=>{for(var r in t)V(e,r,{get:t[r],enumerable:!0})},_t=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of mt(t))!dt.call(e,o)&&o!==r&&V(e,o,{get:()=>t[o],enumerable:!(n=ft(t,o))||n.enumerable});return e};var gt=e=>_t(V({},"__esModule",{value:!0}),e);var Vt={};ht(Vt,{HeyCatchProvider:()=>pt,SDK_VERSION:()=>k,STAGE:()=>Z,analytics:()=>Kt});module.exports=gt(Vt);var ce="project",xt="[a-z0-9]",Gt=new RegExp(`^${xt}$`);var qe=require("posthog-react-native");var ue;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 m=0;m<l.length;m++){let f=l[m];f in c||(c[f]=a[f].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 v=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};(ue=globalThis).__zod_globalConfig??(ue.__zod_globalConfig={});var W=globalThis.__zod_globalConfig;function P(e){return e&&Object.assign(W,e),W}function pe(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 le(e,t){return typeof t=="bigint"?t.toString():t}function fe(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function me(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 $(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 J="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function j(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function de(e){if(j(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(j(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Y(e){return de(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var he=new Set(["string","number","symbol"]);function _e(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function q(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function x(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 ge(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Yt={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 S(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 xe(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 X(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function O(e){return typeof e=="string"?e:e?.message}function E(e,t,r){let n=e.message?e.message:O(e.inst?._zod.def?.error?.(e))??O(t?.error?.(e))??O(r.customError?.(e))??O(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 Q(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}var ve=(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,le,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},ze=p("$ZodError",ve),T=p("$ZodError",ve,{Parent:Error});var zt=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 v;if(i.issues.length){let c=new(o?.Err??e)(i.issues.map(u=>E(u,s,P())));throw J(c,o?.callee),c}return i.value},L=zt(T),$t=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=>E(u,s,P())));throw J(c,o?.callee),c}return i.value},D=$t(T),yt=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 v;return s.issues.length?{success:!1,error:new(e??ze)(s.issues.map(i=>E(i,o,P())))}:{success:!0,data:s.value}},M=yt(T),bt=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=>E(i,o,P())))}:{success:!0,data:s.value}},R=bt(T);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])))",Zt=new RegExp(`^${wt}$`);var $e=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var ye=/^-?\d+(?:\.\d+)?$/,be=/^(?:true|false)$/i;var N=p("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Ze=p("$ZodCheckStringFormat",(e,t)=>{var r,n;N.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=()=>{})}),ke=p("$ZodCheckRegex",(e,t)=>{Ze.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 Ee={major:4,minor:4,patch:3};var g=p("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ee;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=S(i),l;for(let m of c){if(m._zod.def.when){if(xe(i)||!m._zod.def.when(i))continue}else if(a)continue;let f=i.issues.length,_=m._zod.check(i);if(_ instanceof Promise&&u?.async===!1)throw new v;if(l||_ instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await _,i.issues.length!==f&&(a||(a=S(i,f)))});else{if(i.issues.length===f)continue;a||(a=S(i,f))}}return l?l.then(()=>i):i},s=(i,c,u)=>{if(S(i))return i.aborted=!0,i;let a=o(c,n,u);if(a instanceof Promise){if(u.async===!1)throw new v;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 v;return u.then(a=>o(a,n,c))}return o(u,n,c)}}$(e,"~standard",()=>({validate:o=>{try{let s=M(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return R(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),Te=p("$ZodString",(e,t)=>{g.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??$e(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 Me=p("$ZodNumber",(e,t)=>{g.init(e,t),e._zod.pattern=e._zod.bag.pattern??ye,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 Re=p("$ZodBoolean",(e,t)=>{g.init(e,t),e._zod.pattern=be,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 Ce(e,t,r){e.issues.length&&t.issues.push(...X(r,e.issues)),t.value[r]=e.value}var Ne=p("$ZodArray",(e,t)=>{g.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=>Ce(a,r,i))):Ce(u,r,i)}return s.length?Promise.all(s).then(()=>r):r}});function F(e,t,r,n,o,s){let i=r in n;if(e.issues.length){if(o&&s&&!i)return;t.issues.push(...X(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 kt(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=ge(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Pt(e,t,r,n,o,s){let i=[],c=o.keySet,u=o.catchall._zod,a=u.def.type,l=u.optin==="optional",m=u.optout==="optional";for(let f in t){if(f==="__proto__"||c.has(f))continue;if(a==="never"){i.push(f);continue}let _=u.run({value:t[f],issues:[]},n);_ instanceof Promise?e.push(_.then(y=>F(y,r,f,t,l,m))):F(_,r,f,t,l,m)}return i.length&&r.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>r):r}var Oe=p("$ZodObject",(e,t)=>{if(g.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=fe(()=>kt(t));$(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 m of l.values)u[a].add(m)}}return u});let o=j,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=[],m=i.shape;for(let f of i.keys){let _=m[f],y=_._zod.optin==="optional",se=_._zod.optout==="optional",K=_._zod.run({value:a[f],issues:[]},u);K instanceof Promise?l.push(K.then(lt=>F(lt,c,f,a,y,se))):F(K,c,f,a,y,se)}return s?Pt(l,a,c,u,n.value,e):l.length?Promise.all(l).then(()=>c):c}});var je=p("$ZodEnum",(e,t)=>{g.init(e,t);let r=pe(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(o=>he.has(typeof o)).map(o=>typeof o=="string"?_e(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 Ae(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Le=p("$ZodOptional",(e,t)=>{g.init(e,t),e._zod.optin="optional",e._zod.optout="optional",$(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),$(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${me(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=>Ae(i,o)):Ae(s,o)}return r.value===void 0?r:t.innerType._zod.run(r,n)}});var De=p("$ZodDefault",(e,t)=>{g.init(e,t),e._zod.optin="optional",$(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=>Se(s,t)):Se(o,t)}});function Se(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Fe=p("$ZodCustom",(e,t)=>{N.init(e,t),g.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=>Ie(s,r,n,e));Ie(o,r,n,e)}});function Ie(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(Q(o))}}function He(e,t){return new e({type:"string",...x(t)})}function Ue(e,t){return new e({type:"number",checks:[],...x(t)})}function Be(e,t){return new e({type:"boolean",...x(t)})}function ee(e,t){return new ke({check:"string_format",format:"regex",...x(t),pattern:e})}function Ke(e,t,r){let n=x(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.");g.init(e,t),e.def=t,e.type=t.type,e.parse=(r,n)=>L(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>M(e,r,n),e.parseAsync=async(r,n)=>D(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>R(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)=>q(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.apply=r=>r(e)}),Ct=p("ZodMiniString",(e,t)=>{Te.init(e,t),z.init(e,t)});function b(e){return He(Ct,e)}var At=p("ZodMiniNumber",(e,t)=>{Me.init(e,t),z.init(e,t)});function Ve(e){return Ue(At,e)}var St=p("ZodMiniBoolean",(e,t)=>{Re.init(e,t),z.init(e,t)});function w(e){return Be(St,e)}var It=p("ZodMiniArray",(e,t)=>{Ne.init(e,t),z.init(e,t)});function te(e,t){return new It({type:"array",element:e,...x(t)})}var Tt=p("ZodMiniObject",(e,t)=>{Oe.init(e,t),z.init(e,t),$(e,"shape",()=>t.shape)});function re(e,t){let r={type:"object",shape:e??{},...x(t)};return new Tt(r)}var Mt=p("ZodMiniEnum",(e,t)=>{je.init(e,t),z.init(e,t),e.options=Object.values(t.entries)});function We(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Mt({type:"enum",entries:r,...x(t)})}var Rt=p("ZodMiniOptional",(e,t)=>{Le.init(e,t),z.init(e,t)});function h(e){return new Rt({type:"optional",innerType:e})}var Nt=p("ZodMiniDefault",(e,t)=>{De.init(e,t),z.init(e,t)});function C(e,t){return new Nt({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Y(t)}})}var Ot=p("ZodMiniCustom",(e,t)=>{Fe.init(e,t),z.init(e,t)});function ne(e,t){return Ke(Ot,e??(()=>!0),t)}var H="https://in.dev.heycatch.ai",Z="dev",k="0.7.0-dev.1029",Ge="phc_CqKdgm7xbFBs3mSdtqzrHNTfzTRKrwRmCrEB9aftENY9";function Je(e=Z){return e!=="dev"?null:`[HeyCatch] WARNING: this is an internal development build (v${k}). 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 A="unknown",Ft=["localStorage","cookie","memory","localStorage+cookie","sessionStorage"];var Ye=re({projectKey:b({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(ee(/^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:C(te(b()),[]),install:C(re({framework:C(b(),A),frameworkVersion:C(b(),A),agent:C(b(),A)}),{framework:A,frameworkVersion:A,agent:A}),autocapture:h(w()),maskAllText:h(w()),maskAllElementAttributes:h(w()),propertyDenylist:h(te(b())),sanitizeProperties:h(ne(e=>typeof e=="function")),beforeSend:h(ne(e=>typeof e=="function"||Array.isArray(e)&&e.every(t=>typeof t=="function"))),persistence:h(We(Ft)),disablePersistence:h(w()),cookieExpirationDays:h(Ve()),optOutCapturingByDefault:h(w()),respectDnt:h(w())});var oe=null;function d(){return oe}var ie=null;function Xe(){ie?.()}function Qe(e){if(oe!==null)return;let t=Ye.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 qe.PostHog(Ge,{host:H,preloadFeatureFlags:!1,disableRemoteFeatureFlags:!0,sendFeatureFlagEvent:!1,disableSurveys:!0,...t.data.optOutCapturingByDefault===void 0?{}:{defaultOptIn:!t.data.optOutCapturingByDefault}}),{install:n}=t.data,o={heycatch_framework:n.framework,heycatch_framework_version:n.frameworkVersion,heycatch_agent:n.agent};ie=()=>{r.register({heycatch_sdk_version:k,heycatch_sdk_stage:Z,heycatch_project_key:t.data.projectKey,...o}),r.group(ce,t.data.projectKey,{key:t.data.projectKey,sdk_version:k,sdk_stage:Z,framework:n.framework,framework_version:n.frameworkVersion,agent:n.agent,api_host:H})},ie(),oe=r,console.info(`[HeyCatch] SDK v${k} (${Z}) initialized \u2192 ${H}`);let s=Je();s!==null&&console.warn(s)}function et(e){return t=>{console.error(`[HeyCatch] consent ${e} could not be saved - capture state may reset on the next app launch:`,t)}}function tt(){d()?.optIn().catch(et("opt-in"))}function rt(){d()?.optOut().catch(et("opt-out"))}function nt(e,t,r){let n=d();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.identify(e,{...t?{$set:t}:{},...r?{$set_once:r}:{}})}}function ot(){let e=d();e!==null&&(e.reset(),Xe())}function U(e,t){let r=d();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 it(e,t,r){let n=d();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 st(e,t){let r=d();r!==null&&(!e&&!t||r.capture("$set",{...e?{$set:e}:{},...t?{$set_once:t}:{}}))}var ut=require("posthog-react-native"),at=require("react");var B=require("react/jsx-runtime");function Ht(){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 ct=Ht();function Ut(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 Bt({router:e}){let{useGlobalSearchParams:t,usePathname:r}=e,n=r(),o=JSON.stringify(t());return(0,at.useEffect)(()=>{U(n,Ut(o))},[n,o]),null}function pt({children:e}){let t=d();return t===null?(console.error("[HeyCatch] HeyCatchProvider mounted before init() - call analytics.init({ projectKey }) at module scope of the root layout."),e):(0,B.jsxs)(ut.PostHogProvider,{autocapture:{captureScreens:!1,captureTouches:!0},client:t,children:[ct===null?null:(0,B.jsx)(Bt,{router:ct}),e]})}var Kt={init:Qe,optInCapturing:tt,optOutCapturing:rt,resetIdentity:ot,setIdentity:nt,setPersonProperties:st,trackEvent:it,trackScreen:U};0&&(module.exports={HeyCatchProvider,SDK_VERSION,STAGE,analytics});
|
|
2
|
+
//# sourceMappingURL=react-native.cjs.map
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { d as HeyCatchPersonProperties, b as HeyCatchConfig, e as HeyCatchProperties, T as TrackOptions } from './shared-CaIZ-Tgs.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-CaIZ-Tgs.cjs';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The consent pair on native, where it is a REAL gate, not a no-op: the
|
|
7
|
+
* native transport has its own persisted opt-out, and `init()` wires
|
|
8
|
+
* `optOutCapturingByDefault` to it. A native app under GDPR needs a consent
|
|
9
|
+
* banner exactly as much as a web app does.
|
|
10
|
+
*
|
|
11
|
+
* Synchronous, matching the web spelling, so one signature serves shared
|
|
12
|
+
* code. Nothing awaits the write - the transport queues captures behind its
|
|
13
|
+
* own storage load - but a failure is reported rather than dropped.
|
|
14
|
+
*
|
|
15
|
+
* No-op before `init()`.
|
|
16
|
+
*/
|
|
17
|
+
declare function optInCapturing(): void;
|
|
18
|
+
/** The withdraw half. No-op before `init()`. */
|
|
19
|
+
declare function optOutCapturing(): void;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Link the device's anonymous visitor to the authenticated user. Same
|
|
23
|
+
* contract as the web entry: a stable internal user id - never an email or
|
|
24
|
+
* a session token - with email/name in the PROPERTIES. No-op before
|
|
25
|
+
* `init()`, mirroring the web entry.
|
|
26
|
+
*/
|
|
27
|
+
declare function setIdentity(userId: string, properties?: HeyCatchPersonProperties, propertiesOnce?: HeyCatchPersonProperties): void;
|
|
28
|
+
/**
|
|
29
|
+
* Clear the current identity. Call on sign-out so the next user on this
|
|
30
|
+
* device starts anonymous.
|
|
31
|
+
*/
|
|
32
|
+
declare function resetIdentity(): void;
|
|
33
|
+
|
|
34
|
+
declare function init(config: HeyCatchConfig): void;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Record a screen view. `HeyCatchProvider` calls this automatically on
|
|
38
|
+
* Expo Router route changes; call it manually only on a non-Expo-Router
|
|
39
|
+
* navigator (pass the current route name from your navigation container).
|
|
40
|
+
*
|
|
41
|
+
* Manual by design: the transport's own screen autocapture is broken on
|
|
42
|
+
* React Navigation v7 (what current Expo Router runs on) - its hooks may
|
|
43
|
+
* not run above the navigator, which is exactly where a provider sits.
|
|
44
|
+
*/
|
|
45
|
+
declare function trackScreen(name: string, properties?: HeyCatchProperties): void;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Record a product event. Touch autocapture (via `HeyCatchProvider`) and
|
|
49
|
+
* lifecycle events cover behaviour - this is for the moments only the app
|
|
50
|
+
* knows about. Same validation contract as the web entry; `userId` in the
|
|
51
|
+
* options is ignored here, the device session already knows who.
|
|
52
|
+
*/
|
|
53
|
+
declare function trackEvent(event: string, properties?: HeyCatchProperties, options?: TrackOptions): void;
|
|
54
|
+
/**
|
|
55
|
+
* Update the current person's properties without sending a product event -
|
|
56
|
+
* same surface as the web entry. The `$set` event is the transport's
|
|
57
|
+
* person-update carrier; it is a built-in, not a custom event, so no
|
|
58
|
+
* `heycatch_custom_user_event` stamp.
|
|
59
|
+
*/
|
|
60
|
+
declare function setPersonProperties(set?: HeyCatchPersonProperties, setOnce?: HeyCatchPersonProperties): void;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Mount once in the root layout (`app/_layout.tsx`), wrapping the layout's
|
|
64
|
+
* children. It adds the two things `init` alone cannot: touch autocapture
|
|
65
|
+
* (the transport hooks touches via a root View, so a component is
|
|
66
|
+
* structurally required) and automatic screen views on Expo Router.
|
|
67
|
+
* Everything else - lifecycle events, identity, business events - works
|
|
68
|
+
* from `init` alone.
|
|
69
|
+
*/
|
|
70
|
+
declare function HeyCatchProvider({ children, }: {
|
|
71
|
+
children: ReactNode;
|
|
72
|
+
}): ReactNode;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The React Native entry. The `react-native` export condition routes a
|
|
76
|
+
* bare `@heycatch/sdk` import here under Metro (newest Expo enables
|
|
77
|
+
* package exports with that condition), so the customer API stays ONE
|
|
78
|
+
* surface across web, server, and native.
|
|
79
|
+
*
|
|
80
|
+
* Wraps posthog-react-native - a regular dependency, deliberately NOT
|
|
81
|
+
* bundled: bundling breaks its optional-Expo-peer probing. Not a peer
|
|
82
|
+
* either: a peer would force the agent guide to name the vendor in its
|
|
83
|
+
* install line (the vendor-ban spec forbids exactly that); the dependency
|
|
84
|
+
* resolves silently instead. The Expo companions are app-level installs
|
|
85
|
+
* the guide's RN line carries (`expo-file-system` above all - without it
|
|
86
|
+
* persistence silently falls back to memory and every launch becomes a
|
|
87
|
+
* new anonymous person).
|
|
88
|
+
*
|
|
89
|
+
* Flags, surveys, replay, and error tracking are never fetched or enabled.
|
|
90
|
+
* Native-only additions to the namespace: `trackScreen`, plus the
|
|
91
|
+
* `HeyCatchProvider` component for touch autocapture + Expo Router screen
|
|
92
|
+
* views.
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The same-shaped `analytics` namespace as the web and server entries,
|
|
97
|
+
* plus the native-only `trackScreen`.
|
|
98
|
+
*/
|
|
99
|
+
declare const analytics: {
|
|
100
|
+
readonly init: typeof init;
|
|
101
|
+
readonly optInCapturing: typeof optInCapturing;
|
|
102
|
+
readonly optOutCapturing: typeof optOutCapturing;
|
|
103
|
+
readonly resetIdentity: typeof resetIdentity;
|
|
104
|
+
readonly setIdentity: typeof setIdentity;
|
|
105
|
+
readonly setPersonProperties: typeof setPersonProperties;
|
|
106
|
+
readonly trackEvent: typeof trackEvent;
|
|
107
|
+
readonly trackScreen: typeof trackScreen;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export { HeyCatchConfig, HeyCatchPersonProperties, HeyCatchProperties, HeyCatchProvider, TrackOptions, analytics };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { d as HeyCatchPersonProperties, b as HeyCatchConfig, e as HeyCatchProperties, T as TrackOptions } from './shared-CaIZ-Tgs.js';
|
|
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-CaIZ-Tgs.js';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The consent pair on native, where it is a REAL gate, not a no-op: the
|
|
7
|
+
* native transport has its own persisted opt-out, and `init()` wires
|
|
8
|
+
* `optOutCapturingByDefault` to it. A native app under GDPR needs a consent
|
|
9
|
+
* banner exactly as much as a web app does.
|
|
10
|
+
*
|
|
11
|
+
* Synchronous, matching the web spelling, so one signature serves shared
|
|
12
|
+
* code. Nothing awaits the write - the transport queues captures behind its
|
|
13
|
+
* own storage load - but a failure is reported rather than dropped.
|
|
14
|
+
*
|
|
15
|
+
* No-op before `init()`.
|
|
16
|
+
*/
|
|
17
|
+
declare function optInCapturing(): void;
|
|
18
|
+
/** The withdraw half. No-op before `init()`. */
|
|
19
|
+
declare function optOutCapturing(): void;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Link the device's anonymous visitor to the authenticated user. Same
|
|
23
|
+
* contract as the web entry: a stable internal user id - never an email or
|
|
24
|
+
* a session token - with email/name in the PROPERTIES. No-op before
|
|
25
|
+
* `init()`, mirroring the web entry.
|
|
26
|
+
*/
|
|
27
|
+
declare function setIdentity(userId: string, properties?: HeyCatchPersonProperties, propertiesOnce?: HeyCatchPersonProperties): void;
|
|
28
|
+
/**
|
|
29
|
+
* Clear the current identity. Call on sign-out so the next user on this
|
|
30
|
+
* device starts anonymous.
|
|
31
|
+
*/
|
|
32
|
+
declare function resetIdentity(): void;
|
|
33
|
+
|
|
34
|
+
declare function init(config: HeyCatchConfig): void;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Record a screen view. `HeyCatchProvider` calls this automatically on
|
|
38
|
+
* Expo Router route changes; call it manually only on a non-Expo-Router
|
|
39
|
+
* navigator (pass the current route name from your navigation container).
|
|
40
|
+
*
|
|
41
|
+
* Manual by design: the transport's own screen autocapture is broken on
|
|
42
|
+
* React Navigation v7 (what current Expo Router runs on) - its hooks may
|
|
43
|
+
* not run above the navigator, which is exactly where a provider sits.
|
|
44
|
+
*/
|
|
45
|
+
declare function trackScreen(name: string, properties?: HeyCatchProperties): void;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Record a product event. Touch autocapture (via `HeyCatchProvider`) and
|
|
49
|
+
* lifecycle events cover behaviour - this is for the moments only the app
|
|
50
|
+
* knows about. Same validation contract as the web entry; `userId` in the
|
|
51
|
+
* options is ignored here, the device session already knows who.
|
|
52
|
+
*/
|
|
53
|
+
declare function trackEvent(event: string, properties?: HeyCatchProperties, options?: TrackOptions): void;
|
|
54
|
+
/**
|
|
55
|
+
* Update the current person's properties without sending a product event -
|
|
56
|
+
* same surface as the web entry. The `$set` event is the transport's
|
|
57
|
+
* person-update carrier; it is a built-in, not a custom event, so no
|
|
58
|
+
* `heycatch_custom_user_event` stamp.
|
|
59
|
+
*/
|
|
60
|
+
declare function setPersonProperties(set?: HeyCatchPersonProperties, setOnce?: HeyCatchPersonProperties): void;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Mount once in the root layout (`app/_layout.tsx`), wrapping the layout's
|
|
64
|
+
* children. It adds the two things `init` alone cannot: touch autocapture
|
|
65
|
+
* (the transport hooks touches via a root View, so a component is
|
|
66
|
+
* structurally required) and automatic screen views on Expo Router.
|
|
67
|
+
* Everything else - lifecycle events, identity, business events - works
|
|
68
|
+
* from `init` alone.
|
|
69
|
+
*/
|
|
70
|
+
declare function HeyCatchProvider({ children, }: {
|
|
71
|
+
children: ReactNode;
|
|
72
|
+
}): ReactNode;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The React Native entry. The `react-native` export condition routes a
|
|
76
|
+
* bare `@heycatch/sdk` import here under Metro (newest Expo enables
|
|
77
|
+
* package exports with that condition), so the customer API stays ONE
|
|
78
|
+
* surface across web, server, and native.
|
|
79
|
+
*
|
|
80
|
+
* Wraps posthog-react-native - a regular dependency, deliberately NOT
|
|
81
|
+
* bundled: bundling breaks its optional-Expo-peer probing. Not a peer
|
|
82
|
+
* either: a peer would force the agent guide to name the vendor in its
|
|
83
|
+
* install line (the vendor-ban spec forbids exactly that); the dependency
|
|
84
|
+
* resolves silently instead. The Expo companions are app-level installs
|
|
85
|
+
* the guide's RN line carries (`expo-file-system` above all - without it
|
|
86
|
+
* persistence silently falls back to memory and every launch becomes a
|
|
87
|
+
* new anonymous person).
|
|
88
|
+
*
|
|
89
|
+
* Flags, surveys, replay, and error tracking are never fetched or enabled.
|
|
90
|
+
* Native-only additions to the namespace: `trackScreen`, plus the
|
|
91
|
+
* `HeyCatchProvider` component for touch autocapture + Expo Router screen
|
|
92
|
+
* views.
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The same-shaped `analytics` namespace as the web and server entries,
|
|
97
|
+
* plus the native-only `trackScreen`.
|
|
98
|
+
*/
|
|
99
|
+
declare const analytics: {
|
|
100
|
+
readonly init: typeof init;
|
|
101
|
+
readonly optInCapturing: typeof optInCapturing;
|
|
102
|
+
readonly optOutCapturing: typeof optOutCapturing;
|
|
103
|
+
readonly resetIdentity: typeof resetIdentity;
|
|
104
|
+
readonly setIdentity: typeof setIdentity;
|
|
105
|
+
readonly setPersonProperties: typeof setPersonProperties;
|
|
106
|
+
readonly trackEvent: typeof trackEvent;
|
|
107
|
+
readonly trackScreen: typeof trackScreen;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export { HeyCatchConfig, HeyCatchPersonProperties, HeyCatchProperties, HeyCatchProvider, TrackOptions, analytics };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var K=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var se="project",ct="[a-z0-9]",Ft=new RegExp(`^${ct}$`);import{PostHog as St}from"posthog-react-native";var ce;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 m=0;m<l.length;m++){let f=l[m];f in c||(c[f]=a[f].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 v=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};(ce=globalThis).__zod_globalConfig??(ce.__zod_globalConfig={});var V=globalThis.__zod_globalConfig;function Z(e){return e&&Object.assign(V,e),V}function ae(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 le(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function fe(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}var ue=Symbol("evaluating");function $(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==ue)return n===void 0&&(n=ue,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}var G="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function j(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function me(e){if(j(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(j(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function J(e){return me(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var de=new Set(["string","number","symbol"]);function he(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Y(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function x(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 _e(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Ut={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 S(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 ge(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 q(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function O(e){return typeof e=="string"?e:e?.message}function k(e,t,r){let n=e.message?e.message:O(e.inst?._zod.def?.error?.(e))??O(t?.error?.(e))??O(r.customError?.(e))??O(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 X(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}var xe=(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})},ve=p("$ZodError",xe),T=p("$ZodError",xe,{Parent:Error});var at=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 v;if(i.issues.length){let c=new(o?.Err??e)(i.issues.map(u=>k(u,s,Z())));throw G(c,o?.callee),c}return i.value},L=at(T),pt=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=>k(u,s,Z())));throw G(c,o?.callee),c}return i.value},D=pt(T),lt=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 v;return s.issues.length?{success:!1,error:new(e??ve)(s.issues.map(i=>k(i,o,Z())))}:{success:!0,data:s.value}},M=lt(T),ft=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=>k(i,o,Z())))}:{success:!0,data:s.value}},R=ft(T);var mt="(?:(?:\\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])))",dt=new RegExp(`^${mt}$`);var ze=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var $e=/^-?\d+(?:\.\d+)?$/,ye=/^(?:true|false)$/i;var N=p("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var we=p("$ZodCheckStringFormat",(e,t)=>{var r,n;N.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=()=>{})}),Ze=p("$ZodCheckRegex",(e,t)=>{we.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 Pe={major:4,minor:4,patch:3};var g=p("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Pe;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=S(i),l;for(let m of c){if(m._zod.def.when){if(ge(i)||!m._zod.def.when(i))continue}else if(a)continue;let f=i.issues.length,_=m._zod.check(i);if(_ instanceof Promise&&u?.async===!1)throw new v;if(l||_ instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await _,i.issues.length!==f&&(a||(a=S(i,f)))});else{if(i.issues.length===f)continue;a||(a=S(i,f))}}return l?l.then(()=>i):i},s=(i,c,u)=>{if(S(i))return i.aborted=!0,i;let a=o(c,n,u);if(a instanceof Promise){if(u.async===!1)throw new v;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 v;return u.then(a=>o(a,n,c))}return o(u,n,c)}}$(e,"~standard",()=>({validate:o=>{try{let s=M(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return R(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),Ie=p("$ZodString",(e,t)=>{g.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??ze(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 Te=p("$ZodNumber",(e,t)=>{g.init(e,t),e._zod.pattern=e._zod.bag.pattern??$e,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 Me=p("$ZodBoolean",(e,t)=>{g.init(e,t),e._zod.pattern=ye,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 Ee(e,t,r){e.issues.length&&t.issues.push(...q(r,e.issues)),t.value[r]=e.value}var Re=p("$ZodArray",(e,t)=>{g.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=>Ee(a,r,i))):Ee(u,r,i)}return s.length?Promise.all(s).then(()=>r):r}});function F(e,t,r,n,o,s){let i=r in n;if(e.issues.length){if(o&&s&&!i)return;t.issues.push(...q(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 ht(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=_e(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function _t(e,t,r,n,o,s){let i=[],c=o.keySet,u=o.catchall._zod,a=u.def.type,l=u.optin==="optional",m=u.optout==="optional";for(let f in t){if(f==="__proto__"||c.has(f))continue;if(a==="never"){i.push(f);continue}let _=u.run({value:t[f],issues:[]},n);_ instanceof Promise?e.push(_.then(y=>F(y,r,f,t,l,m))):F(_,r,f,t,l,m)}return i.length&&r.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>r):r}var Ne=p("$ZodObject",(e,t)=>{if(g.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=le(()=>ht(t));$(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 m of l.values)u[a].add(m)}}return u});let o=j,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=[],m=i.shape;for(let f of i.keys){let _=m[f],y=_._zod.optin==="optional",ie=_._zod.optout==="optional",B=_._zod.run({value:a[f],issues:[]},u);B instanceof Promise?l.push(B.then(st=>F(st,c,f,a,y,ie))):F(B,c,f,a,y,ie)}return s?_t(l,a,c,u,n.value,e):l.length?Promise.all(l).then(()=>c):c}});var Oe=p("$ZodEnum",(e,t)=>{g.init(e,t);let r=ae(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(o=>de.has(typeof o)).map(o=>typeof o=="string"?he(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 Ce(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var je=p("$ZodOptional",(e,t)=>{g.init(e,t),e._zod.optin="optional",e._zod.optout="optional",$(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),$(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${fe(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=>Ce(i,o)):Ce(s,o)}return r.value===void 0?r:t.innerType._zod.run(r,n)}});var Le=p("$ZodDefault",(e,t)=>{g.init(e,t),e._zod.optin="optional",$(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=>Ae(s,t)):Ae(o,t)}});function Ae(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var De=p("$ZodCustom",(e,t)=>{N.init(e,t),g.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=>Se(s,r,n,e));Se(o,r,n,e)}});function Se(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(X(o))}}function Fe(e,t){return new e({type:"string",...x(t)})}function He(e,t){return new e({type:"number",checks:[],...x(t)})}function Ue(e,t){return new e({type:"boolean",...x(t)})}function Q(e,t){return new Ze({check:"string_format",format:"regex",...x(t),pattern:e})}function Be(e,t,r){let n=x(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.");g.init(e,t),e.def=t,e.type=t.type,e.parse=(r,n)=>L(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>M(e,r,n),e.parseAsync=async(r,n)=>D(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>R(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)=>Y(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.apply=r=>r(e)}),xt=p("ZodMiniString",(e,t)=>{Ie.init(e,t),z.init(e,t)});function b(e){return Fe(xt,e)}var vt=p("ZodMiniNumber",(e,t)=>{Te.init(e,t),z.init(e,t)});function Ke(e){return He(vt,e)}var zt=p("ZodMiniBoolean",(e,t)=>{Me.init(e,t),z.init(e,t)});function w(e){return Ue(zt,e)}var $t=p("ZodMiniArray",(e,t)=>{Re.init(e,t),z.init(e,t)});function ee(e,t){return new $t({type:"array",element:e,...x(t)})}var yt=p("ZodMiniObject",(e,t)=>{Ne.init(e,t),z.init(e,t),$(e,"shape",()=>t.shape)});function te(e,t){let r={type:"object",shape:e??{},...x(t)};return new yt(r)}var bt=p("ZodMiniEnum",(e,t)=>{Oe.init(e,t),z.init(e,t),e.options=Object.values(t.entries)});function Ve(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new bt({type:"enum",entries:r,...x(t)})}var wt=p("ZodMiniOptional",(e,t)=>{je.init(e,t),z.init(e,t)});function h(e){return new wt({type:"optional",innerType:e})}var Zt=p("ZodMiniDefault",(e,t)=>{Le.init(e,t),z.init(e,t)});function P(e,t){return new Zt({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():J(t)}})}var kt=p("ZodMiniCustom",(e,t)=>{De.init(e,t),z.init(e,t)});function re(e,t){return Be(kt,e??(()=>!0),t)}var H="https://in.dev.heycatch.ai",C="dev",A="0.7.0-dev.1029",We="phc_CqKdgm7xbFBs3mSdtqzrHNTfzTRKrwRmCrEB9aftENY9";function Ge(e=C){return e!=="dev"?null:`[HeyCatch] WARNING: this is an internal development build (v${A}). 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 E="unknown",At=["localStorage","cookie","memory","localStorage+cookie","sessionStorage"];var Je=te({projectKey:b({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(Q(/^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:P(ee(b()),[]),install:P(te({framework:P(b(),E),frameworkVersion:P(b(),E),agent:P(b(),E)}),{framework:E,frameworkVersion:E,agent:E}),autocapture:h(w()),maskAllText:h(w()),maskAllElementAttributes:h(w()),propertyDenylist:h(ee(b())),sanitizeProperties:h(re(e=>typeof e=="function")),beforeSend:h(re(e=>typeof e=="function"||Array.isArray(e)&&e.every(t=>typeof t=="function"))),persistence:h(Ve(At)),disablePersistence:h(w()),cookieExpirationDays:h(Ke()),optOutCapturingByDefault:h(w()),respectDnt:h(w())});var ne=null;function d(){return ne}var oe=null;function Ye(){oe?.()}function qe(e){if(ne!==null)return;let t=Je.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 St(We,{host:H,preloadFeatureFlags:!1,disableRemoteFeatureFlags:!0,sendFeatureFlagEvent:!1,disableSurveys:!0,...t.data.optOutCapturingByDefault===void 0?{}:{defaultOptIn:!t.data.optOutCapturingByDefault}}),{install:n}=t.data,o={heycatch_framework:n.framework,heycatch_framework_version:n.frameworkVersion,heycatch_agent:n.agent};oe=()=>{r.register({heycatch_sdk_version:A,heycatch_sdk_stage:C,heycatch_project_key:t.data.projectKey,...o}),r.group(se,t.data.projectKey,{key:t.data.projectKey,sdk_version:A,sdk_stage:C,framework:n.framework,framework_version:n.frameworkVersion,agent:n.agent,api_host:H})},oe(),ne=r,console.info(`[HeyCatch] SDK v${A} (${C}) initialized \u2192 ${H}`);let s=Ge();s!==null&&console.warn(s)}function Xe(e){return t=>{console.error(`[HeyCatch] consent ${e} could not be saved - capture state may reset on the next app launch:`,t)}}function Qe(){d()?.optIn().catch(Xe("opt-in"))}function et(){d()?.optOut().catch(Xe("opt-out"))}function tt(e,t,r){let n=d();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.identify(e,{...t?{$set:t}:{},...r?{$set_once:r}:{}})}}function rt(){let e=d();e!==null&&(e.reset(),Ye())}function U(e,t){let r=d();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 nt(e,t,r){let n=d();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 ot(e,t){let r=d();r!==null&&(!e&&!t||r.capture("$set",{...e?{$set:e}:{},...t?{$set_once:t}:{}}))}import{PostHogProvider as It}from"posthog-react-native";import{useEffect as Tt}from"react";import{jsx as jt,jsxs as Lt}from"react/jsx-runtime";function Mt(){try{if(typeof K!="function")return null;let e=K("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 it=Mt();function Rt(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 Nt({router:e}){let{useGlobalSearchParams:t,usePathname:r}=e,n=r(),o=JSON.stringify(t());return Tt(()=>{U(n,Rt(o))},[n,o]),null}function Ot({children:e}){let t=d();return t===null?(console.error("[HeyCatch] HeyCatchProvider mounted before init() - call analytics.init({ projectKey }) at module scope of the root layout."),e):Lt(It,{autocapture:{captureScreens:!1,captureTouches:!0},client:t,children:[it===null?null:jt(Nt,{router:it}),e]})}var ps={init:qe,optInCapturing:Qe,optOutCapturing:et,resetIdentity:rt,setIdentity:tt,setPersonProperties:ot,trackEvent:nt,trackScreen:U};export{Ot as HeyCatchProvider,A as SDK_VERSION,C as STAGE,ps as analytics};
|
|
2
|
+
//# sourceMappingURL=react-native.js.map
|