@aj-2000-test/goodlogs-sdk 0.4.5 → 0.4.6

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,4 +1,4 @@
1
- 'use strict';var S=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var C={us:"https://goodlogs-api-us.happyhill-a7c56143.centralindia.azurecontainerapps.io",eu:"https://goodlogs-api-eu.yellowmeadow-422296f6.japaneast.azurecontainerapps.io",ap:"https://goodlogs-api-ap.delightfulsand-90b72c09.southeastasia.azurecontainerapps.io"};function B(o){let e=o.split("_");return e.length>=4&&e[0]==="gl"?e[2]:"eu"}function y(o,e){if(e)return e;let t=B(o);return C[t]||C.eu}var G=5e3,F=50,v="0.4.5",w="gl_anon_id",_="gl_session_id";function b(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,o=>{let e=Math.random()*16|0;return (o==="x"?e:e&3|8).toString(16)})}function U(){let o={$goodlogs_sdk:"js",$goodlogs_sdk_version:v};return typeof navigator>"u"||(typeof screen<"u"&&(o.$screen=`${screen.width}x${screen.height}`),typeof navigator<"u"&&(o.$language=navigator.language??""),typeof location<"u"&&(o.$url=location.href,o.$path=location.pathname,o.$page=location.pathname.split("/").filter(Boolean).pop()||"/"),typeof document<"u"&&(document.referrer&&(o.$referrer=document.referrer),document.title&&(o.$title=document.title))),o}function M(o,e){let t={$session_id:o,$distinct_id:e,$goodlogs_sdk:"js",$goodlogs_sdk_version:v};return typeof navigator>"u"||typeof location<"u"&&(t.$url=location.href,t.$path=location.pathname),t}function D(o,e,t,n,r){let s=M(o,e);return t&&(s.$release=t),s.$environment=n,r.email&&(s.$user_email=r.email),r.name&&(s.$user_name=r.name),s}function K(){if(!(typeof document<"u"))try{let e=new Error().stack?.split(`
1
+ 'use strict';var S=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var C={us:"https://goodlogs-api-us.happyhill-a7c56143.centralindia.azurecontainerapps.io",eu:"https://goodlogs-api-eu.yellowmeadow-422296f6.japaneast.azurecontainerapps.io",ap:"https://goodlogs-api-ap.delightfulsand-90b72c09.southeastasia.azurecontainerapps.io"};function B(o){let e=o.split("_");return e.length>=4&&e[0]==="gl"?e[2]:"eu"}function y(o,e){if(e)return e;let t=B(o);return C[t]||C.eu}var G=5e3,F=50,v="0.4.6",w="gl_anon_id",_="gl_session_id";function b(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,o=>{let e=Math.random()*16|0;return (o==="x"?e:e&3|8).toString(16)})}function U(){let o={$goodlogs_sdk:"js",$goodlogs_sdk_version:v};return typeof navigator>"u"||(typeof screen<"u"&&(o.$screen=`${screen.width}x${screen.height}`),typeof navigator<"u"&&(o.$language=navigator.language??""),typeof location<"u"&&(o.$url=location.href,o.$path=location.pathname,o.$page=location.pathname.split("/").filter(Boolean).pop()||"/"),typeof document<"u"&&(document.referrer&&(o.$referrer=document.referrer),document.title&&(o.$title=document.title))),o}function M(o,e){let t={$session_id:o,$distinct_id:e,$goodlogs_sdk:"js",$goodlogs_sdk_version:v};return typeof navigator>"u"||typeof location<"u"&&(t.$url=location.href,t.$path=location.pathname),t}function D(o,e,t,n,r){let s=M(o,e);return t&&(s.$release=t),s.$environment=n,r.email&&(s.$user_email=r.email),r.name&&(s.$user_name=r.name),s}function K(){if(!(typeof document<"u"))try{let e=new Error().stack?.split(`
2
2
  `);if(!e)return;for(let t=3;t<Math.min(e.length,8);t++){let n=e[t]?.trim();if(!n||n.includes("goodlogs")&&(n.includes("client.")||n.includes("index.")))continue;let r=n.match(/at\s+(?:(.+?)\s+\()?(.+?):(\d+):\d+\)?/);if(r){let s=r[1]||"<anonymous>",i=r[2]?.replace(/^.*[/\\]/,"")??"",d=r[3];return `${s}@${i}:${d}`}}}catch{}}function X(o){let e=[],t=o;for(;t&&t.tagName;){let n=t.tagName.toLowerCase();if(n==="html"||n==="body"){e.unshift(n);break}if(t.id){e.unshift(`#${t.id}`);break}let r=1,s=t;for(;s?.previousElementSibling;)s.previousElementSibling.tagName?.toLowerCase()===n&&r++,s=s.previousElementSibling;e.unshift(r>1?`${n}:nth-of-type(${r})`:n),t=t.parentElement;}return e.join(" > ").slice(0,200)}function V(){if(typeof localStorage<"u"){let o=localStorage.getItem(w);if(o)return o;let e=b();return localStorage.setItem(w,e),e}return b()}function z(){if(typeof sessionStorage<"u"){let o=sessionStorage.getItem(_);if(o)return o;let e=b();return sessionStorage.setItem(_,e),e}return b()}function W(){let o="";for(let e=0;e<32;e++)o+=(Math.random()*16|0).toString(16);return o}function J(){let o="";for(let e=0;e<16;e++)o+=(Math.random()*16|0).toString(16);return o}function Y(o,e){switch(o){case "lcp":return e<=2500?"good":e<=4e3?"needs-improvement":"poor";case "inp":return e<=200?"good":e<=500?"needs-improvement":"poor";case "cls":return e<=.1?"good":e<=.25?"needs-improvement":"poor";case "fcp":return e<=1800?"good":e<=3e3?"needs-improvement":"poor";case "ttfb":return e<=800?"good":e<=1800?"needs-improvement":"poor";case "dns":return e<=20?"good":e<=100?"needs-improvement":"poor";case "tcp":return e<=50?"good":e<=200?"needs-improvement":"poor";case "download":return e<=100?"good":e<=500?"needs-improvement":"poor";case "dom_processing":return e<=500?"good":e<=1500?"needs-improvement":"poor";case "page_load":return e<=1e3?"good":e<=3e3?"needs-improvement":"poor";default:return}}function Q(o){if(!o)return [];let e=[];for(let t of o.split(`
3
3
  `)){let n=t.trim();if(!n||n.startsWith("Error")||n.startsWith("at Error"))continue;let r=/^at\s+(?:(.+?)\s+\()?(.+?):(\d+):(\d+)\)?$/.exec(n);if(r){let s=r[1]?.trim(),i=r[2];e.push({function:s&&s!=="<anonymous>"?s:void 0,filename:i,lineno:Number(r[3]),colno:Number(r[4]),abs_path:i,in_app:!i.includes("node_modules/")&&!i.includes("/dist/")&&!i.startsWith("internal/")});continue}if(r=/^([^@]*)@(.+?):(\d+):(\d+)$/.exec(n),r){let s=r[1]?.trim(),i=r[2];e.push({function:s||void 0,filename:i,lineno:Number(r[3]),colno:Number(r[4]),abs_path:i,in_app:!i.includes("node_modules/")&&!i.includes("/dist/")});}}return e}var R=class R{constructor(e){this.userProperties={};this.originalFetch=null;this.xhrPatched=false;this._debug=false;this.logBuffer=[];this.eventBuffer=[];this.errorBuffer=[];this.vitalBuffer=[];this.spanBuffer=[];this.breadcrumbBuffer=[];this.timer=null;this.visibilityHandler=null;this.clickHandler=null;this.lastPath="";this.navTransaction=null;this.errorHandler=null;this.rejectionHandler=null;this.apiKey=e.apiKey,this.endpoint=y(e.apiKey,e.endpoint).replace(/\/+$/,""),this.flushInterval=e.flushInterval??G,this.batchSize=e.batchSize??F,this.defaultContext=e.defaultContext??{},this.onError=e.onError??(()=>{}),this.disabled=e.disabled??false,this.telemetry=e.telemetry??true,this.useEnvelope=e.useEnvelope??false,this.autoFetch=e.autoFetch??(this.useEnvelope&&e.autocapture!==false),this.release=e.release??null,this.environment=e.environment??"production",this._debug=e.debug??false,this.anonymousId=V(),this.sessionId=z(),this._debug&&this._log("init",{endpoint:this.endpoint,sessionId:this.sessionId,distinctId:this.anonymousId,release:this.release,env:this.environment,envelope:this.useEnvelope,autoFetch:this.autoFetch}),this.disabled&&typeof console<"u"&&console.warn("[GoodLogs] SDK is disabled. No events or logs will be sent."),!this.disabled&&typeof setTimeout<"u"&&setTimeout(()=>{!this.release&&typeof console<"u"&&console.warn("[GoodLogs] No release version set. Set `release` in options or call gl.setRelease('1.2.3') for release health tracking.");},5e3),this.disabled||(this.startTimer(),this.attachPageLifecycle(),e.autocapture!==false&&(this.attachClickCapture(),this.captureWebVitals(),this.attachPageviewCapture(),this.attachGlobalErrorHandlers()),this.autoFetch&&(this.attachFetchInstrumentation(),this.attachXhrInstrumentation()),this.sendTelemetry("init","info"));}log(e,t,n){if(this.disabled)return;let r=65536,s=t;t.length>r&&(s=t.slice(0,r-100)+`
4
4
 
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var S=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var C={us:"https://goodlogs-api-us.happyhill-a7c56143.centralindia.azurecontainerapps.io",eu:"https://goodlogs-api-eu.yellowmeadow-422296f6.japaneast.azurecontainerapps.io",ap:"https://goodlogs-api-ap.delightfulsand-90b72c09.southeastasia.azurecontainerapps.io"};function B(o){let e=o.split("_");return e.length>=4&&e[0]==="gl"?e[2]:"eu"}function y(o,e){if(e)return e;let t=B(o);return C[t]||C.eu}var G=5e3,F=50,v="0.4.5",w="gl_anon_id",_="gl_session_id";function b(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,o=>{let e=Math.random()*16|0;return (o==="x"?e:e&3|8).toString(16)})}function U(){let o={$goodlogs_sdk:"js",$goodlogs_sdk_version:v};return typeof navigator>"u"||(typeof screen<"u"&&(o.$screen=`${screen.width}x${screen.height}`),typeof navigator<"u"&&(o.$language=navigator.language??""),typeof location<"u"&&(o.$url=location.href,o.$path=location.pathname,o.$page=location.pathname.split("/").filter(Boolean).pop()||"/"),typeof document<"u"&&(document.referrer&&(o.$referrer=document.referrer),document.title&&(o.$title=document.title))),o}function M(o,e){let t={$session_id:o,$distinct_id:e,$goodlogs_sdk:"js",$goodlogs_sdk_version:v};return typeof navigator>"u"||typeof location<"u"&&(t.$url=location.href,t.$path=location.pathname),t}function D(o,e,t,n,r){let s=M(o,e);return t&&(s.$release=t),s.$environment=n,r.email&&(s.$user_email=r.email),r.name&&(s.$user_name=r.name),s}function K(){if(!(typeof document<"u"))try{let e=new Error().stack?.split(`
1
+ var S=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var C={us:"https://goodlogs-api-us.happyhill-a7c56143.centralindia.azurecontainerapps.io",eu:"https://goodlogs-api-eu.yellowmeadow-422296f6.japaneast.azurecontainerapps.io",ap:"https://goodlogs-api-ap.delightfulsand-90b72c09.southeastasia.azurecontainerapps.io"};function B(o){let e=o.split("_");return e.length>=4&&e[0]==="gl"?e[2]:"eu"}function y(o,e){if(e)return e;let t=B(o);return C[t]||C.eu}var G=5e3,F=50,v="0.4.6",w="gl_anon_id",_="gl_session_id";function b(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,o=>{let e=Math.random()*16|0;return (o==="x"?e:e&3|8).toString(16)})}function U(){let o={$goodlogs_sdk:"js",$goodlogs_sdk_version:v};return typeof navigator>"u"||(typeof screen<"u"&&(o.$screen=`${screen.width}x${screen.height}`),typeof navigator<"u"&&(o.$language=navigator.language??""),typeof location<"u"&&(o.$url=location.href,o.$path=location.pathname,o.$page=location.pathname.split("/").filter(Boolean).pop()||"/"),typeof document<"u"&&(document.referrer&&(o.$referrer=document.referrer),document.title&&(o.$title=document.title))),o}function M(o,e){let t={$session_id:o,$distinct_id:e,$goodlogs_sdk:"js",$goodlogs_sdk_version:v};return typeof navigator>"u"||typeof location<"u"&&(t.$url=location.href,t.$path=location.pathname),t}function D(o,e,t,n,r){let s=M(o,e);return t&&(s.$release=t),s.$environment=n,r.email&&(s.$user_email=r.email),r.name&&(s.$user_name=r.name),s}function K(){if(!(typeof document<"u"))try{let e=new Error().stack?.split(`
2
2
  `);if(!e)return;for(let t=3;t<Math.min(e.length,8);t++){let n=e[t]?.trim();if(!n||n.includes("goodlogs")&&(n.includes("client.")||n.includes("index.")))continue;let r=n.match(/at\s+(?:(.+?)\s+\()?(.+?):(\d+):\d+\)?/);if(r){let s=r[1]||"<anonymous>",i=r[2]?.replace(/^.*[/\\]/,"")??"",d=r[3];return `${s}@${i}:${d}`}}}catch{}}function X(o){let e=[],t=o;for(;t&&t.tagName;){let n=t.tagName.toLowerCase();if(n==="html"||n==="body"){e.unshift(n);break}if(t.id){e.unshift(`#${t.id}`);break}let r=1,s=t;for(;s?.previousElementSibling;)s.previousElementSibling.tagName?.toLowerCase()===n&&r++,s=s.previousElementSibling;e.unshift(r>1?`${n}:nth-of-type(${r})`:n),t=t.parentElement;}return e.join(" > ").slice(0,200)}function V(){if(typeof localStorage<"u"){let o=localStorage.getItem(w);if(o)return o;let e=b();return localStorage.setItem(w,e),e}return b()}function z(){if(typeof sessionStorage<"u"){let o=sessionStorage.getItem(_);if(o)return o;let e=b();return sessionStorage.setItem(_,e),e}return b()}function W(){let o="";for(let e=0;e<32;e++)o+=(Math.random()*16|0).toString(16);return o}function J(){let o="";for(let e=0;e<16;e++)o+=(Math.random()*16|0).toString(16);return o}function Y(o,e){switch(o){case "lcp":return e<=2500?"good":e<=4e3?"needs-improvement":"poor";case "inp":return e<=200?"good":e<=500?"needs-improvement":"poor";case "cls":return e<=.1?"good":e<=.25?"needs-improvement":"poor";case "fcp":return e<=1800?"good":e<=3e3?"needs-improvement":"poor";case "ttfb":return e<=800?"good":e<=1800?"needs-improvement":"poor";case "dns":return e<=20?"good":e<=100?"needs-improvement":"poor";case "tcp":return e<=50?"good":e<=200?"needs-improvement":"poor";case "download":return e<=100?"good":e<=500?"needs-improvement":"poor";case "dom_processing":return e<=500?"good":e<=1500?"needs-improvement":"poor";case "page_load":return e<=1e3?"good":e<=3e3?"needs-improvement":"poor";default:return}}function Q(o){if(!o)return [];let e=[];for(let t of o.split(`
3
3
  `)){let n=t.trim();if(!n||n.startsWith("Error")||n.startsWith("at Error"))continue;let r=/^at\s+(?:(.+?)\s+\()?(.+?):(\d+):(\d+)\)?$/.exec(n);if(r){let s=r[1]?.trim(),i=r[2];e.push({function:s&&s!=="<anonymous>"?s:void 0,filename:i,lineno:Number(r[3]),colno:Number(r[4]),abs_path:i,in_app:!i.includes("node_modules/")&&!i.includes("/dist/")&&!i.startsWith("internal/")});continue}if(r=/^([^@]*)@(.+?):(\d+):(\d+)$/.exec(n),r){let s=r[1]?.trim(),i=r[2];e.push({function:s||void 0,filename:i,lineno:Number(r[3]),colno:Number(r[4]),abs_path:i,in_app:!i.includes("node_modules/")&&!i.includes("/dist/")});}}return e}var R=class R{constructor(e){this.userProperties={};this.originalFetch=null;this.xhrPatched=false;this._debug=false;this.logBuffer=[];this.eventBuffer=[];this.errorBuffer=[];this.vitalBuffer=[];this.spanBuffer=[];this.breadcrumbBuffer=[];this.timer=null;this.visibilityHandler=null;this.clickHandler=null;this.lastPath="";this.navTransaction=null;this.errorHandler=null;this.rejectionHandler=null;this.apiKey=e.apiKey,this.endpoint=y(e.apiKey,e.endpoint).replace(/\/+$/,""),this.flushInterval=e.flushInterval??G,this.batchSize=e.batchSize??F,this.defaultContext=e.defaultContext??{},this.onError=e.onError??(()=>{}),this.disabled=e.disabled??false,this.telemetry=e.telemetry??true,this.useEnvelope=e.useEnvelope??false,this.autoFetch=e.autoFetch??(this.useEnvelope&&e.autocapture!==false),this.release=e.release??null,this.environment=e.environment??"production",this._debug=e.debug??false,this.anonymousId=V(),this.sessionId=z(),this._debug&&this._log("init",{endpoint:this.endpoint,sessionId:this.sessionId,distinctId:this.anonymousId,release:this.release,env:this.environment,envelope:this.useEnvelope,autoFetch:this.autoFetch}),this.disabled&&typeof console<"u"&&console.warn("[GoodLogs] SDK is disabled. No events or logs will be sent."),!this.disabled&&typeof setTimeout<"u"&&setTimeout(()=>{!this.release&&typeof console<"u"&&console.warn("[GoodLogs] No release version set. Set `release` in options or call gl.setRelease('1.2.3') for release health tracking.");},5e3),this.disabled||(this.startTimer(),this.attachPageLifecycle(),e.autocapture!==false&&(this.attachClickCapture(),this.captureWebVitals(),this.attachPageviewCapture(),this.attachGlobalErrorHandlers()),this.autoFetch&&(this.attachFetchInstrumentation(),this.attachXhrInstrumentation()),this.sendTelemetry("init","info"));}log(e,t,n){if(this.disabled)return;let r=65536,s=t;t.length>r&&(s=t.slice(0,r-100)+`
4
4
 
package/dist/replay.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var G=new Set([1,3,6]);function V(o){return o.every(n=>{if(n.type!==3)return false;let i=n.data?.source;return i!==void 0&&G.has(i)})}var y=null;async function W(o,n={}){if(typeof document>"u")return null;if(y)return y;let i=n.sampleRate??1;if(i<1&&Math.random()>i)return null;let u=n.rrwebRecord??await Q();if(!u)return null;let l=o.endpoint,f=o.apiKey,g=o,q=n.debug??g._debug??false,r=(e,t)=>{if(!q||typeof console>"u")return;let a=new Date().toISOString().slice(11,23);t?console.log(`%c[GL:replay ${a}]%c ${e}`,"color:#f59e0b;font-weight:bold","color:inherit",t):console.log(`%c[GL:replay ${a}]%c ${e}`,"color:#f59e0b;font-weight:bold","color:inherit");},D=n.flushIntervalMs??5e3,T=n.flushBytes??5e5,S=n.sessionTimeoutMs??1800*1e3,I=n.maxSessionMs??3600*1e3;r("config",{flushIntervalMs:D,flushBytes:T,sessionTimeoutMs:S/1e3+"s",maxSessionMs:I/1e3+"s"});let s=g.sessionId,d=[],b=0,M=0,k=false,w=false,c=Date.now(),m=Date.now(),x=null,O=()=>{r("session:announce",{sessionId:s,distinctId:g.getDistinctId()}),v(l,f,{session_id:s,distinct_id:g.getDistinctId(),started_at:new Date(m).toISOString(),start_url:typeof location<"u"?location.href:null,last_url:typeof location<"u"?location.href:null},n.onError);},B=()=>{let e=s;r("session:seal",{sessionId:e,queueSize:d.length}),p(true),v(l,f,{session_id:e,ended_at:new Date().toISOString()},n.onError);},p=async(e=false)=>{if(d.length===0)return;if(!e&&V(d)){d=[],b=0;return}let t=d,a=t[0].timestamp,R=t[t.length-1].timestamp,P=t.length,E=s;d=[],b=0;let z=M++;try{let h=JSON.stringify(t),K=await F(h);r("chunk:upload",{sessionId:E,seq:z,events:P,bytes:h.length,range:`${new Date(a).toISOString()} \u2192 ${new Date(R).toISOString()}`});let J=`${l}/v1/replay/chunks?session_id=${encodeURIComponent(E)}&seq=${z}&start_ts=${encodeURIComponent(new Date(a).toISOString())}&end_ts=${encodeURIComponent(new Date(R).toISOString())}&event_count=${P}`;await fetch(J,{method:"POST",headers:{Authorization:`Bearer ${f}`,"Content-Type":"application/gzip","Content-Encoding":"gzip"},body:K,keepalive:!0});}catch(h){n.onError?.(h);}v(l,f,{session_id:E,last_url:typeof location<"u"?location.href:null,last_activity_at:new Date(R).toISOString(),has_error:k||void 0},n.onError);},_=()=>{let e=Date.now()-m,t=Date.now()-c;r("session:rotate",{oldSessionId:s,elapsed:Math.round(e/1e3)+"s",idle:Math.round(t/1e3)+"s"}),B();try{x?.();}catch(a){n.onError?.(a);}g.newSession(),s=g.getSessionId(),M=0,k=false,c=Date.now(),m=Date.now(),O(),$();},$=()=>{x=u({emit:e=>{if(w)return;e.type===3&&G.has(e.data?.source??-1)||(c=Date.now()),d.push(e),b+=256,b>=T&&p();},checkoutEveryNms:6e4,maskAllInputs:n.maskAllInputs??true,blockSelector:n.blockSelector??"[data-gl-block]",maskTextSelector:n.maskTextSelector??"[data-gl-mask]",sampling:{mousemove:50,mouseInteraction:true,scroll:150,input:"last"}});},U=setInterval(()=>{globalThis.__gl_replay_has_error__&&(k=true);},1e3),H=()=>{if(!w){r("stop",{sessionId:s}),w=true,clearInterval(N),clearInterval(j),clearInterval(U),document?.removeEventListener("visibilitychange",C),typeof window<"u"&&window.removeEventListener("beforeunload",L);try{x?.();}catch(e){n.onError?.(e);}B(),y=null;}};r("start",{sessionId:s,sampleRate:i}),O(),$();let N=setInterval(()=>{p();},D),j=setInterval(()=>{if(w)return;let e=Date.now();if(e-c>S){r("watchdog:idle-timeout",{idle:Math.round((e-c)/1e3)+"s"}),_();return}if(e-m>I){r("watchdog:max-duration",{elapsed:Math.round((e-m)/1e3)+"s"}),_();return}},1e4),C=()=>{if(!w){if(document?.visibilityState==="hidden")r("visibility:hidden",{sessionId:s}),p(true),v(l,f,{session_id:s,ended_at:new Date().toISOString()},n.onError);else if(document?.visibilityState==="visible"){let e=Date.now(),t=e-c,a=e-m;r("visibility:visible",{idle:Math.round(t/1e3)+"s",elapsed:Math.round(a/1e3)+"s"}),t>S||a>I?_():c=e;}}};document.addEventListener("visibilitychange",C);let L=()=>{p(true),v(l,f,{session_id:s,ended_at:new Date().toISOString()},n.onError);};typeof window<"u"&&window.addEventListener("beforeunload",L);let A={get sessionId(){return s},flush:()=>p(true),stop:H};return y=A,A}async function v(o,n,i,u){try{await fetch(`${o}/v1/replay/sessions`,{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify(i),keepalive:!0});}catch(l){u?.(l);}}async function F(o){if(typeof CompressionStream>"u"||typeof Blob>"u"||typeof Response>"u")return o;let i=new Blob([o]).stream().pipeThrough(new CompressionStream("gzip")),u=await new Response(i).arrayBuffer();return new Blob([u],{type:"application/gzip"})}async function Q(){try{let o=await import('rrweb');return o.record??o.default?.record??null}catch{return null}}exports.startReplay=W;
1
+ 'use strict';var G=new Set([1,3,6]);function Y(s){return s.every(n=>{if(n.type!==3)return false;let i=n.data?.source;return i!==void 0&&G.has(i)})}var S=null;async function X(s,n={}){if(typeof document>"u")return null;if(S)return S;let i=n.sampleRate??1;if(i<1&&Math.random()>i)return null;let u=n.rrwebRecord??await W();if(!u)return null;let l=s.endpoint,f=s.apiKey,g=s,U=n.debug??g._debug??false,r=(e,o)=>{if(!U||typeof console>"u")return;let a=new Date().toISOString().slice(11,23);o?console.log(`%c[GL:replay ${a}]%c ${e}`,"color:#f59e0b;font-weight:bold","color:inherit",o):console.log(`%c[GL:replay ${a}]%c ${e}`,"color:#f59e0b;font-weight:bold","color:inherit");},T=n.flushIntervalMs??5e3,M=n.flushBytes??5e5,I=n.sessionTimeoutMs??1800*1e3,_=n.maxSessionMs??3600*1e3;r("config",{flushIntervalMs:T,flushBytes:M,sessionTimeoutMs:I/1e3+"s",maxSessionMs:_/1e3+"s"});let t=g.sessionId,d=[],y=0,O=`gl_replay_seq_${t}`,k=(()=>{try{return parseInt(sessionStorage?.getItem(O)??"0",10)||0}catch{return 0}})(),H=()=>{try{sessionStorage?.setItem(O,String(k));}catch{}},x=false,w=false,c=Date.now(),m=Date.now(),R=null,B=()=>{r("session:announce",{sessionId:t,distinctId:g.getDistinctId()}),b(l,f,{session_id:t,distinct_id:g.getDistinctId(),started_at:new Date(m).toISOString(),start_url:typeof location<"u"?location.href:null,last_url:typeof location<"u"?location.href:null},n.onError);},$=()=>{let e=t;r("session:seal",{sessionId:e,queueSize:d.length}),p(true),b(l,f,{session_id:e,ended_at:new Date().toISOString()},n.onError);},p=async(e=false)=>{if(d.length===0)return;if(!e&&Y(d)){d=[],y=0;return}let o=d,a=o[0].timestamp,v=o[o.length-1].timestamp,P=o.length,D=t;d=[],y=0;let z=k++;H();try{let h=JSON.stringify(o),Q=await F(h);r("chunk:upload",{sessionId:D,seq:z,events:P,bytes:h.length,range:`${new Date(a).toISOString()} \u2192 ${new Date(v).toISOString()}`});let V=`${l}/v1/replay/chunks?session_id=${encodeURIComponent(D)}&seq=${z}&start_ts=${encodeURIComponent(new Date(a).toISOString())}&end_ts=${encodeURIComponent(new Date(v).toISOString())}&event_count=${P}`;await fetch(V,{method:"POST",headers:{Authorization:`Bearer ${f}`,"Content-Type":"application/gzip","Content-Encoding":"gzip"},body:Q,keepalive:!0});}catch(h){n.onError?.(h);}b(l,f,{session_id:D,last_url:typeof location<"u"?location.href:null,last_activity_at:new Date(v).toISOString(),has_error:x||void 0},n.onError);},E=()=>{let e=Date.now()-m,o=Date.now()-c;r("session:rotate",{oldSessionId:t,elapsed:Math.round(e/1e3)+"s",idle:Math.round(o/1e3)+"s"}),$();try{R?.();}catch(v){n.onError?.(v);}g.newSession(),t=g.getSessionId(),k=0;let a=`gl_replay_seq_${t}`;try{sessionStorage?.setItem(a,"0");}catch{}x=false,c=Date.now(),m=Date.now(),B(),C();},C=()=>{R=u({emit:e=>{if(w)return;e.type===3&&G.has(e.data?.source??-1)||(c=Date.now()),d.push(e),y+=256,y>=M&&p();},checkoutEveryNms:6e4,maskAllInputs:n.maskAllInputs??true,blockSelector:n.blockSelector??"[data-gl-block]",maskTextSelector:n.maskTextSelector??"[data-gl-mask]",sampling:{mousemove:50,mouseInteraction:true,scroll:150,input:"last"}});},K=setInterval(()=>{globalThis.__gl_replay_has_error__&&(x=true);},1e3),N=()=>{if(!w){r("stop",{sessionId:t}),w=true,clearInterval(j),clearInterval(J),clearInterval(K),document?.removeEventListener("visibilitychange",L),typeof window<"u"&&window.removeEventListener("beforeunload",q);try{R?.();}catch(e){n.onError?.(e);}$(),S=null;}};r("start",{sessionId:t,sampleRate:i}),B(),C();let j=setInterval(()=>{p();},T),J=setInterval(()=>{if(w)return;let e=Date.now();if(e-c>I){r("watchdog:idle-timeout",{idle:Math.round((e-c)/1e3)+"s"}),E();return}if(e-m>_){r("watchdog:max-duration",{elapsed:Math.round((e-m)/1e3)+"s"}),E();return}},1e4),L=()=>{if(!w){if(document?.visibilityState==="hidden")r("visibility:hidden",{sessionId:t}),p(true),b(l,f,{session_id:t,ended_at:new Date().toISOString()},n.onError);else if(document?.visibilityState==="visible"){let e=Date.now(),o=e-c,a=e-m;r("visibility:visible",{idle:Math.round(o/1e3)+"s",elapsed:Math.round(a/1e3)+"s"}),o>I||a>_?E():c=e;}}};document.addEventListener("visibilitychange",L);let q=()=>{p(true),b(l,f,{session_id:t,ended_at:new Date().toISOString()},n.onError);};typeof window<"u"&&window.addEventListener("beforeunload",q);let A={get sessionId(){return t},flush:()=>p(true),stop:N};return S=A,A}async function b(s,n,i,u){try{await fetch(`${s}/v1/replay/sessions`,{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify(i),keepalive:!0});}catch(l){u?.(l);}}async function F(s){if(typeof CompressionStream>"u"||typeof Blob>"u"||typeof Response>"u")return s;let i=new Blob([s]).stream().pipeThrough(new CompressionStream("gzip")),u=await new Response(i).arrayBuffer();return new Blob([u],{type:"application/gzip"})}async function W(){try{let s=await import('rrweb');return s.record??s.default?.record??null}catch{return null}}exports.startReplay=X;
package/dist/replay.js CHANGED
@@ -1 +1 @@
1
- var G=new Set([1,3,6]);function V(o){return o.every(n=>{if(n.type!==3)return false;let i=n.data?.source;return i!==void 0&&G.has(i)})}var y=null;async function W(o,n={}){if(typeof document>"u")return null;if(y)return y;let i=n.sampleRate??1;if(i<1&&Math.random()>i)return null;let u=n.rrwebRecord??await Q();if(!u)return null;let l=o.endpoint,f=o.apiKey,g=o,q=n.debug??g._debug??false,r=(e,t)=>{if(!q||typeof console>"u")return;let a=new Date().toISOString().slice(11,23);t?console.log(`%c[GL:replay ${a}]%c ${e}`,"color:#f59e0b;font-weight:bold","color:inherit",t):console.log(`%c[GL:replay ${a}]%c ${e}`,"color:#f59e0b;font-weight:bold","color:inherit");},D=n.flushIntervalMs??5e3,T=n.flushBytes??5e5,S=n.sessionTimeoutMs??1800*1e3,I=n.maxSessionMs??3600*1e3;r("config",{flushIntervalMs:D,flushBytes:T,sessionTimeoutMs:S/1e3+"s",maxSessionMs:I/1e3+"s"});let s=g.sessionId,d=[],b=0,M=0,k=false,w=false,c=Date.now(),m=Date.now(),x=null,O=()=>{r("session:announce",{sessionId:s,distinctId:g.getDistinctId()}),v(l,f,{session_id:s,distinct_id:g.getDistinctId(),started_at:new Date(m).toISOString(),start_url:typeof location<"u"?location.href:null,last_url:typeof location<"u"?location.href:null},n.onError);},B=()=>{let e=s;r("session:seal",{sessionId:e,queueSize:d.length}),p(true),v(l,f,{session_id:e,ended_at:new Date().toISOString()},n.onError);},p=async(e=false)=>{if(d.length===0)return;if(!e&&V(d)){d=[],b=0;return}let t=d,a=t[0].timestamp,R=t[t.length-1].timestamp,P=t.length,E=s;d=[],b=0;let z=M++;try{let h=JSON.stringify(t),K=await F(h);r("chunk:upload",{sessionId:E,seq:z,events:P,bytes:h.length,range:`${new Date(a).toISOString()} \u2192 ${new Date(R).toISOString()}`});let J=`${l}/v1/replay/chunks?session_id=${encodeURIComponent(E)}&seq=${z}&start_ts=${encodeURIComponent(new Date(a).toISOString())}&end_ts=${encodeURIComponent(new Date(R).toISOString())}&event_count=${P}`;await fetch(J,{method:"POST",headers:{Authorization:`Bearer ${f}`,"Content-Type":"application/gzip","Content-Encoding":"gzip"},body:K,keepalive:!0});}catch(h){n.onError?.(h);}v(l,f,{session_id:E,last_url:typeof location<"u"?location.href:null,last_activity_at:new Date(R).toISOString(),has_error:k||void 0},n.onError);},_=()=>{let e=Date.now()-m,t=Date.now()-c;r("session:rotate",{oldSessionId:s,elapsed:Math.round(e/1e3)+"s",idle:Math.round(t/1e3)+"s"}),B();try{x?.();}catch(a){n.onError?.(a);}g.newSession(),s=g.getSessionId(),M=0,k=false,c=Date.now(),m=Date.now(),O(),$();},$=()=>{x=u({emit:e=>{if(w)return;e.type===3&&G.has(e.data?.source??-1)||(c=Date.now()),d.push(e),b+=256,b>=T&&p();},checkoutEveryNms:6e4,maskAllInputs:n.maskAllInputs??true,blockSelector:n.blockSelector??"[data-gl-block]",maskTextSelector:n.maskTextSelector??"[data-gl-mask]",sampling:{mousemove:50,mouseInteraction:true,scroll:150,input:"last"}});},U=setInterval(()=>{globalThis.__gl_replay_has_error__&&(k=true);},1e3),H=()=>{if(!w){r("stop",{sessionId:s}),w=true,clearInterval(N),clearInterval(j),clearInterval(U),document?.removeEventListener("visibilitychange",C),typeof window<"u"&&window.removeEventListener("beforeunload",L);try{x?.();}catch(e){n.onError?.(e);}B(),y=null;}};r("start",{sessionId:s,sampleRate:i}),O(),$();let N=setInterval(()=>{p();},D),j=setInterval(()=>{if(w)return;let e=Date.now();if(e-c>S){r("watchdog:idle-timeout",{idle:Math.round((e-c)/1e3)+"s"}),_();return}if(e-m>I){r("watchdog:max-duration",{elapsed:Math.round((e-m)/1e3)+"s"}),_();return}},1e4),C=()=>{if(!w){if(document?.visibilityState==="hidden")r("visibility:hidden",{sessionId:s}),p(true),v(l,f,{session_id:s,ended_at:new Date().toISOString()},n.onError);else if(document?.visibilityState==="visible"){let e=Date.now(),t=e-c,a=e-m;r("visibility:visible",{idle:Math.round(t/1e3)+"s",elapsed:Math.round(a/1e3)+"s"}),t>S||a>I?_():c=e;}}};document.addEventListener("visibilitychange",C);let L=()=>{p(true),v(l,f,{session_id:s,ended_at:new Date().toISOString()},n.onError);};typeof window<"u"&&window.addEventListener("beforeunload",L);let A={get sessionId(){return s},flush:()=>p(true),stop:H};return y=A,A}async function v(o,n,i,u){try{await fetch(`${o}/v1/replay/sessions`,{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify(i),keepalive:!0});}catch(l){u?.(l);}}async function F(o){if(typeof CompressionStream>"u"||typeof Blob>"u"||typeof Response>"u")return o;let i=new Blob([o]).stream().pipeThrough(new CompressionStream("gzip")),u=await new Response(i).arrayBuffer();return new Blob([u],{type:"application/gzip"})}async function Q(){try{let o=await import('rrweb');return o.record??o.default?.record??null}catch{return null}}export{W as startReplay};
1
+ var G=new Set([1,3,6]);function Y(s){return s.every(n=>{if(n.type!==3)return false;let i=n.data?.source;return i!==void 0&&G.has(i)})}var S=null;async function X(s,n={}){if(typeof document>"u")return null;if(S)return S;let i=n.sampleRate??1;if(i<1&&Math.random()>i)return null;let u=n.rrwebRecord??await W();if(!u)return null;let l=s.endpoint,f=s.apiKey,g=s,U=n.debug??g._debug??false,r=(e,o)=>{if(!U||typeof console>"u")return;let a=new Date().toISOString().slice(11,23);o?console.log(`%c[GL:replay ${a}]%c ${e}`,"color:#f59e0b;font-weight:bold","color:inherit",o):console.log(`%c[GL:replay ${a}]%c ${e}`,"color:#f59e0b;font-weight:bold","color:inherit");},T=n.flushIntervalMs??5e3,M=n.flushBytes??5e5,I=n.sessionTimeoutMs??1800*1e3,_=n.maxSessionMs??3600*1e3;r("config",{flushIntervalMs:T,flushBytes:M,sessionTimeoutMs:I/1e3+"s",maxSessionMs:_/1e3+"s"});let t=g.sessionId,d=[],y=0,O=`gl_replay_seq_${t}`,k=(()=>{try{return parseInt(sessionStorage?.getItem(O)??"0",10)||0}catch{return 0}})(),H=()=>{try{sessionStorage?.setItem(O,String(k));}catch{}},x=false,w=false,c=Date.now(),m=Date.now(),R=null,B=()=>{r("session:announce",{sessionId:t,distinctId:g.getDistinctId()}),b(l,f,{session_id:t,distinct_id:g.getDistinctId(),started_at:new Date(m).toISOString(),start_url:typeof location<"u"?location.href:null,last_url:typeof location<"u"?location.href:null},n.onError);},$=()=>{let e=t;r("session:seal",{sessionId:e,queueSize:d.length}),p(true),b(l,f,{session_id:e,ended_at:new Date().toISOString()},n.onError);},p=async(e=false)=>{if(d.length===0)return;if(!e&&Y(d)){d=[],y=0;return}let o=d,a=o[0].timestamp,v=o[o.length-1].timestamp,P=o.length,D=t;d=[],y=0;let z=k++;H();try{let h=JSON.stringify(o),Q=await F(h);r("chunk:upload",{sessionId:D,seq:z,events:P,bytes:h.length,range:`${new Date(a).toISOString()} \u2192 ${new Date(v).toISOString()}`});let V=`${l}/v1/replay/chunks?session_id=${encodeURIComponent(D)}&seq=${z}&start_ts=${encodeURIComponent(new Date(a).toISOString())}&end_ts=${encodeURIComponent(new Date(v).toISOString())}&event_count=${P}`;await fetch(V,{method:"POST",headers:{Authorization:`Bearer ${f}`,"Content-Type":"application/gzip","Content-Encoding":"gzip"},body:Q,keepalive:!0});}catch(h){n.onError?.(h);}b(l,f,{session_id:D,last_url:typeof location<"u"?location.href:null,last_activity_at:new Date(v).toISOString(),has_error:x||void 0},n.onError);},E=()=>{let e=Date.now()-m,o=Date.now()-c;r("session:rotate",{oldSessionId:t,elapsed:Math.round(e/1e3)+"s",idle:Math.round(o/1e3)+"s"}),$();try{R?.();}catch(v){n.onError?.(v);}g.newSession(),t=g.getSessionId(),k=0;let a=`gl_replay_seq_${t}`;try{sessionStorage?.setItem(a,"0");}catch{}x=false,c=Date.now(),m=Date.now(),B(),C();},C=()=>{R=u({emit:e=>{if(w)return;e.type===3&&G.has(e.data?.source??-1)||(c=Date.now()),d.push(e),y+=256,y>=M&&p();},checkoutEveryNms:6e4,maskAllInputs:n.maskAllInputs??true,blockSelector:n.blockSelector??"[data-gl-block]",maskTextSelector:n.maskTextSelector??"[data-gl-mask]",sampling:{mousemove:50,mouseInteraction:true,scroll:150,input:"last"}});},K=setInterval(()=>{globalThis.__gl_replay_has_error__&&(x=true);},1e3),N=()=>{if(!w){r("stop",{sessionId:t}),w=true,clearInterval(j),clearInterval(J),clearInterval(K),document?.removeEventListener("visibilitychange",L),typeof window<"u"&&window.removeEventListener("beforeunload",q);try{R?.();}catch(e){n.onError?.(e);}$(),S=null;}};r("start",{sessionId:t,sampleRate:i}),B(),C();let j=setInterval(()=>{p();},T),J=setInterval(()=>{if(w)return;let e=Date.now();if(e-c>I){r("watchdog:idle-timeout",{idle:Math.round((e-c)/1e3)+"s"}),E();return}if(e-m>_){r("watchdog:max-duration",{elapsed:Math.round((e-m)/1e3)+"s"}),E();return}},1e4),L=()=>{if(!w){if(document?.visibilityState==="hidden")r("visibility:hidden",{sessionId:t}),p(true),b(l,f,{session_id:t,ended_at:new Date().toISOString()},n.onError);else if(document?.visibilityState==="visible"){let e=Date.now(),o=e-c,a=e-m;r("visibility:visible",{idle:Math.round(o/1e3)+"s",elapsed:Math.round(a/1e3)+"s"}),o>I||a>_?E():c=e;}}};document.addEventListener("visibilitychange",L);let q=()=>{p(true),b(l,f,{session_id:t,ended_at:new Date().toISOString()},n.onError);};typeof window<"u"&&window.addEventListener("beforeunload",q);let A={get sessionId(){return t},flush:()=>p(true),stop:N};return S=A,A}async function b(s,n,i,u){try{await fetch(`${s}/v1/replay/sessions`,{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify(i),keepalive:!0});}catch(l){u?.(l);}}async function F(s){if(typeof CompressionStream>"u"||typeof Blob>"u"||typeof Response>"u")return s;let i=new Blob([s]).stream().pipeThrough(new CompressionStream("gzip")),u=await new Response(i).arrayBuffer();return new Blob([u],{type:"application/gzip"})}async function W(){try{let s=await import('rrweb');return s.record??s.default?.record??null}catch{return null}}export{X as startReplay};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aj-2000-test/goodlogs-sdk",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "description": "GoodLogs SDK — ingest logs/events + programmatic API client for queries, alerts, AI",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",