@inferevents/sdk 0.1.9 → 0.1.11

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/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var v=false;function T(e){v=e;}function a(e,...t){v&&console.log(`[infer] ${e}`,...t);}function p(e,...t){v&&console.warn(`[infer] ${e}`,...t);}function I(e,...t){v&&console.error(`[infer] ${e}`,...t);}var S="infer_event_queue",m=1e3,i=[];function C(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function A(e){i.length>=m&&(p("Queue full, dropping oldest event"),i.shift()),i.push(e),a(`Queued event: ${e.event_name} (${i.length} in queue)`);}function E(e){return i.splice(0,e)}function y(){return i.length}function d(e){i=[...e,...i],i.length>m&&(i=i.slice(i.length-m));}function f(){let e=C();if(!(!e||i.length===0))try{e.setItem(S,JSON.stringify(i)),a("Persisted queue to localStorage:",i.length);}catch{}}function x(){let e=C();if(e)try{let t=e.getItem(S);if(t){let n=JSON.parse(t);Array.isArray(n)&&(i=[...n,...i],i.length>m&&(i=i.slice(i.length-m)),a("Restored queue from localStorage:",n.length)),e.removeItem(S);}}catch{}}var k="infer_anonymous_id",c=null,_=null,b={};function N(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function U(){if(c)return c;let e=N();if(e){let t=e.getItem(k);if(t)return c=t,c}if(c=crypto.randomUUID(),a("Generated anonymous_id:",c),e)try{e.setItem(k,c);}catch{}return c}function L(){return _}function O(e,t){_=e,t&&(b={...b,...t}),a("Identity set:",_,b);}var R="infer_tab_id";function M(){try{if(typeof sessionStorage>"u")return null;let e=sessionStorage.getItem(R);return e||(e=crypto.randomUUID(),sessionStorage.setItem(R,e)),e}catch{return null}}function F(){_=null,b={},c=null;let e=N();if(e)try{e.removeItem(k);}catch{}}var J="0.1.0";function V(){return typeof window<"u"&&typeof document<"u"}function j(){let e={platform:"web",sdk_version:J};if(!V())return e;typeof navigator<"u"&&(e.browser=navigator.userAgent,e.locale=navigator.language),typeof screen<"u"&&(e.screen_width=screen.width,e.screen_height=screen.height);try{e.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone;}catch{}e.page_url=window.location.href,e.pathname=window.location.pathname,e.page_title=document.title,e.referrer=document.referrer||void 0,e.os=Z(navigator.userAgent),e.device_type=W(navigator.userAgent);let t=M();t&&(e.tab_id=t),e.landing_page=H();let n=G();return n.utm_source&&(e.utm_source=n.utm_source),n.utm_medium&&(e.utm_medium=n.utm_medium),n.utm_campaign&&(e.utm_campaign=n.utm_campaign),n.utm_term&&(e.utm_term=n.utm_term),n.utm_content&&(e.utm_content=n.utm_content),e}var P="infer_landing_page";function H(){try{let e=sessionStorage.getItem(P);if(e)return e;let t=window.location.pathname;return sessionStorage.setItem(P,t),t}catch{return window.location.pathname}}var X=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],D="infer_utm";function G(){try{let e=sessionStorage.getItem(D);if(e)return JSON.parse(e);let t=new URLSearchParams(window.location.search),n={};for(let r of X){let o=t.get(r);o&&(n[r]=o);}return Object.keys(n).length>0&&sessionStorage.setItem(D,JSON.stringify(n)),n}catch{return {}}}function Z(e){return /Windows/.test(e)?"Windows":/iPhone|iPad|iPod/.test(e)?"iOS":/Mac OS X/.test(e)?"macOS":/Android/.test(e)?"Android":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"ChromeOS":"Unknown"}function W(e){return /Mobi|Android.*Mobile|iPhone|iPod/.test(e)?"Mobile":/iPad|Android(?!.*Mobile)|Tablet/.test(e)?"Tablet":"Desktop"}var $="infer_session_last_active";var Q={pageView:true,session:true,click:true,formSubmit:true,error:true};function z(e){return e===false?null:e===true?{...Q}:{...Q,...e}}var h=new Map,q=500;function Y(e){let t=Date.now(),n=h.get(e);if(n&&t-n<q)return true;if(h.set(e,t),h.size>50)for(let[r,o]of h)t-o>q&&h.delete(r);return false}function B(e,t){if(typeof window>"u")return ()=>{};let n=[];return t.session&&ee(e),t.pageView&&n.push(te(e)),t.click&&n.push(ne(e)),t.formSubmit&&n.push(re(e)),t.error&&n.push(oe(e)),()=>{for(let r of n)r();}}function ee(e){try{let t=Date.now(),n=sessionStorage.getItem($);(!n||t-Number(n)>18e5)&&e.trackInternal("session_start",{}),sessionStorage.setItem($,String(t));}catch{}}function te(e){e.trackInternal("page_view",{url:window.location.href,path:window.location.pathname,title:document.title});let t=history.pushState.bind(history),n=history.replaceState.bind(history),r=()=>{e.trackInternal("page_view",{url:window.location.href,path:window.location.pathname,title:document.title});};return history.pushState=function(...o){t(...o),r();},history.replaceState=function(...o){n(...o),r();},window.addEventListener("popstate",r),()=>{history.pushState=t,history.replaceState=n,window.removeEventListener("popstate",r);}}function ne(e){let t=n=>{let r=n.target;if(!r)return;let o=r.closest("a, button, [role='button'], input[type='submit']");if(!o)return;let u=`click:${o.id||o.className||o.tagName}`;if(Y(u))return;let l={tag:o.tagName.toLowerCase()};o.id&&(l.element_id=o.id),o.className&&typeof o.className=="string"&&(l.element_class=o.className),o.tagName==="A"&&(l.href=o.href),e.trackInternal("click",l);};return document.addEventListener("click",t,{capture:true}),()=>document.removeEventListener("click",t,{capture:true})}function re(e){let t=n=>{let r=n.target;r&&queueMicrotask(()=>{let o=`form_submit:${r.id||r.action||""}`;if(Y(o))return;let u={};r.id&&(u.form_id=r.id),r.action&&(u.form_action=r.action),r.method&&(u.form_method=r.method.toUpperCase()),n.defaultPrevented&&(u.prevented=true),e.trackInternal("form_submit",u);});};return document.addEventListener("submit",t,{capture:true}),()=>document.removeEventListener("submit",t,{capture:true})}function oe(e){let t=r=>{e.trackInternal("error",{message:r.message||"Unknown error",filename:r.filename||null,lineno:r.lineno||null,colno:r.colno||null});},n=r=>{let o=r.reason instanceof Error?r.reason.message:typeof r.reason=="string"?r.reason:"Unhandled promise rejection";e.trackInternal("error",{message:o,type:"unhandledrejection"});};return window.addEventListener("error",t),window.addEventListener("unhandledrejection",n),()=>{window.removeEventListener("error",t),window.removeEventListener("unhandledrejection",n);}}var ie="https://api.infer.events",se=20,ae=1e4,ue=3e4,ce=1e3,K=5,w=class{config;flushTimer=null;teardownAutoTrack=null;flushing=false;retryCount=0;disabled=false;constructor(t){if(!t.projectId||typeof t.projectId!="string")throw new Error("[infer] projectId is required");if(T(t.debug??false),this.config={projectId:t.projectId,endpoint:t.endpoint??ie,batchSize:t.batchSize??se,flushInterval:t.flushInterval??ae},a("Initialized with config:",this.config),x(),this.flushTimer=setInterval(()=>{this.flush();},this.config.flushInterval),typeof window<"u"){let r=()=>{f(),this.sendBeacon();};window.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&r();}),window.addEventListener("pagehide",r);}let n=z(t.autoTrack??false);n&&(this.teardownAutoTrack=B(this,n));}track(t,n,r){this.enqueueEvent("track",t,n??{},r?.category);}identify(t,n){O(t,n),this.enqueueEvent("identify","identify",n??{});}page(t){let n={};t&&(n.name=t),typeof window<"u"&&(n.url=window.location.href,n.path=window.location.pathname,n.title=document.title),this.enqueueEvent("page","page_view",n);}screen(t){this.enqueueEvent("screen","screen_view",{name:t});}trackInternal(t,n){this.enqueueEvent("track",t,n);}async flush(){if(this.disabled||this.flushing||y()===0)return;this.flushing=true;let t=E(this.config.batchSize);a(`Flushing ${t.length} events`);try{let n=await fetch(`${this.config.endpoint}/v1/events`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.projectId}`},body:JSON.stringify({events:t})});n.ok?(this.retryCount=0,a(`Flushed ${t.length} events successfully`)):n.status>=500?(p(`Server error ${n.status}, will retry`),d(t),this.scheduleRetry()):I(`Client error ${n.status}, dropping batch`);}catch(n){if(this.retryCount>=K){I(`Cannot connect to ${this.config.endpoint} after ${K} attempts. If your site uses a Content Security Policy, add ${this.config.endpoint} to connect-src. Events will be dropped until the page is reloaded.`),this.disabled=true;return}p("Network error, will retry:",n),d(t),this.scheduleRetry();}finally{this.flushing=false;}y()>0&&this.flush();}destroy(){this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null),this.teardownAutoTrack&&(this.teardownAutoTrack(),this.teardownAutoTrack=null),f();}enqueueEvent(t,n,r,o){let u={event_id:crypto.randomUUID(),project_id:this.config.projectId,anonymous_id:U(),event_name:n,event_type:t,properties:r,context:j(),timestamp:new Date().toISOString()};o&&(u.category=o);let l=L();l&&(u.user_id=l),A(u),y()>=this.config.batchSize&&this.flush();}sendBeacon(){let t=E(this.config.batchSize);if(t.length!==0)try{fetch(`${this.config.endpoint}/v1/events`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.projectId}`},body:JSON.stringify({events:t}),keepalive:!0}).then(n=>{n.ok?a(`Beacon sent ${t.length} events`):(d(t),f());}).catch(()=>{d(t),f();});}catch{d(t),f();}}scheduleRetry(){this.retryCount++;let t=Math.min(ce*Math.pow(2,this.retryCount-1)+Math.random()*1e3,ue);a(`Retry #${this.retryCount} in ${Math.round(t)}ms`),setTimeout(()=>{this.flush();},t);}};var s=null,g=[];function ke(e){s&&s.destroy(),s=new w(e);for(let t of g)switch(t.type){case "track":s.track(...t.args);break;case "identify":s.identify(...t.args);break;case "page":s.page(...t.args);break;case "screen":s.screen(...t.args);break}return g=[],s}function Te(e,t,n){if(!s){g.push({type:"track",args:[e,t,n]});return}s.track(e,t,n);}function Ce(e,t){if(!s){g.push({type:"identify",args:[e,t]});return}s.identify(e,t);}function Ae(e){if(!s){g.push({type:"page",args:[e]});return}s.page(e);}function xe(e){if(!s){g.push({type:"screen",args:[e]});return}s.screen(e);}async function Re(){s&&await s.flush();}function Ne(){s&&(s.destroy(),s=null);}
2
- exports.destroy=Ne;exports.flush=Re;exports.identify=Ce;exports.init=ke;exports.page=Ae;exports.reset=F;exports.screen=xe;exports.track=Te;
1
+ 'use strict';var v=false;function C(e){v=e;}function u(e,...t){v&&console.log(`[infer] ${e}`,...t);}function p(e,...t){v&&console.warn(`[infer] ${e}`,...t);}function I(e,...t){v&&console.error(`[infer] ${e}`,...t);}var E="infer_event_queue",m=1e3,s=[];function A(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function x(e){s.length>=m&&(p("Queue full, dropping oldest event"),s.shift()),s.push(e),u(`Queued event: ${e.event_name} (${s.length} in queue)`);}function k(e){return s.splice(0,e)}function y(){return s.length}function d(e){s=[...e,...s],s.length>m&&(s=s.slice(s.length-m));}function f(){let e=A();if(!(!e||s.length===0))try{e.setItem(E,JSON.stringify(s)),u("Persisted queue to localStorage:",s.length);}catch{}}function R(){let e=A();if(e)try{let t=e.getItem(E);if(t){let n=JSON.parse(t);Array.isArray(n)&&(s=[...n,...s],s.length>m&&(s=s.slice(s.length-m)),u("Restored queue from localStorage:",n.length)),e.removeItem(E);}}catch{}}var T="infer_anonymous_id",l=null,_=null,b={};function U(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function O(){if(l)return l;let e=U();if(e){let t=e.getItem(T);if(t)return l=t,l}if(l=crypto.randomUUID(),u("Generated anonymous_id:",l),e)try{e.setItem(T,l);}catch{}return l}function L(){return _}function M(e,t){_=e,t&&(b={...b,...t}),u("Identity set:",_,b);}var N="infer_tab_id";function P(){try{if(typeof sessionStorage>"u")return null;let e=sessionStorage.getItem(N);return e||(e=crypto.randomUUID(),sessionStorage.setItem(N,e)),e}catch{return null}}function H(){_=null,b={},l=null;let e=U();if(e)try{e.removeItem(T);}catch{}}var W="0.1.0";function X(){return typeof window<"u"&&typeof document<"u"}function j(){let e={platform:"web",sdk_version:W};if(!X())return e;typeof navigator<"u"&&(e.browser=navigator.userAgent,e.locale=navigator.language),typeof screen<"u"&&(e.screen_width=screen.width,e.screen_height=screen.height);try{e.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone;}catch{}e.page_url=window.location.href,e.pathname=window.location.pathname,e.page_title=document.title,e.referrer=document.referrer||void 0,e.os=te(navigator.userAgent),e.device_type=ne(navigator.userAgent);let t=P();t&&(e.tab_id=t),e.landing_page=G();let n=ee();return n.utm_source&&(e.utm_source=n.utm_source),n.utm_medium&&(e.utm_medium=n.utm_medium),n.utm_campaign&&(e.utm_campaign=n.utm_campaign),n.utm_term&&(e.utm_term=n.utm_term),n.utm_content&&(e.utm_content=n.utm_content),e}var D="infer_landing_page";function G(){try{let e=sessionStorage.getItem(D);if(e)return e;let t=window.location.pathname;return sessionStorage.setItem(D,t),t}catch{return window.location.pathname}}var Z=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],$="infer_utm";function ee(){try{let e=sessionStorage.getItem($);if(e)return JSON.parse(e);let t=new URLSearchParams(window.location.search),n={};for(let r of Z){let o=t.get(r);o&&(n[r]=o);}return Object.keys(n).length>0&&sessionStorage.setItem($,JSON.stringify(n)),n}catch{return {}}}function te(e){return /Windows/.test(e)?"Windows":/iPhone|iPad|iPod/.test(e)?"iOS":/Mac OS X/.test(e)?"macOS":/Android/.test(e)?"Android":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"ChromeOS":"Unknown"}function ne(e){return /Mobi|Android.*Mobile|iPhone|iPod/.test(e)?"Mobile":/iPad|Android(?!.*Mobile)|Tablet/.test(e)?"Tablet":"Desktop"}var Q="infer_session_last_active";var q={pageView:true,session:true,click:true,formSubmit:true,error:true};function K(e){return e===false?null:e===true?{...q}:{...q,...e}}var h=new Map,z=500;function F(e){let t=Date.now(),n=h.get(e);if(n&&t-n<z)return true;if(h.set(e,t),h.size>50)for(let[r,o]of h)t-o>z&&h.delete(r);return false}function J(e,t){if(typeof window>"u")return ()=>{};let n=[];return t.session&&re(e),t.pageView&&n.push(oe(e)),t.click&&n.push(ie(e)),t.formSubmit&&n.push(se(e)),t.error&&n.push(ue(e)),()=>{for(let r of n)r();}}function re(e){try{let t=Date.now(),n=sessionStorage.getItem(Q);(!n||t-Number(n)>18e5)&&e.trackInternal("session_start",{}),sessionStorage.setItem(Q,String(t));}catch{}}function oe(e){e.trackInternal("page_view",{url:window.location.href,path:window.location.pathname,title:document.title});let t=history.pushState.bind(history),n=history.replaceState.bind(history),r=()=>{e.trackInternal("page_view",{url:window.location.href,path:window.location.pathname,title:document.title});};return history.pushState=function(...o){t(...o),r();},history.replaceState=function(...o){n(...o),r();},window.addEventListener("popstate",r),()=>{history.pushState=t,history.replaceState=n,window.removeEventListener("popstate",r);}}function ie(e){let t=n=>{let r=n.target;if(!r)return;let o=r.closest("a, button, [role='button'], input[type='submit']");if(!o)return;let i=`click:${o.id||o.className||o.tagName}`;if(F(i))return;let c={tag:o.tagName.toLowerCase()};o.id&&(c.element_id=o.id),o.className&&typeof o.className=="string"&&(c.element_class=o.className),o.tagName==="A"&&(c.href=o.href),e.trackInternal("click",c);};return document.addEventListener("click",t,{capture:true}),()=>document.removeEventListener("click",t,{capture:true})}function se(e){let t=n=>{let r=n.target;r&&queueMicrotask(()=>{let o=`form_submit:${r.id||r.action||""}`;if(F(o))return;let i={};r.id&&(i.form_id=r.id),r.action&&(i.form_action=r.action),r.method&&(i.form_method=r.method.toUpperCase()),n.defaultPrevented&&(i.prevented=true),e.trackInternal("form_submit",i);});};return document.addEventListener("submit",t,{capture:true}),()=>document.removeEventListener("submit",t,{capture:true})}function Y(e,t){return e.length<=t?e:e.slice(0,t-1)+"\u2026"}function B(e,t,n){let r=`${e}|${t??""}|${n??""}`,o=0;for(let i=0;i<r.length;i++)o=(o<<5)-o+r.charCodeAt(i)|0;return "err_"+(o>>>0).toString(36)}function ae(e,t){return !!(t&&(/^(chrome|moz|safari)-extension:\/\//.test(t)||t.startsWith("about:")||t.startsWith("chrome://"))||e==="Script error."&&!t)}function ue(e){let t=r=>{let o=r.message||"Unknown error",i=r.filename||null;if(ae(o,i))return;let c=r.lineno??null,S=r.error instanceof Error&&r.error.stack?Y(r.error.stack,1024):null;e.trackInternal("error",{message:o,filename:i,lineno:c,colno:r.colno??null,stack:S,error_type:"runtime",fingerprint:B(o,i,c)});},n=r=>{let o=r.reason instanceof Error,i;if(o)i=r.reason.message;else if(typeof r.reason=="string")i=r.reason;else try{i="Unhandled promise rejection: "+JSON.stringify(r.reason);}catch{i="Unhandled promise rejection";}let c=o&&r.reason.stack?Y(r.reason.stack,1024):null,S=o&&r.reason.stack?r.reason.stack.match(/at\s+.*?\(?(https?:\/\/\S+|\/\S+)/)?.[1]??null:null;e.trackInternal("error",{message:i,type:"unhandledrejection",stack:c,error_type:"promise",fingerprint:B(i,S,null)});};return window.addEventListener("error",t),window.addEventListener("unhandledrejection",n),()=>{window.removeEventListener("error",t),window.removeEventListener("unhandledrejection",n);}}var ce="https://api.infer.events",le=20,de=1e4,fe=3e4,ge=1e3,V=5,w=class{config;flushTimer=null;teardownAutoTrack=null;flushing=false;retryCount=0;disabled=false;constructor(t){if(!t.projectId||typeof t.projectId!="string")throw new Error("[infer] projectId is required");if(C(t.debug??false),this.config={projectId:t.projectId,endpoint:t.endpoint??ce,batchSize:t.batchSize??le,flushInterval:t.flushInterval??de},u("Initialized with config:",this.config),R(),this.flushTimer=setInterval(()=>{this.flush();},this.config.flushInterval),typeof window<"u"){let r=()=>{f(),this.sendBeacon();};window.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&r();}),window.addEventListener("pagehide",r);}let n=K(t.autoTrack??false);n&&(this.teardownAutoTrack=J(this,n));}track(t,n,r){this.enqueueEvent("track",t,n??{},r?.category);}identify(t,n){M(t,n),this.enqueueEvent("identify","identify",n??{});}page(t){let n={};t&&(n.name=t),typeof window<"u"&&(n.url=window.location.href,n.path=window.location.pathname,n.title=document.title),this.enqueueEvent("page","page_view",n);}screen(t){this.enqueueEvent("screen","screen_view",{name:t});}trackInternal(t,n){this.enqueueEvent("track",t,n);}async flush(){if(this.disabled||this.flushing||y()===0)return;this.flushing=true;let t=k(this.config.batchSize);u(`Flushing ${t.length} events`);try{let n=await fetch(`${this.config.endpoint}/v1/events`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.projectId}`},body:JSON.stringify({events:t})});n.ok?(this.retryCount=0,u(`Flushed ${t.length} events successfully`)):n.status>=500?(p(`Server error ${n.status}, will retry`),d(t),this.scheduleRetry()):I(`Client error ${n.status}, dropping batch`);}catch(n){if(this.retryCount>=V){I(`Cannot connect to ${this.config.endpoint} after ${V} attempts. If your site uses a Content Security Policy, add ${this.config.endpoint} to connect-src. Events will be dropped until the page is reloaded.`),this.disabled=true;return}p("Network error, will retry:",n),d(t),this.scheduleRetry();}finally{this.flushing=false;}y()>0&&this.flush();}destroy(){this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null),this.teardownAutoTrack&&(this.teardownAutoTrack(),this.teardownAutoTrack=null),f();}enqueueEvent(t,n,r,o){let i={event_id:crypto.randomUUID(),project_id:this.config.projectId,anonymous_id:O(),event_name:n,event_type:t,properties:r,context:j(),timestamp:new Date().toISOString()};o&&(i.category=o);let c=L();c&&(i.user_id=c),x(i),y()>=this.config.batchSize&&this.flush();}sendBeacon(){let t=k(this.config.batchSize);if(t.length!==0)try{fetch(`${this.config.endpoint}/v1/events`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.projectId}`},body:JSON.stringify({events:t}),keepalive:!0}).then(n=>{n.ok?u(`Beacon sent ${t.length} events`):(d(t),f());}).catch(()=>{d(t),f();});}catch{d(t),f();}}scheduleRetry(){this.retryCount++;let t=Math.min(ge*Math.pow(2,this.retryCount-1)+Math.random()*1e3,fe);u(`Retry #${this.retryCount} in ${Math.round(t)}ms`),setTimeout(()=>{this.flush();},t);}};var a=null,g=[];function xe(e){a&&a.destroy(),a=new w(e);for(let t of g)switch(t.type){case "track":a.track(...t.args);break;case "identify":a.identify(...t.args);break;case "page":a.page(...t.args);break;case "screen":a.screen(...t.args);break}return g=[],a}function Re(e,t,n){if(!a){g.push({type:"track",args:[e,t,n]});return}a.track(e,t,n);}function Ne(e,t){if(!a){g.push({type:"identify",args:[e,t]});return}a.identify(e,t);}function Ue(e){if(!a){g.push({type:"page",args:[e]});return}a.page(e);}function Oe(e){if(!a){g.push({type:"screen",args:[e]});return}a.screen(e);}async function Le(){a&&await a.flush();}function Me(){a&&(a.destroy(),a=null);}
2
+ exports.destroy=Me;exports.flush=Le;exports.identify=Ne;exports.init=xe;exports.page=Ue;exports.reset=H;exports.screen=Oe;exports.track=Re;
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var v=false;function T(e){v=e;}function a(e,...t){v&&console.log(`[infer] ${e}`,...t);}function p(e,...t){v&&console.warn(`[infer] ${e}`,...t);}function I(e,...t){v&&console.error(`[infer] ${e}`,...t);}var S="infer_event_queue",m=1e3,i=[];function C(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function A(e){i.length>=m&&(p("Queue full, dropping oldest event"),i.shift()),i.push(e),a(`Queued event: ${e.event_name} (${i.length} in queue)`);}function E(e){return i.splice(0,e)}function y(){return i.length}function d(e){i=[...e,...i],i.length>m&&(i=i.slice(i.length-m));}function f(){let e=C();if(!(!e||i.length===0))try{e.setItem(S,JSON.stringify(i)),a("Persisted queue to localStorage:",i.length);}catch{}}function x(){let e=C();if(e)try{let t=e.getItem(S);if(t){let n=JSON.parse(t);Array.isArray(n)&&(i=[...n,...i],i.length>m&&(i=i.slice(i.length-m)),a("Restored queue from localStorage:",n.length)),e.removeItem(S);}}catch{}}var k="infer_anonymous_id",c=null,_=null,b={};function N(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function U(){if(c)return c;let e=N();if(e){let t=e.getItem(k);if(t)return c=t,c}if(c=crypto.randomUUID(),a("Generated anonymous_id:",c),e)try{e.setItem(k,c);}catch{}return c}function L(){return _}function O(e,t){_=e,t&&(b={...b,...t}),a("Identity set:",_,b);}var R="infer_tab_id";function M(){try{if(typeof sessionStorage>"u")return null;let e=sessionStorage.getItem(R);return e||(e=crypto.randomUUID(),sessionStorage.setItem(R,e)),e}catch{return null}}function F(){_=null,b={},c=null;let e=N();if(e)try{e.removeItem(k);}catch{}}var J="0.1.0";function V(){return typeof window<"u"&&typeof document<"u"}function j(){let e={platform:"web",sdk_version:J};if(!V())return e;typeof navigator<"u"&&(e.browser=navigator.userAgent,e.locale=navigator.language),typeof screen<"u"&&(e.screen_width=screen.width,e.screen_height=screen.height);try{e.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone;}catch{}e.page_url=window.location.href,e.pathname=window.location.pathname,e.page_title=document.title,e.referrer=document.referrer||void 0,e.os=Z(navigator.userAgent),e.device_type=W(navigator.userAgent);let t=M();t&&(e.tab_id=t),e.landing_page=H();let n=G();return n.utm_source&&(e.utm_source=n.utm_source),n.utm_medium&&(e.utm_medium=n.utm_medium),n.utm_campaign&&(e.utm_campaign=n.utm_campaign),n.utm_term&&(e.utm_term=n.utm_term),n.utm_content&&(e.utm_content=n.utm_content),e}var P="infer_landing_page";function H(){try{let e=sessionStorage.getItem(P);if(e)return e;let t=window.location.pathname;return sessionStorage.setItem(P,t),t}catch{return window.location.pathname}}var X=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],D="infer_utm";function G(){try{let e=sessionStorage.getItem(D);if(e)return JSON.parse(e);let t=new URLSearchParams(window.location.search),n={};for(let r of X){let o=t.get(r);o&&(n[r]=o);}return Object.keys(n).length>0&&sessionStorage.setItem(D,JSON.stringify(n)),n}catch{return {}}}function Z(e){return /Windows/.test(e)?"Windows":/iPhone|iPad|iPod/.test(e)?"iOS":/Mac OS X/.test(e)?"macOS":/Android/.test(e)?"Android":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"ChromeOS":"Unknown"}function W(e){return /Mobi|Android.*Mobile|iPhone|iPod/.test(e)?"Mobile":/iPad|Android(?!.*Mobile)|Tablet/.test(e)?"Tablet":"Desktop"}var $="infer_session_last_active";var Q={pageView:true,session:true,click:true,formSubmit:true,error:true};function z(e){return e===false?null:e===true?{...Q}:{...Q,...e}}var h=new Map,q=500;function Y(e){let t=Date.now(),n=h.get(e);if(n&&t-n<q)return true;if(h.set(e,t),h.size>50)for(let[r,o]of h)t-o>q&&h.delete(r);return false}function B(e,t){if(typeof window>"u")return ()=>{};let n=[];return t.session&&ee(e),t.pageView&&n.push(te(e)),t.click&&n.push(ne(e)),t.formSubmit&&n.push(re(e)),t.error&&n.push(oe(e)),()=>{for(let r of n)r();}}function ee(e){try{let t=Date.now(),n=sessionStorage.getItem($);(!n||t-Number(n)>18e5)&&e.trackInternal("session_start",{}),sessionStorage.setItem($,String(t));}catch{}}function te(e){e.trackInternal("page_view",{url:window.location.href,path:window.location.pathname,title:document.title});let t=history.pushState.bind(history),n=history.replaceState.bind(history),r=()=>{e.trackInternal("page_view",{url:window.location.href,path:window.location.pathname,title:document.title});};return history.pushState=function(...o){t(...o),r();},history.replaceState=function(...o){n(...o),r();},window.addEventListener("popstate",r),()=>{history.pushState=t,history.replaceState=n,window.removeEventListener("popstate",r);}}function ne(e){let t=n=>{let r=n.target;if(!r)return;let o=r.closest("a, button, [role='button'], input[type='submit']");if(!o)return;let u=`click:${o.id||o.className||o.tagName}`;if(Y(u))return;let l={tag:o.tagName.toLowerCase()};o.id&&(l.element_id=o.id),o.className&&typeof o.className=="string"&&(l.element_class=o.className),o.tagName==="A"&&(l.href=o.href),e.trackInternal("click",l);};return document.addEventListener("click",t,{capture:true}),()=>document.removeEventListener("click",t,{capture:true})}function re(e){let t=n=>{let r=n.target;r&&queueMicrotask(()=>{let o=`form_submit:${r.id||r.action||""}`;if(Y(o))return;let u={};r.id&&(u.form_id=r.id),r.action&&(u.form_action=r.action),r.method&&(u.form_method=r.method.toUpperCase()),n.defaultPrevented&&(u.prevented=true),e.trackInternal("form_submit",u);});};return document.addEventListener("submit",t,{capture:true}),()=>document.removeEventListener("submit",t,{capture:true})}function oe(e){let t=r=>{e.trackInternal("error",{message:r.message||"Unknown error",filename:r.filename||null,lineno:r.lineno||null,colno:r.colno||null});},n=r=>{let o=r.reason instanceof Error?r.reason.message:typeof r.reason=="string"?r.reason:"Unhandled promise rejection";e.trackInternal("error",{message:o,type:"unhandledrejection"});};return window.addEventListener("error",t),window.addEventListener("unhandledrejection",n),()=>{window.removeEventListener("error",t),window.removeEventListener("unhandledrejection",n);}}var ie="https://api.infer.events",se=20,ae=1e4,ue=3e4,ce=1e3,K=5,w=class{config;flushTimer=null;teardownAutoTrack=null;flushing=false;retryCount=0;disabled=false;constructor(t){if(!t.projectId||typeof t.projectId!="string")throw new Error("[infer] projectId is required");if(T(t.debug??false),this.config={projectId:t.projectId,endpoint:t.endpoint??ie,batchSize:t.batchSize??se,flushInterval:t.flushInterval??ae},a("Initialized with config:",this.config),x(),this.flushTimer=setInterval(()=>{this.flush();},this.config.flushInterval),typeof window<"u"){let r=()=>{f(),this.sendBeacon();};window.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&r();}),window.addEventListener("pagehide",r);}let n=z(t.autoTrack??false);n&&(this.teardownAutoTrack=B(this,n));}track(t,n,r){this.enqueueEvent("track",t,n??{},r?.category);}identify(t,n){O(t,n),this.enqueueEvent("identify","identify",n??{});}page(t){let n={};t&&(n.name=t),typeof window<"u"&&(n.url=window.location.href,n.path=window.location.pathname,n.title=document.title),this.enqueueEvent("page","page_view",n);}screen(t){this.enqueueEvent("screen","screen_view",{name:t});}trackInternal(t,n){this.enqueueEvent("track",t,n);}async flush(){if(this.disabled||this.flushing||y()===0)return;this.flushing=true;let t=E(this.config.batchSize);a(`Flushing ${t.length} events`);try{let n=await fetch(`${this.config.endpoint}/v1/events`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.projectId}`},body:JSON.stringify({events:t})});n.ok?(this.retryCount=0,a(`Flushed ${t.length} events successfully`)):n.status>=500?(p(`Server error ${n.status}, will retry`),d(t),this.scheduleRetry()):I(`Client error ${n.status}, dropping batch`);}catch(n){if(this.retryCount>=K){I(`Cannot connect to ${this.config.endpoint} after ${K} attempts. If your site uses a Content Security Policy, add ${this.config.endpoint} to connect-src. Events will be dropped until the page is reloaded.`),this.disabled=true;return}p("Network error, will retry:",n),d(t),this.scheduleRetry();}finally{this.flushing=false;}y()>0&&this.flush();}destroy(){this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null),this.teardownAutoTrack&&(this.teardownAutoTrack(),this.teardownAutoTrack=null),f();}enqueueEvent(t,n,r,o){let u={event_id:crypto.randomUUID(),project_id:this.config.projectId,anonymous_id:U(),event_name:n,event_type:t,properties:r,context:j(),timestamp:new Date().toISOString()};o&&(u.category=o);let l=L();l&&(u.user_id=l),A(u),y()>=this.config.batchSize&&this.flush();}sendBeacon(){let t=E(this.config.batchSize);if(t.length!==0)try{fetch(`${this.config.endpoint}/v1/events`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.projectId}`},body:JSON.stringify({events:t}),keepalive:!0}).then(n=>{n.ok?a(`Beacon sent ${t.length} events`):(d(t),f());}).catch(()=>{d(t),f();});}catch{d(t),f();}}scheduleRetry(){this.retryCount++;let t=Math.min(ce*Math.pow(2,this.retryCount-1)+Math.random()*1e3,ue);a(`Retry #${this.retryCount} in ${Math.round(t)}ms`),setTimeout(()=>{this.flush();},t);}};var s=null,g=[];function ke(e){s&&s.destroy(),s=new w(e);for(let t of g)switch(t.type){case "track":s.track(...t.args);break;case "identify":s.identify(...t.args);break;case "page":s.page(...t.args);break;case "screen":s.screen(...t.args);break}return g=[],s}function Te(e,t,n){if(!s){g.push({type:"track",args:[e,t,n]});return}s.track(e,t,n);}function Ce(e,t){if(!s){g.push({type:"identify",args:[e,t]});return}s.identify(e,t);}function Ae(e){if(!s){g.push({type:"page",args:[e]});return}s.page(e);}function xe(e){if(!s){g.push({type:"screen",args:[e]});return}s.screen(e);}async function Re(){s&&await s.flush();}function Ne(){s&&(s.destroy(),s=null);}
2
- export{Ne as destroy,Re as flush,Ce as identify,ke as init,Ae as page,F as reset,xe as screen,Te as track};
1
+ var v=false;function C(e){v=e;}function u(e,...t){v&&console.log(`[infer] ${e}`,...t);}function p(e,...t){v&&console.warn(`[infer] ${e}`,...t);}function I(e,...t){v&&console.error(`[infer] ${e}`,...t);}var E="infer_event_queue",m=1e3,s=[];function A(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function x(e){s.length>=m&&(p("Queue full, dropping oldest event"),s.shift()),s.push(e),u(`Queued event: ${e.event_name} (${s.length} in queue)`);}function k(e){return s.splice(0,e)}function y(){return s.length}function d(e){s=[...e,...s],s.length>m&&(s=s.slice(s.length-m));}function f(){let e=A();if(!(!e||s.length===0))try{e.setItem(E,JSON.stringify(s)),u("Persisted queue to localStorage:",s.length);}catch{}}function R(){let e=A();if(e)try{let t=e.getItem(E);if(t){let n=JSON.parse(t);Array.isArray(n)&&(s=[...n,...s],s.length>m&&(s=s.slice(s.length-m)),u("Restored queue from localStorage:",n.length)),e.removeItem(E);}}catch{}}var T="infer_anonymous_id",l=null,_=null,b={};function U(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function O(){if(l)return l;let e=U();if(e){let t=e.getItem(T);if(t)return l=t,l}if(l=crypto.randomUUID(),u("Generated anonymous_id:",l),e)try{e.setItem(T,l);}catch{}return l}function L(){return _}function M(e,t){_=e,t&&(b={...b,...t}),u("Identity set:",_,b);}var N="infer_tab_id";function P(){try{if(typeof sessionStorage>"u")return null;let e=sessionStorage.getItem(N);return e||(e=crypto.randomUUID(),sessionStorage.setItem(N,e)),e}catch{return null}}function H(){_=null,b={},l=null;let e=U();if(e)try{e.removeItem(T);}catch{}}var W="0.1.0";function X(){return typeof window<"u"&&typeof document<"u"}function j(){let e={platform:"web",sdk_version:W};if(!X())return e;typeof navigator<"u"&&(e.browser=navigator.userAgent,e.locale=navigator.language),typeof screen<"u"&&(e.screen_width=screen.width,e.screen_height=screen.height);try{e.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone;}catch{}e.page_url=window.location.href,e.pathname=window.location.pathname,e.page_title=document.title,e.referrer=document.referrer||void 0,e.os=te(navigator.userAgent),e.device_type=ne(navigator.userAgent);let t=P();t&&(e.tab_id=t),e.landing_page=G();let n=ee();return n.utm_source&&(e.utm_source=n.utm_source),n.utm_medium&&(e.utm_medium=n.utm_medium),n.utm_campaign&&(e.utm_campaign=n.utm_campaign),n.utm_term&&(e.utm_term=n.utm_term),n.utm_content&&(e.utm_content=n.utm_content),e}var D="infer_landing_page";function G(){try{let e=sessionStorage.getItem(D);if(e)return e;let t=window.location.pathname;return sessionStorage.setItem(D,t),t}catch{return window.location.pathname}}var Z=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],$="infer_utm";function ee(){try{let e=sessionStorage.getItem($);if(e)return JSON.parse(e);let t=new URLSearchParams(window.location.search),n={};for(let r of Z){let o=t.get(r);o&&(n[r]=o);}return Object.keys(n).length>0&&sessionStorage.setItem($,JSON.stringify(n)),n}catch{return {}}}function te(e){return /Windows/.test(e)?"Windows":/iPhone|iPad|iPod/.test(e)?"iOS":/Mac OS X/.test(e)?"macOS":/Android/.test(e)?"Android":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"ChromeOS":"Unknown"}function ne(e){return /Mobi|Android.*Mobile|iPhone|iPod/.test(e)?"Mobile":/iPad|Android(?!.*Mobile)|Tablet/.test(e)?"Tablet":"Desktop"}var Q="infer_session_last_active";var q={pageView:true,session:true,click:true,formSubmit:true,error:true};function K(e){return e===false?null:e===true?{...q}:{...q,...e}}var h=new Map,z=500;function F(e){let t=Date.now(),n=h.get(e);if(n&&t-n<z)return true;if(h.set(e,t),h.size>50)for(let[r,o]of h)t-o>z&&h.delete(r);return false}function J(e,t){if(typeof window>"u")return ()=>{};let n=[];return t.session&&re(e),t.pageView&&n.push(oe(e)),t.click&&n.push(ie(e)),t.formSubmit&&n.push(se(e)),t.error&&n.push(ue(e)),()=>{for(let r of n)r();}}function re(e){try{let t=Date.now(),n=sessionStorage.getItem(Q);(!n||t-Number(n)>18e5)&&e.trackInternal("session_start",{}),sessionStorage.setItem(Q,String(t));}catch{}}function oe(e){e.trackInternal("page_view",{url:window.location.href,path:window.location.pathname,title:document.title});let t=history.pushState.bind(history),n=history.replaceState.bind(history),r=()=>{e.trackInternal("page_view",{url:window.location.href,path:window.location.pathname,title:document.title});};return history.pushState=function(...o){t(...o),r();},history.replaceState=function(...o){n(...o),r();},window.addEventListener("popstate",r),()=>{history.pushState=t,history.replaceState=n,window.removeEventListener("popstate",r);}}function ie(e){let t=n=>{let r=n.target;if(!r)return;let o=r.closest("a, button, [role='button'], input[type='submit']");if(!o)return;let i=`click:${o.id||o.className||o.tagName}`;if(F(i))return;let c={tag:o.tagName.toLowerCase()};o.id&&(c.element_id=o.id),o.className&&typeof o.className=="string"&&(c.element_class=o.className),o.tagName==="A"&&(c.href=o.href),e.trackInternal("click",c);};return document.addEventListener("click",t,{capture:true}),()=>document.removeEventListener("click",t,{capture:true})}function se(e){let t=n=>{let r=n.target;r&&queueMicrotask(()=>{let o=`form_submit:${r.id||r.action||""}`;if(F(o))return;let i={};r.id&&(i.form_id=r.id),r.action&&(i.form_action=r.action),r.method&&(i.form_method=r.method.toUpperCase()),n.defaultPrevented&&(i.prevented=true),e.trackInternal("form_submit",i);});};return document.addEventListener("submit",t,{capture:true}),()=>document.removeEventListener("submit",t,{capture:true})}function Y(e,t){return e.length<=t?e:e.slice(0,t-1)+"\u2026"}function B(e,t,n){let r=`${e}|${t??""}|${n??""}`,o=0;for(let i=0;i<r.length;i++)o=(o<<5)-o+r.charCodeAt(i)|0;return "err_"+(o>>>0).toString(36)}function ae(e,t){return !!(t&&(/^(chrome|moz|safari)-extension:\/\//.test(t)||t.startsWith("about:")||t.startsWith("chrome://"))||e==="Script error."&&!t)}function ue(e){let t=r=>{let o=r.message||"Unknown error",i=r.filename||null;if(ae(o,i))return;let c=r.lineno??null,S=r.error instanceof Error&&r.error.stack?Y(r.error.stack,1024):null;e.trackInternal("error",{message:o,filename:i,lineno:c,colno:r.colno??null,stack:S,error_type:"runtime",fingerprint:B(o,i,c)});},n=r=>{let o=r.reason instanceof Error,i;if(o)i=r.reason.message;else if(typeof r.reason=="string")i=r.reason;else try{i="Unhandled promise rejection: "+JSON.stringify(r.reason);}catch{i="Unhandled promise rejection";}let c=o&&r.reason.stack?Y(r.reason.stack,1024):null,S=o&&r.reason.stack?r.reason.stack.match(/at\s+.*?\(?(https?:\/\/\S+|\/\S+)/)?.[1]??null:null;e.trackInternal("error",{message:i,type:"unhandledrejection",stack:c,error_type:"promise",fingerprint:B(i,S,null)});};return window.addEventListener("error",t),window.addEventListener("unhandledrejection",n),()=>{window.removeEventListener("error",t),window.removeEventListener("unhandledrejection",n);}}var ce="https://api.infer.events",le=20,de=1e4,fe=3e4,ge=1e3,V=5,w=class{config;flushTimer=null;teardownAutoTrack=null;flushing=false;retryCount=0;disabled=false;constructor(t){if(!t.projectId||typeof t.projectId!="string")throw new Error("[infer] projectId is required");if(C(t.debug??false),this.config={projectId:t.projectId,endpoint:t.endpoint??ce,batchSize:t.batchSize??le,flushInterval:t.flushInterval??de},u("Initialized with config:",this.config),R(),this.flushTimer=setInterval(()=>{this.flush();},this.config.flushInterval),typeof window<"u"){let r=()=>{f(),this.sendBeacon();};window.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&r();}),window.addEventListener("pagehide",r);}let n=K(t.autoTrack??false);n&&(this.teardownAutoTrack=J(this,n));}track(t,n,r){this.enqueueEvent("track",t,n??{},r?.category);}identify(t,n){M(t,n),this.enqueueEvent("identify","identify",n??{});}page(t){let n={};t&&(n.name=t),typeof window<"u"&&(n.url=window.location.href,n.path=window.location.pathname,n.title=document.title),this.enqueueEvent("page","page_view",n);}screen(t){this.enqueueEvent("screen","screen_view",{name:t});}trackInternal(t,n){this.enqueueEvent("track",t,n);}async flush(){if(this.disabled||this.flushing||y()===0)return;this.flushing=true;let t=k(this.config.batchSize);u(`Flushing ${t.length} events`);try{let n=await fetch(`${this.config.endpoint}/v1/events`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.projectId}`},body:JSON.stringify({events:t})});n.ok?(this.retryCount=0,u(`Flushed ${t.length} events successfully`)):n.status>=500?(p(`Server error ${n.status}, will retry`),d(t),this.scheduleRetry()):I(`Client error ${n.status}, dropping batch`);}catch(n){if(this.retryCount>=V){I(`Cannot connect to ${this.config.endpoint} after ${V} attempts. If your site uses a Content Security Policy, add ${this.config.endpoint} to connect-src. Events will be dropped until the page is reloaded.`),this.disabled=true;return}p("Network error, will retry:",n),d(t),this.scheduleRetry();}finally{this.flushing=false;}y()>0&&this.flush();}destroy(){this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null),this.teardownAutoTrack&&(this.teardownAutoTrack(),this.teardownAutoTrack=null),f();}enqueueEvent(t,n,r,o){let i={event_id:crypto.randomUUID(),project_id:this.config.projectId,anonymous_id:O(),event_name:n,event_type:t,properties:r,context:j(),timestamp:new Date().toISOString()};o&&(i.category=o);let c=L();c&&(i.user_id=c),x(i),y()>=this.config.batchSize&&this.flush();}sendBeacon(){let t=k(this.config.batchSize);if(t.length!==0)try{fetch(`${this.config.endpoint}/v1/events`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.projectId}`},body:JSON.stringify({events:t}),keepalive:!0}).then(n=>{n.ok?u(`Beacon sent ${t.length} events`):(d(t),f());}).catch(()=>{d(t),f();});}catch{d(t),f();}}scheduleRetry(){this.retryCount++;let t=Math.min(ge*Math.pow(2,this.retryCount-1)+Math.random()*1e3,fe);u(`Retry #${this.retryCount} in ${Math.round(t)}ms`),setTimeout(()=>{this.flush();},t);}};var a=null,g=[];function xe(e){a&&a.destroy(),a=new w(e);for(let t of g)switch(t.type){case "track":a.track(...t.args);break;case "identify":a.identify(...t.args);break;case "page":a.page(...t.args);break;case "screen":a.screen(...t.args);break}return g=[],a}function Re(e,t,n){if(!a){g.push({type:"track",args:[e,t,n]});return}a.track(e,t,n);}function Ne(e,t){if(!a){g.push({type:"identify",args:[e,t]});return}a.identify(e,t);}function Ue(e){if(!a){g.push({type:"page",args:[e]});return}a.page(e);}function Oe(e){if(!a){g.push({type:"screen",args:[e]});return}a.screen(e);}async function Le(){a&&await a.flush();}function Me(){a&&(a.destroy(),a=null);}
2
+ export{Me as destroy,Le as flush,Ne as identify,xe as init,Ue as page,H as reset,Oe as screen,Re as track};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inferevents/sdk",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "Event collection SDK for Infer — analytics designed for AI agents, not dashboards",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",