@bigchill101/iris 0.0.6 → 0.0.7

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.js CHANGED
@@ -1 +1 @@
1
- var c=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var I=(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 w(t))!b.call(e,r)&&r!==i&&c(e,r,{get:()=>t[r],enumerable:!(n=S(t,r))||n.enumerable});return e};var C=e=>P(c({},"__esModule",{value:!0}),e);var k={};I(k,{Iris:()=>p});module.exports=C(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 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 d;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",l={$tag:r,$id:n.id||void 0,$class:n.className||void 0,$text:((d=n.innerText)==null?void 0:d.slice(0,50))||""};if(r==="a"){let u=n.getAttribute("href");u&&(l.$href=u)}e(y,l)},{capture:!0})}var o=require("web-vitals");function g(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 v(){try{let e=localStorage.getItem(h);return e||(e=a(),localStorage.setItem(h,e)),e}catch{return a()}}function m(){try{let e=sessionStorage.getItem(x);return e||(e=a(),sessionStorage.setItem(x,e)),e}catch{return a()}}var p=class{transport;config;isStarted=!1;originalPushState=null;constructor(t){this.config={autocapture:!1,debug:!1,...t},this.transport=new s(this.config)}start(){if(this.isStarted)return;this.isStarted=!0;let t=this.config.autocapture;t&&t.pageviews!==!1&&(this.trackPageview(),this.enableHistoryPatch()),t&&t.clicks!==!1&&f(this.track.bind(this)),t&&t.webvitals!==!1&&g(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:m(),vid:v(),p:i};this.transport.send(n)}trackPageview(){this.track("$pageview")}handlePopState=()=>{this.trackPageview()};enableHistoryPatch(){this.originalPushState=history.pushState;let t=this;history.pushState=function(...i){t.originalPushState.apply(history,i),t.trackPageview()},window.addEventListener("popstate",this.handlePopState)}stop(){this.isStarted&&(this.isStarted=!1,this.originalPushState&&(history.pushState=this.originalPushState,this.originalPushState=null),window.removeEventListener("popstate",this.handlePopState))}};0&&(module.exports={Iris});
1
+ var c=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var P=(e,t)=>{for(var i in t)c(e,i,{get:t[i],enumerable:!0})},C=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of b(t))!I.call(e,r)&&r!==i&&c(e,r,{get:()=>t[r],enumerable:!(n=w(t,r))||n.enumerable});return e};var k=e=>C(c({},"__esModule",{value:!0}),e);var E={};P(E,{Iris:()=>l});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 g(e){window.addEventListener("click",t=>{var d;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(),S="$click",u={$tag:r,$id:n.id||void 0,$class:n.className||void 0,$text:((d=n.innerText)==null?void 0:d.slice(0,50))||""};if(r==="a"){let f=n.getAttribute("href");f&&(u.$href=f)}e(S,u)},{capture:!0})}var o=require("web-vitals");function h(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 x="iris_vid",v="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(x);return e||(e=a(),localStorage.setItem(x,e)),e}catch{return a()}}function y(){try{let e=sessionStorage.getItem(v);return e||(e=a(),sessionStorage.setItem(v,e)),e}catch{return a()}}var p=!1,l=class{transport;config;isStarted=!1;originalPushState=null;constructor(t){this.config={autocapture:!1,debug:!1,...t},this.transport=new s(this.config)}start(){if(this.isStarted)return;this.isStarted=!0;let t=this.config.autocapture;t&&t.pageviews===!0&&(this.trackPageview(),this.enableHistoryPatch()),t&&t.clicks===!0&&g(this.track.bind(this)),t&&t.webvitals===!0&&h(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:y(),vid:m(),p:i};this.transport.send(n)}trackPageview(){this.track("$pageview")}handlePopState=()=>{this.trackPageview()};enableHistoryPatch(){if(p)return;p=!0,this.originalPushState=history.pushState;let t=this;history.pushState=function(...i){t.originalPushState.apply(history,i),t.trackPageview()},window.addEventListener("popstate",this.handlePopState)}stop(){this.isStarted&&(this.isStarted=!1,this.originalPushState&&(history.pushState=this.originalPushState,this.originalPushState=null,p=!1),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 l(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(),v="$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 p=i.getAttribute("href");p&&(a.$href=p)}e(v,a)},{capture:!0})}import{onCLS as m,onINP as y,onLCP as S}from"web-vitals";function d(e){let t=n=>{e("$web_vital",{$id:n.id,$name:n.name,$val:n.value,$rating:n.rating})};m(t),y(t),S(t)}var u="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 g(){try{let e=localStorage.getItem(u);return e||(e=s(),localStorage.setItem(u,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;isStarted=!1;originalPushState=null;constructor(t){this.config={autocapture:!1,debug:!1,...t},this.transport=new o(this.config)}start(){if(this.isStarted)return;this.isStarted=!0;let t=this.config.autocapture;t&&t.pageviews!==!1&&(this.trackPageview(),this.enableHistoryPatch()),t&&t.clicks!==!1&&l(this.track.bind(this)),t&&t.webvitals!==!1&&d(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:g(),p:n};this.transport.send(i)}trackPageview(){this.track("$pageview")}handlePopState=()=>{this.trackPageview()};enableHistoryPatch(){this.originalPushState=history.pushState;let t=this;history.pushState=function(...n){t.originalPushState.apply(history,n),t.trackPageview()},window.addEventListener("popstate",this.handlePopState)}stop(){this.isStarted&&(this.isStarted=!1,this.originalPushState&&(history.pushState=this.originalPushState,this.originalPushState=null),window.removeEventListener("popstate",this.handlePopState))}};export{x as Iris};
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 u(e){window.addEventListener("click",t=>{var p;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",c={$tag:r,$id:i.id||void 0,$class:i.className||void 0,$text:((p=i.innerText)==null?void 0:p.slice(0,50))||""};if(r==="a"){let l=i.getAttribute("href");l&&(c.$href=l)}e(m,c)},{capture:!0})}import{onCLS as y,onINP as S,onLCP as w}from"web-vitals";function d(e){let t=n=>{e("$web_vital",{$id:n.id,$name:n.name,$val:n.value,$rating:n.rating})};y(t),S(t),w(t)}var f="iris_vid",g="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 h(){try{let e=localStorage.getItem(f);return e||(e=s(),localStorage.setItem(f,e)),e}catch{return s()}}function x(){try{let e=sessionStorage.getItem(g);return e||(e=s(),sessionStorage.setItem(g,e)),e}catch{return s()}}var a=!1,v=class{transport;config;isStarted=!1;originalPushState=null;constructor(t){this.config={autocapture:!1,debug:!1,...t},this.transport=new o(this.config)}start(){if(this.isStarted)return;this.isStarted=!0;let t=this.config.autocapture;t&&t.pageviews===!0&&(this.trackPageview(),this.enableHistoryPatch()),t&&t.clicks===!0&&u(this.track.bind(this)),t&&t.webvitals===!0&&d(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:x(),vid:h(),p:n};this.transport.send(i)}trackPageview(){this.track("$pageview")}handlePopState=()=>{this.trackPageview()};enableHistoryPatch(){if(a)return;a=!0,this.originalPushState=history.pushState;let t=this;history.pushState=function(...n){t.originalPushState.apply(history,n),t.trackPageview()},window.addEventListener("popstate",this.handlePopState)}stop(){this.isStarted&&(this.isStarted=!1,this.originalPushState&&(history.pushState=this.originalPushState,this.originalPushState=null,a=!1),window.removeEventListener("popstate",this.handlePopState))}};export{v as Iris};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigchill101/iris",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Privacy-first, self-hosted analytics client",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",