analytica.click 0.0.645 → 0.0.646
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var g=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var E=(e,r)=>{for(var n in r)g(e,n,{get:r[n],enumerable:!0})},I=(e,r,n,c)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of x(r))!y.call(e,s)&&s!==n&&g(e,s,{get:()=>r[s],enumerable:!(c=h(r,s))||c.enumerable});return e};var K=e=>I(g({},"__esModule",{value:!0}),e);var $={};E($,{getErrorKey:()=>J});module.exports=K($);var m=require("ag-common/dist/common/helpers/hashCode"),f=require("ag-common/dist/common/helpers/log"),u=require("ag-common/dist/common/helpers/object"),J=e=>{try{let r=/^\[?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}\]?$/gim,n=/(at \S+?) \(\S+\)\s/gim,c=/^((%[cs])+\s*)+$/gim,s=/^color:/gim,o;(0,u.isJson)(e.message)?o=JSON.parse(e.message):o=[e.message];let a=o.findIndex(t=>t.match(c)),i=o.findIndex(t=>t.match(s));a>=0&&i>=0&&i===a+1&&(o=o.filter((t,S)=>![a,i].includes(S)));let p=o.map(t=>t.includes(".js:")||t.includes("node_modules")?t.replace(n,"$1 (stacktrace)"):t.replace(r,"[date]")),l=JSON.stringify(p),d=(0,m.hashCode)(l).toString();return(0,f.debug)("got errorKey=",l,d),d}catch{return(0,m.hashCode)(e.message).toString()}};0&&(module.exports={getErrorKey});
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
'use client';
|
|
2
1
|
"use strict";var l=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var N=(r,e)=>{for(var t in e)l(r,t,{get:e[t],enumerable:!0})},K=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of J(e))!x.call(r,o)&&o!==t&&l(r,o,{get:()=>e[o],enumerable:!(n=j(e,o))||n.enumerable});return r};var R=r=>K(l({},"__esModule",{value:!0}),r);var v={};N(v,{errorTrack:()=>I,mergeErrorPayload:()=>b});module.exports=R(v);var _=require("cross-fetch/polyfill"),c=require("ag-common/dist/common/helpers/log"),E=require("ag-common/dist/common/helpers/string/contains");var d=require("ag-common/dist/common/helpers/hashCode"),h=require("ag-common/dist/common/helpers/log"),k=require("ag-common/dist/common/helpers/object"),T=r=>{try{let e=/^\[?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}\]?$/gim,t=/(at \S+?) \(\S+\)\s/gim,n=/^((%[cs])+\s*)+$/gim,o=/^color:/gim,s;(0,k.isJson)(r.message)?s=JSON.parse(r.message):s=[r.message];let g=s.findIndex(i=>i.match(n)),f=s.findIndex(i=>i.match(o));g>=0&&f>=0&&f===g+1&&(s=s.filter((i,$)=>![g,f].includes($)));let P=s.map(i=>i.includes(".js:")||i.includes("node_modules")?i.replace(t,"$1 (stacktrace)"):i.replace(e,"[date]")),p=JSON.stringify(P),y=(0,d.hashCode)(p).toString();return(0,h.debug)("got errorKey=",p,y),y}catch{return(0,d.hashCode)(r.message).toString()}};var S=(r,e)=>{let t=[],n={},o=0;return Object.entries(r).forEach(([s,g])=>{o<e?t.push(g):n[s]=g,o+=1}),{part:t,rest:n}};var w=typeof window<"u"&&window.location.hostname==="localhost",a={},m,u,b=(r,e)=>{let t=(r?.data.occurrences??0)+(e.data.occurrences??1);return{...e,data:{...e.data,occurrences:t}}},O=async()=>{try{if(Object.keys(a).length>100){let n=Object.keys(a)[0],o=a[n],s=await fetch(`${u}/site/errors`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify([{key:o.key,data:{...o.data,message:`error overload!: ${o.data.message||"?"}`}}])});if(a={},!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return{}}let{part:r,rest:e}=S(a,10);a=e;let t=await fetch(`${u}/site/errors`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify(r)});if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`)}catch(r){return{error:r instanceof Error?r.message:String(r)}}finally{Object.keys(a).length>0?m=setTimeout(O,1e3):m=void 0}},I=async({data:r,overrideBaseUrl:e="https://analytica.click/api",ignoreBrowserErrors:t=["will be removed","performing full reload","tracking error","fetch RSC payload","perform a full reload","warnings#debug_enabled",'"digest"',"punycode"],devMode:n})=>{if(e||(e="https://analytica.click/api"),e.startsWith("/")&&typeof window>"u"&&(e="https://analytica.click/api"),t.length>0){let s=(0,E.containsInsensitive)(r.data.message,...t);if(s){(0,c.debug)("ignoring error, contains=",s);return}}if(w&&n)(0,c.debug)("allowing local error tracking due to devmode=true");else if(w)return(0,c.debug)(`local error tracking ignored:${r.data.message} ${JSON.stringify(r)}, to ${e}`),{};if(!C(r.data.message))return{};(0,c.debug)("error track",r.data.message,JSON.stringify(r));let o=T({...r.data,name:r.data.name??"unknown"});return a[o]=b(a[o],r),u=e,m??=setTimeout(O,500),{}};function C(r){return r?r.match(/^"?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}"?$/)?((0,c.info)("ignoring react devtools message"),!1):r===JSON.stringify([{}])?((0,c.info)("empty message payload?"),!1):!0:((0,c.info)("no message?"),!1)}0&&(module.exports={errorTrack,mergeErrorPayload});
|
package/dist/helpers/server.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
'use client';
|
|
2
1
|
"use strict";var g=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var l=(r,t)=>{for(var o in t)g(r,o,{get:t[o],enumerable:!0})},y=(r,t,o,d)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of f(t))!w.call(r,s)&&s!==o&&g(r,s,{get:()=>t[s],enumerable:!(d=p(t,s))||d.enumerable});return r};var h=r=>y(g({},"__esModule",{value:!0}),r);var k={};l(k,{event:()=>u,metric:()=>v,page:()=>m});module.exports=h(k);var b=require("cross-fetch/polyfill"),i=require("ag-common/dist/common/helpers/log"),u=async r=>{let{analyticaToken:t,overrideBaseUrl:o="https://analytica.click/api",eventName:d,devMode:s,valueOverrides:a}=r;if(!s&&typeof window<"u"&&window.location.hostname==="localhost")return(0,i.debug)(`local page ignored: ${JSON.stringify(r)}, to ${o}`),{};let n={eventName:d,browserFingerprint:a?.browserFingerprint,pageLocation:""};typeof window<"u"&&(n={...n,pageLocation:window.location.href,browserResolution:`${window.screen.width}:${window.screen.height}`}),typeof navigator<"u"&&(n={...n,browser:navigator.userAgent});try{let e=await fetch(`${o}/site/event`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify({key:t,data:n})});if(!e.ok){let c=await e.text();return(0,i.warn)("tracking error:"+c),{error:c}}}catch(e){let c=e instanceof Error?e.message:"Unknown error";return(0,i.warn)("tracking error:"+c),{error:c}}return{}},m=async r=>{let{analyticaToken:t,overrideBaseUrl:o="https://analytica.click/api",devMode:d,valueOverrides:s}=r;if(!d&&typeof window<"u"&&window.location.hostname==="localhost")return(0,i.debug)(`local page ignored: ${JSON.stringify(r)}, to ${o}`),{};let a={pageLocation:"",browserFingerprint:s?.browserFingerprint};if(typeof window<"u"&&(a={...a,pageLocation:window.location.href,browserResolution:`${window.screen.width}:${window.screen.height}`}),typeof document<"u"&&(a={...a,pageReferrer:document.referrer,pageTitle:document.title}),typeof navigator<"u"&&(a={...a,browserLanguage:navigator.language,browser:navigator.userAgent}),!a.pageLocation)return(0,i.warn)("no pageLocation"),{};try{let n=await fetch(`${o}/site/tracking`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify({key:t,data:a})});if(!n.ok){let e=await n.text();return(0,i.warn)("tracking error:"+e),{error:e}}}catch(n){let e=n instanceof Error?n.message:"Unknown error";return(0,i.warn)("tracking error:"+e),{error:e}}return{}},v=async r=>{let{analyticaToken:t,overrideBaseUrl:o="https://analytica.click/api",type:d,value:s,devMode:a}=r;if(!a&&typeof window<"u"&&window.location.hostname==="localhost")return(0,i.debug)(`local metric ignored: ${JSON.stringify(r)}, to ${o}`),{};if(d==="health")return(0,i.warn)('Type "health" is reserved for system metrics'),{error:'Type "health" is reserved for system metrics'};let n={type:d,value:s};try{let e=await fetch(`${o}/site/metric`,{method:"POST",headers:{"Content-Type":"application/json",authorization:""},body:JSON.stringify({key:t,data:n})});if(!e.ok){let c=await e.text();return(0,i.warn)("metric tracking error:"+c),{error:c}}}catch(e){let c=e instanceof Error?e.message:"Unknown error";return(0,i.warn)("metric tracking error:"+c),{error:c}}return{}};0&&(module.exports={event,metric,page});
|