@bigchill101/iris 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -12,7 +12,9 @@ declare class Iris {
12
12
  start(): void;
13
13
  track(name: string, props?: object): void;
14
14
  private trackPageview;
15
+ private handlePopState;
15
16
  private enableHistoryPatch;
17
+ stop(): void;
16
18
  }
17
19
 
18
20
  export { Iris };
package/dist/index.d.ts CHANGED
@@ -12,7 +12,9 @@ declare class Iris {
12
12
  start(): void;
13
13
  track(name: string, props?: object): void;
14
14
  private trackPageview;
15
+ private handlePopState;
15
16
  private enableHistoryPatch;
17
+ stop(): void;
16
18
  }
17
19
 
18
20
  export { Iris };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var c=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var S=(e,t)=>{for(var i in t)c(e,i,{get:t[i],enumerable:!0})},P=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of I(t))!w.call(e,r)&&r!==i&&c(e,r,{get:()=>t[r],enumerable:!(n=b(t,r))||n.enumerable});return e};var k=e=>P(c({},"__esModule",{value:!0}),e);var E={};S(E,{Iris:()=>d});module.exports=k(E);var s=class{constructor(t){this.config=t}send(t){let i=`${this.config.host}/api/event`,n=JSON.stringify(t);if(navigator.sendBeacon){let r=new Blob([n],{type:"application/json"});navigator.sendBeacon(i,r)}else fetch(i,{method:"POST",body:n,keepalive:!0,headers:{"Content-Type":"application/json"}}).catch(r=>{this.config.debug&&console.error("Iris: Failed to send",r)});this.config.debug&&console.log("Iris: Event Sent",t)}};function f(e){window.addEventListener("click",t=>{var g;let n=t.target.closest('button, a, input[type="submit"], [role="button"]');if(!n||n.classList.contains("iris-ignore")||n instanceof HTMLInputElement&&n.type==="password")return;let r=n.tagName.toLowerCase(),y="$click",p={$tag:r,$id:n.id||void 0,$class:n.className||void 0,$text:((g=n.innerText)==null?void 0:g.slice(0,50))||""};if(r==="a"){let l=n.getAttribute("href");l&&(p.$href=l)}e(y,p)},{capture:!0})}var o=require("web-vitals");function u(e){let t=i=>{e("$web_vital",{$id:i.id,$name:i.name,$val:i.value,$rating:i.rating})};(0,o.onCLS)(t),(0,o.onINP)(t),(0,o.onLCP)(t)}var h="iris_vid",x="iris_sid";function a(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function m(){try{let e=localStorage.getItem(h);return e||(e=a(),localStorage.setItem(h,e)),e}catch{return a()}}function v(){try{let e=sessionStorage.getItem(x);return e||(e=a(),sessionStorage.setItem(x,e)),e}catch{return a()}}var d=class{transport;config;constructor(t){this.config={autocapture:!0,debug:!1,...t},this.transport=new s(this.config)}start(){this.trackPageview(),this.enableHistoryPatch(),this.config.autocapture&&f(this.track.bind(this)),u(this.track.bind(this))}track(t,i){let n={n:t,u:window.location.href,d:window.location.hostname,r:document.referrer||null,w:window.innerWidth,s:this.config.siteId,sid:v(),vid:m(),p:i};this.transport.send(n)}trackPageview(){this.track("$pageview")}enableHistoryPatch(){let t=history.pushState;history.pushState=(...i)=>{t.apply(history,i),this.trackPageview()},window.addEventListener("popstate",()=>{this.trackPageview()})}};0&&(module.exports={Iris});
1
+ var c=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var S=(e,t)=>{for(var i in t)c(e,i,{get:t[i],enumerable:!0})},P=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of w(t))!I.call(e,o)&&o!==i&&c(e,o,{get:()=>t[o],enumerable:!(n=b(t,o))||n.enumerable});return e};var E=e=>P(c({},"__esModule",{value:!0}),e);var k={};S(k,{Iris:()=>p});module.exports=E(k);var s=class{constructor(t){this.config=t}send(t){let i=`${this.config.host}/api/event`,n=JSON.stringify(t);if(navigator.sendBeacon){let o=new Blob([n],{type:"application/json"});navigator.sendBeacon(i,o)}else fetch(i,{method:"POST",body:n,keepalive:!0,headers:{"Content-Type":"application/json"}}).catch(o=>{this.config.debug&&console.error("Iris: Failed to send",o)});this.config.debug&&console.log("Iris: Event Sent",t)}};function u(e){window.addEventListener("click",t=>{var l;let n=t.target.closest('button, a, input[type="submit"], [role="button"]');if(!n||n.classList.contains("iris-ignore")||n instanceof HTMLInputElement&&n.type==="password")return;let o=n.tagName.toLowerCase(),y="$click",d={$tag:o,$id:n.id||void 0,$class:n.className||void 0,$text:((l=n.innerText)==null?void 0:l.slice(0,50))||""};if(o==="a"){let g=n.getAttribute("href");g&&(d.$href=g)}e(y,d)},{capture:!0})}var r=require("web-vitals");function f(e){let t=i=>{e("$web_vital",{$id:i.id,$name:i.name,$val:i.value,$rating:i.rating})};(0,r.onCLS)(t),(0,r.onINP)(t),(0,r.onLCP)(t)}var h="iris_vid",x="iris_sid";function a(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function m(){try{let e=localStorage.getItem(h);return e||(e=a(),localStorage.setItem(h,e)),e}catch{return a()}}function v(){try{let e=sessionStorage.getItem(x);return e||(e=a(),sessionStorage.setItem(x,e)),e}catch{return a()}}var p=class{transport;config;constructor(t){this.config={autocapture:!0,debug:!1,...t},this.transport=new s(this.config)}start(){this.trackPageview(),this.enableHistoryPatch(),this.config.autocapture&&u(this.track.bind(this)),f(this.track.bind(this))}track(t,i){let n={n:t,u:window.location.href,d:window.location.hostname,r:document.referrer||null,w:window.innerWidth,s:this.config.siteId,sid:v(),vid:m(),p:i};this.transport.send(n)}trackPageview(){this.track("$pageview")}handlePopState=()=>{this.trackPageview()};enableHistoryPatch(){let t=history.pushState;history.pushState=(...i)=>{t.apply(history,i),this.trackPageview()},window.addEventListener("popstate",this.handlePopState)}stop(){window.removeEventListener("popstate",this.handlePopState)}};0&&(module.exports={Iris});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var o=class{constructor(t){this.config=t}send(t){let n=`${this.config.host}/api/event`,i=JSON.stringify(t);if(navigator.sendBeacon){let r=new Blob([i],{type:"application/json"});navigator.sendBeacon(n,r)}else fetch(n,{method:"POST",body:i,keepalive:!0,headers:{"Content-Type":"application/json"}}).catch(r=>{this.config.debug&&console.error("Iris: Failed to send",r)});this.config.debug&&console.log("Iris: Event Sent",t)}};function p(e){window.addEventListener("click",t=>{var c;let i=t.target.closest('button, a, input[type="submit"], [role="button"]');if(!i||i.classList.contains("iris-ignore")||i instanceof HTMLInputElement&&i.type==="password")return;let r=i.tagName.toLowerCase(),m="$click",a={$tag:r,$id:i.id||void 0,$class:i.className||void 0,$text:((c=i.innerText)==null?void 0:c.slice(0,50))||""};if(r==="a"){let d=i.getAttribute("href");d&&(a.$href=d)}e(m,a)},{capture:!0})}import{onCLS as v,onINP as y,onLCP as b}from"web-vitals";function g(e){let t=n=>{e("$web_vital",{$id:n.id,$name:n.name,$val:n.value,$rating:n.rating})};v(t),y(t),b(t)}var l="iris_vid",f="iris_sid";function s(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function u(){try{let e=localStorage.getItem(l);return e||(e=s(),localStorage.setItem(l,e)),e}catch{return s()}}function h(){try{let e=sessionStorage.getItem(f);return e||(e=s(),sessionStorage.setItem(f,e)),e}catch{return s()}}var x=class{transport;config;constructor(t){this.config={autocapture:!0,debug:!1,...t},this.transport=new o(this.config)}start(){this.trackPageview(),this.enableHistoryPatch(),this.config.autocapture&&p(this.track.bind(this)),g(this.track.bind(this))}track(t,n){let i={n:t,u:window.location.href,d:window.location.hostname,r:document.referrer||null,w:window.innerWidth,s:this.config.siteId,sid:h(),vid:u(),p:n};this.transport.send(i)}trackPageview(){this.track("$pageview")}enableHistoryPatch(){let t=history.pushState;history.pushState=(...n)=>{t.apply(history,n),this.trackPageview()},window.addEventListener("popstate",()=>{this.trackPageview()})}};export{x as Iris};
1
+ var r=class{constructor(t){this.config=t}send(t){let n=`${this.config.host}/api/event`,i=JSON.stringify(t);if(navigator.sendBeacon){let o=new Blob([i],{type:"application/json"});navigator.sendBeacon(n,o)}else fetch(n,{method:"POST",body:i,keepalive:!0,headers:{"Content-Type":"application/json"}}).catch(o=>{this.config.debug&&console.error("Iris: Failed to send",o)});this.config.debug&&console.log("Iris: Event Sent",t)}};function d(e){window.addEventListener("click",t=>{var c;let i=t.target.closest('button, a, input[type="submit"], [role="button"]');if(!i||i.classList.contains("iris-ignore")||i instanceof HTMLInputElement&&i.type==="password")return;let o=i.tagName.toLowerCase(),m="$click",a={$tag:o,$id:i.id||void 0,$class:i.className||void 0,$text:((c=i.innerText)==null?void 0:c.slice(0,50))||""};if(o==="a"){let p=i.getAttribute("href");p&&(a.$href=p)}e(m,a)},{capture:!0})}import{onCLS as v,onINP as y,onLCP as b}from"web-vitals";function l(e){let t=n=>{e("$web_vital",{$id:n.id,$name:n.name,$val:n.value,$rating:n.rating})};v(t),y(t),b(t)}var g="iris_vid",u="iris_sid";function s(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function f(){try{let e=localStorage.getItem(g);return e||(e=s(),localStorage.setItem(g,e)),e}catch{return s()}}function h(){try{let e=sessionStorage.getItem(u);return e||(e=s(),sessionStorage.setItem(u,e)),e}catch{return s()}}var x=class{transport;config;constructor(t){this.config={autocapture:!0,debug:!1,...t},this.transport=new r(this.config)}start(){this.trackPageview(),this.enableHistoryPatch(),this.config.autocapture&&d(this.track.bind(this)),l(this.track.bind(this))}track(t,n){let i={n:t,u:window.location.href,d:window.location.hostname,r:document.referrer||null,w:window.innerWidth,s:this.config.siteId,sid:h(),vid:f(),p:n};this.transport.send(i)}trackPageview(){this.track("$pageview")}handlePopState=()=>{this.trackPageview()};enableHistoryPatch(){let t=history.pushState;history.pushState=(...n)=>{t.apply(history,n),this.trackPageview()},window.addEventListener("popstate",this.handlePopState)}stop(){window.removeEventListener("popstate",this.handlePopState)}};export{x as Iris};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigchill101/iris",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Privacy-first, self-hosted analytics client",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",