@aj-2000-test/goodlogs-sdk 0.3.3 → 0.3.4
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 +1 -1
- package/dist/index.js +1 -1
- package/dist/profiling.cjs +1 -0
- package/dist/profiling.d.cts +47 -0
- package/dist/profiling.d.ts +47 -0
- package/dist/profiling.js +1 -0
- package/dist/replay.cjs +1 -1
- package/dist/replay.js +1 -1
- package/package.json +6 -1
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:(t,e)=>(typeof require<"u"?require:t)[e]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var I={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 t=o.split("_");return t.length>=4&&t[0]==="gl"?t[2]:"eu"}function y(o,t){if(t)return t;let e=B(o);return I[e]||I.eu}var G=5e3,F=50,v="0.3.
|
|
1
|
+
'use strict';var S=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var I={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 t=o.split("_");return t.length>=4&&t[0]==="gl"?t[2]:"eu"}function y(o,t){if(t)return t;let e=B(o);return I[e]||I.eu}var G=5e3,F=50,v="0.3.4",w="gl_anon_id",_="gl_session_id";function b(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,o=>{let t=Math.random()*16|0;return (o==="x"?t:t&3|8).toString(16)})}function M(){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 U(o,t){let e={$session_id:o,$distinct_id:t,$goodlogs_sdk:"js",$goodlogs_sdk_version:v};return typeof navigator>"u"||typeof location<"u"&&(e.$url=location.href,e.$path=location.pathname),e}function D(){if(!(typeof document<"u"))try{let t=new Error().stack?.split(`
|
|
2
2
|
`);if(!t)return;for(let e=3;e<Math.min(t.length,8);e++){let n=t[e]?.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 K(){if(typeof localStorage<"u"){let o=localStorage.getItem(w);if(o)return o;let t=b();return localStorage.setItem(w,t),t}return b()}function X(){if(typeof sessionStorage<"u"){let o=sessionStorage.getItem(_);if(o)return o;let t=b();return sessionStorage.setItem(_,t),t}return b()}function z(){let o="";for(let t=0;t<32;t++)o+=(Math.random()*16|0).toString(16);return o}function V(){let o="";for(let t=0;t<16;t++)o+=(Math.random()*16|0).toString(16);return o}function W(o,t){switch(o){case "lcp":return t<=2500?"good":t<=4e3?"needs-improvement":"poor";case "inp":return t<=200?"good":t<=500?"needs-improvement":"poor";case "cls":return t<=.1?"good":t<=.25?"needs-improvement":"poor";case "fcp":return t<=1800?"good":t<=3e3?"needs-improvement":"poor";case "ttfb":return t<=800?"good":t<=1800?"needs-improvement":"poor";default:return}}function J(o){if(!o)return [];let t=[];for(let e of o.split(`
|
|
3
3
|
`)){let n=e.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];t.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];t.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 t}var R=class R{constructor(t){this.originalFetch=null;this.xhrPatched=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=t.apiKey,this.endpoint=y(t.apiKey,t.endpoint).replace(/\/+$/,""),this.flushInterval=t.flushInterval??G,this.batchSize=t.batchSize??F,this.defaultContext=t.defaultContext??{},this.onError=t.onError??(()=>{}),this.disabled=t.disabled??false,this.telemetry=t.telemetry??true,this.useEnvelope=t.useEnvelope??false,this.autoFetch=t.autoFetch??(this.useEnvelope&&t.autocapture!==false),this.anonymousId=K(),this.sessionId=X(),this.disabled&&typeof console<"u"&&console.warn("[GoodLogs] SDK is disabled. No events or logs will be sent."),this.disabled||(this.startTimer(),this.attachPageLifecycle(),t.autocapture!==false&&(this.attachClickCapture(),this.captureWebVitals(),this.attachPageviewCapture(),this.attachGlobalErrorHandlers()),this.autoFetch&&(this.attachFetchInstrumentation(),this.attachXhrInstrumentation()),this.sendTelemetry("init","info"));}log(t,e,n){if(this.disabled)return;let r=65536,s=e;e.length>r&&(s=e.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:(t,e)=>(typeof require<"u"?require:t)[e]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var I={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 t=o.split("_");return t.length>=4&&t[0]==="gl"?t[2]:"eu"}function y(o,t){if(t)return t;let e=B(o);return I[e]||I.eu}var G=5e3,F=50,v="0.3.
|
|
1
|
+
var S=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var I={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 t=o.split("_");return t.length>=4&&t[0]==="gl"?t[2]:"eu"}function y(o,t){if(t)return t;let e=B(o);return I[e]||I.eu}var G=5e3,F=50,v="0.3.4",w="gl_anon_id",_="gl_session_id";function b(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,o=>{let t=Math.random()*16|0;return (o==="x"?t:t&3|8).toString(16)})}function M(){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 U(o,t){let e={$session_id:o,$distinct_id:t,$goodlogs_sdk:"js",$goodlogs_sdk_version:v};return typeof navigator>"u"||typeof location<"u"&&(e.$url=location.href,e.$path=location.pathname),e}function D(){if(!(typeof document<"u"))try{let t=new Error().stack?.split(`
|
|
2
2
|
`);if(!t)return;for(let e=3;e<Math.min(t.length,8);e++){let n=t[e]?.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 K(){if(typeof localStorage<"u"){let o=localStorage.getItem(w);if(o)return o;let t=b();return localStorage.setItem(w,t),t}return b()}function X(){if(typeof sessionStorage<"u"){let o=sessionStorage.getItem(_);if(o)return o;let t=b();return sessionStorage.setItem(_,t),t}return b()}function z(){let o="";for(let t=0;t<32;t++)o+=(Math.random()*16|0).toString(16);return o}function V(){let o="";for(let t=0;t<16;t++)o+=(Math.random()*16|0).toString(16);return o}function W(o,t){switch(o){case "lcp":return t<=2500?"good":t<=4e3?"needs-improvement":"poor";case "inp":return t<=200?"good":t<=500?"needs-improvement":"poor";case "cls":return t<=.1?"good":t<=.25?"needs-improvement":"poor";case "fcp":return t<=1800?"good":t<=3e3?"needs-improvement":"poor";case "ttfb":return t<=800?"good":t<=1800?"needs-improvement":"poor";default:return}}function J(o){if(!o)return [];let t=[];for(let e of o.split(`
|
|
3
3
|
`)){let n=e.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];t.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];t.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 t}var R=class R{constructor(t){this.originalFetch=null;this.xhrPatched=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=t.apiKey,this.endpoint=y(t.apiKey,t.endpoint).replace(/\/+$/,""),this.flushInterval=t.flushInterval??G,this.batchSize=t.batchSize??F,this.defaultContext=t.defaultContext??{},this.onError=t.onError??(()=>{}),this.disabled=t.disabled??false,this.telemetry=t.telemetry??true,this.useEnvelope=t.useEnvelope??false,this.autoFetch=t.autoFetch??(this.useEnvelope&&t.autocapture!==false),this.anonymousId=K(),this.sessionId=X(),this.disabled&&typeof console<"u"&&console.warn("[GoodLogs] SDK is disabled. No events or logs will be sent."),this.disabled||(this.startTimer(),this.attachPageLifecycle(),t.autocapture!==false&&(this.attachClickCapture(),this.captureWebVitals(),this.attachPageviewCapture(),this.attachGlobalErrorHandlers()),this.autoFetch&&(this.attachFetchInstrumentation(),this.attachXhrInstrumentation()),this.sendTelemetry("init","info"));}log(t,e,n){if(this.disabled)return;let r=65536,s=e;e.length>r&&(s=e.slice(0,r-100)+`
|
|
4
4
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';function M(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,a=>{let e=Math.random()*16|0;return (a==="x"?e:e&3|8).toString(16)})}async function _(a,e={}){if(typeof Profiler>"u")return null;let v=a.endpoint,h=a.apiKey,f=M(),P=e.sampleIntervalMs??10,I=e.maxBufferSize??1e4,k=e.chunkIntervalMs??6e4,y=e.profileType??"cpu",t=null,i=false,l=new Date,u=()=>{try{t=new Profiler({sampleInterval:P,maxBufferSize:I}),l=new Date,t.addEventListener("samplebufferfull",()=>{d();});}catch(r){return e.onError?.(r),false}return true},m=async r=>{if(r.samples.length===0)return;let p=[];for(let n of r.stacks){let o=[],s=n;for(;s;)o.push(s.frameId),s=s.parentId!==void 0?r.stacks[s.parentId]:void 0;p.push(o);}let x=r.frames.map(n=>({function:n.name||"(anonymous)",file:n.resourceId!==void 0?`resource:${n.resourceId}`:void 0,line:n.line??void 0})),c=new Map;for(let n of r.samples)c.set(n.stackId,(c.get(n.stackId)??0)+1);let S=Array.from(c.entries()).map(([n,o])=>({stack_id:n,count:o})),g=new Date,w=g.getTime()-l.getTime(),J=JSON.stringify({samples:S,stacks:p,frames:x}),T=new URLSearchParams({profiler_id:f,profile_type:y,sample_count:String(r.samples.length),frame_count:String(x.length),duration_ms:String(Math.round(w)),start_ts:l.toISOString(),end_ts:g.toISOString(),...e.service?{service:e.service}:{},...e.release?{release:e.release}:{},...e.environment?{environment:e.environment}:{}});try{await fetch(`${v}/v1/profiles/chunks?${T}`,{method:"POST",headers:{Authorization:`Bearer ${h}`,"Content-Type":"application/json"},body:J,keepalive:!0});}catch(n){e.onError?.(n);}},d=async()=>{if(!(!t||i)){try{let r=await t.stop();await m(r);}catch(r){e.onError?.(r);}i||u();}};if(!u())return null;let b=setInterval(()=>{d();},k);return {profilerId:f,stop:async()=>{if(!i&&(i=true,clearInterval(b),t))try{let r=await t.stop();await m(r);}catch(r){e.onError?.(r);}}}}exports.startProfiling=_;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { G as GoodLogs } from './client-w3t1Yzjd.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Continuous Profiling — browser JS Self-Profiling API.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* import { startProfiling } from "@aj-2000-test/goodlogs-sdk/profiling";
|
|
8
|
+
* const handle = await startProfiling(gl, { sampleIntervalMs: 10 });
|
|
9
|
+
* // ... later
|
|
10
|
+
* handle.stop();
|
|
11
|
+
*
|
|
12
|
+
* Uses the JS Self-Profiling API (https://wicg.github.io/js-self-profiling/)
|
|
13
|
+
* which ships behind a flag in Chromium 94+. When unavailable, returns null.
|
|
14
|
+
*
|
|
15
|
+
* The profiler runs continuously and ships chunks every `chunkIntervalMs`
|
|
16
|
+
* (default 60s) to POST /v1/profiles/chunks. Chunk format matches the
|
|
17
|
+
* server-side ProfileBlob shape: { samples, stacks, frames }.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
interface ProfilingOptions {
|
|
21
|
+
/** Sample interval in ms (default 10 ≈ 100 Hz). */
|
|
22
|
+
sampleIntervalMs?: number;
|
|
23
|
+
/** Max buffer size in samples before auto-flush (default 10000). */
|
|
24
|
+
maxBufferSize?: number;
|
|
25
|
+
/** Chunk shipping interval ms (default 60000 = 60s). */
|
|
26
|
+
chunkIntervalMs?: number;
|
|
27
|
+
/** Profile type tag (default "cpu"). */
|
|
28
|
+
profileType?: string;
|
|
29
|
+
/** Service name tag. */
|
|
30
|
+
service?: string;
|
|
31
|
+
/** Release tag. */
|
|
32
|
+
release?: string;
|
|
33
|
+
/** Environment tag. */
|
|
34
|
+
environment?: string;
|
|
35
|
+
/** Error callback. */
|
|
36
|
+
onError?: (e: unknown) => void;
|
|
37
|
+
}
|
|
38
|
+
interface ProfilingHandle {
|
|
39
|
+
stop: () => Promise<void>;
|
|
40
|
+
profilerId: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Start continuous profiling. Returns null if JS Self-Profiling API is unavailable.
|
|
44
|
+
*/
|
|
45
|
+
declare function startProfiling(gl: GoodLogs, options?: ProfilingOptions): Promise<ProfilingHandle | null>;
|
|
46
|
+
|
|
47
|
+
export { type ProfilingHandle, type ProfilingOptions, startProfiling };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { G as GoodLogs } from './client-w3t1Yzjd.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Continuous Profiling — browser JS Self-Profiling API.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* import { startProfiling } from "@aj-2000-test/goodlogs-sdk/profiling";
|
|
8
|
+
* const handle = await startProfiling(gl, { sampleIntervalMs: 10 });
|
|
9
|
+
* // ... later
|
|
10
|
+
* handle.stop();
|
|
11
|
+
*
|
|
12
|
+
* Uses the JS Self-Profiling API (https://wicg.github.io/js-self-profiling/)
|
|
13
|
+
* which ships behind a flag in Chromium 94+. When unavailable, returns null.
|
|
14
|
+
*
|
|
15
|
+
* The profiler runs continuously and ships chunks every `chunkIntervalMs`
|
|
16
|
+
* (default 60s) to POST /v1/profiles/chunks. Chunk format matches the
|
|
17
|
+
* server-side ProfileBlob shape: { samples, stacks, frames }.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
interface ProfilingOptions {
|
|
21
|
+
/** Sample interval in ms (default 10 ≈ 100 Hz). */
|
|
22
|
+
sampleIntervalMs?: number;
|
|
23
|
+
/** Max buffer size in samples before auto-flush (default 10000). */
|
|
24
|
+
maxBufferSize?: number;
|
|
25
|
+
/** Chunk shipping interval ms (default 60000 = 60s). */
|
|
26
|
+
chunkIntervalMs?: number;
|
|
27
|
+
/** Profile type tag (default "cpu"). */
|
|
28
|
+
profileType?: string;
|
|
29
|
+
/** Service name tag. */
|
|
30
|
+
service?: string;
|
|
31
|
+
/** Release tag. */
|
|
32
|
+
release?: string;
|
|
33
|
+
/** Environment tag. */
|
|
34
|
+
environment?: string;
|
|
35
|
+
/** Error callback. */
|
|
36
|
+
onError?: (e: unknown) => void;
|
|
37
|
+
}
|
|
38
|
+
interface ProfilingHandle {
|
|
39
|
+
stop: () => Promise<void>;
|
|
40
|
+
profilerId: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Start continuous profiling. Returns null if JS Self-Profiling API is unavailable.
|
|
44
|
+
*/
|
|
45
|
+
declare function startProfiling(gl: GoodLogs, options?: ProfilingOptions): Promise<ProfilingHandle | null>;
|
|
46
|
+
|
|
47
|
+
export { type ProfilingHandle, type ProfilingOptions, startProfiling };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function M(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,a=>{let e=Math.random()*16|0;return (a==="x"?e:e&3|8).toString(16)})}async function _(a,e={}){if(typeof Profiler>"u")return null;let v=a.endpoint,h=a.apiKey,f=M(),P=e.sampleIntervalMs??10,I=e.maxBufferSize??1e4,k=e.chunkIntervalMs??6e4,y=e.profileType??"cpu",t=null,i=false,l=new Date,u=()=>{try{t=new Profiler({sampleInterval:P,maxBufferSize:I}),l=new Date,t.addEventListener("samplebufferfull",()=>{d();});}catch(r){return e.onError?.(r),false}return true},m=async r=>{if(r.samples.length===0)return;let p=[];for(let n of r.stacks){let o=[],s=n;for(;s;)o.push(s.frameId),s=s.parentId!==void 0?r.stacks[s.parentId]:void 0;p.push(o);}let x=r.frames.map(n=>({function:n.name||"(anonymous)",file:n.resourceId!==void 0?`resource:${n.resourceId}`:void 0,line:n.line??void 0})),c=new Map;for(let n of r.samples)c.set(n.stackId,(c.get(n.stackId)??0)+1);let S=Array.from(c.entries()).map(([n,o])=>({stack_id:n,count:o})),g=new Date,w=g.getTime()-l.getTime(),J=JSON.stringify({samples:S,stacks:p,frames:x}),T=new URLSearchParams({profiler_id:f,profile_type:y,sample_count:String(r.samples.length),frame_count:String(x.length),duration_ms:String(Math.round(w)),start_ts:l.toISOString(),end_ts:g.toISOString(),...e.service?{service:e.service}:{},...e.release?{release:e.release}:{},...e.environment?{environment:e.environment}:{}});try{await fetch(`${v}/v1/profiles/chunks?${T}`,{method:"POST",headers:{Authorization:`Bearer ${h}`,"Content-Type":"application/json"},body:J,keepalive:!0});}catch(n){e.onError?.(n);}},d=async()=>{if(!(!t||i)){try{let r=await t.stop();await m(r);}catch(r){e.onError?.(r);}i||u();}};if(!u())return null;let b=setInterval(()=>{d();},k);return {profilerId:f,stop:async()=>{if(!i&&(i=true,clearInterval(b),t))try{let r=await t.stop();await m(r);}catch(r){e.onError?.(r);}}}}export{_ as startProfiling};
|
package/dist/replay.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var S=new Set([1,3,6]);function G(n){return n.every(e=>{if(e.type!==3)return false;let o=e.data?.source;return o!==void 0&&S.has(o)})}var m=null;async function N(n,e={}){if(typeof document>"u")return null;if(m)return m;let o=e.sampleRate??1;if(o<1&&Math.random()>o)return null;let a=e.rrwebRecord??await H();if(!a)return null;let r=n.endpoint,l=n.apiKey,i=n.sessionId,R=n.getDistinctId(),I=e.flushIntervalMs??5e3,E=e.flushBytes??5e5,T=e.sessionTimeoutMs??1800*1e3,B=e.maxSessionMs??3600*1e3,d=[],f=0,C=0,b=false,p=false,g=Date.now(),O=Date.now();u(r,l,{session_id:i,distinct_id:R,start_url:typeof location<"u"?location.href:null,last_url:typeof location<"u"?location.href:null},e.onError);let c=async(t=false)=>{if(d.length===0)return;if(!t&&G(d)){d=[],f=0;return}let s=d,M=s[0].timestamp,_=s[s.length-1].timestamp,P=s.length;d=[],f=0;let $=C++;try{let w=JSON.stringify(s),z=await q(w),U=`${r}/v1/replay/chunks?session_id=${encodeURIComponent(i)}&seq=${$}&start_ts=${encodeURIComponent(new Date(M).toISOString())}&end_ts=${encodeURIComponent(new Date(_).toISOString())}&event_count=${P}`;await fetch(U,{method:"POST",headers:{Authorization:`Bearer ${l}`,"Content-Type":"application/gzip","Content-Encoding":"gzip"},body:z,keepalive:!0});}catch(w){e.onError?.(w);}u(r,l,{session_id:i,last_url:typeof location<"u"?location.href:null,last_activity_at:new Date(_).toISOString(),has_error:b||void 0},e.onError);},x=setInterval(()=>{globalThis.__gl_replay_has_error__&&(b=true);},1e3),v=t=>{if(!p){p=true,clearInterval(A),clearInterval(L),clearInterval(x),document?.removeEventListener("visibilitychange",y),typeof window<"u"&&window.removeEventListener("beforeunload",h);try{D();}catch(s){e.onError?.(s);}c(true),u(r,l,{session_id:i,ended_at:new Date().toISOString()},e.onError),m=null;}},D=a({emit:t=>{if(p)return;t.type===3&&S.has(t.data?.source??-1)||(g=Date.now()),d.push(t),f+=256,f>=E&&c();},checkoutEveryNms:6e4,maskAllInputs:e.maskAllInputs??true,blockSelector:e.blockSelector??"[data-gl-block]",maskTextSelector:e.maskTextSelector??"[data-gl-mask]",sampling:{mousemove:50,mouseInteraction:true,scroll:150,input:"last"}}),A=setInterval(()=>{c();},I),L=setInterval(()=>{let t=Date.now();if(t-g>T){v();return}if(t-O>B){v();return}},1e4),y=()=>{document?.visibilityState==="hidden"&&(c(true),u(r,l,{session_id:i,ended_at:new Date().toISOString()},e.onError));};document.addEventListener("visibilitychange",y);let h=()=>{c(true),u(r,l,{session_id:i,ended_at:new Date().toISOString()},e.onError);};typeof window<"u"&&window.addEventListener("beforeunload",h);let k={sessionId:i,flush:()=>c(true),stop:()=>v()};return m=k,k}async function u(n,e,o,a){try{await fetch(`${n}/v1/replay/sessions`,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(o),keepalive:!0});}catch(r){a?.(r);}}async function q(n){if(typeof CompressionStream>"u"||typeof Blob>"u"||typeof Response>"u")return n;let o=new Blob([n]).stream().pipeThrough(new CompressionStream("gzip")),a=await new Response(o).arrayBuffer();return new Blob([a],{type:"application/gzip"})}async function H(){try{let n=await import('rrweb');return n.record??n.default?.record??null}catch{return null}}exports.startReplay=N;
|
package/dist/replay.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var S=new Set([1,3,6]);function G(n){return n.every(e=>{if(e.type!==3)return false;let o=e.data?.source;return o!==void 0&&S.has(o)})}var m=null;async function N(n,e={}){if(typeof document>"u")return null;if(m)return m;let o=e.sampleRate??1;if(o<1&&Math.random()>o)return null;let a=e.rrwebRecord??await H();if(!a)return null;let r=n.endpoint,l=n.apiKey,i=n.sessionId,R=n.getDistinctId(),I=e.flushIntervalMs??5e3,E=e.flushBytes??5e5,T=e.sessionTimeoutMs??1800*1e3,B=e.maxSessionMs??3600*1e3,d=[],f=0,C=0,b=false,p=false,g=Date.now(),O=Date.now();u(r,l,{session_id:i,distinct_id:R,start_url:typeof location<"u"?location.href:null,last_url:typeof location<"u"?location.href:null},e.onError);let c=async(t=false)=>{if(d.length===0)return;if(!t&&G(d)){d=[],f=0;return}let s=d,M=s[0].timestamp,_=s[s.length-1].timestamp,P=s.length;d=[],f=0;let $=C++;try{let w=JSON.stringify(s),z=await q(w),U=`${r}/v1/replay/chunks?session_id=${encodeURIComponent(i)}&seq=${$}&start_ts=${encodeURIComponent(new Date(M).toISOString())}&end_ts=${encodeURIComponent(new Date(_).toISOString())}&event_count=${P}`;await fetch(U,{method:"POST",headers:{Authorization:`Bearer ${l}`,"Content-Type":"application/gzip","Content-Encoding":"gzip"},body:z,keepalive:!0});}catch(w){e.onError?.(w);}u(r,l,{session_id:i,last_url:typeof location<"u"?location.href:null,last_activity_at:new Date(_).toISOString(),has_error:b||void 0},e.onError);},x=setInterval(()=>{globalThis.__gl_replay_has_error__&&(b=true);},1e3),v=t=>{if(!p){p=true,clearInterval(A),clearInterval(L),clearInterval(x),document?.removeEventListener("visibilitychange",y),typeof window<"u"&&window.removeEventListener("beforeunload",h);try{D();}catch(s){e.onError?.(s);}c(true),u(r,l,{session_id:i,ended_at:new Date().toISOString()},e.onError),m=null;}},D=a({emit:t=>{if(p)return;t.type===3&&S.has(t.data?.source??-1)||(g=Date.now()),d.push(t),f+=256,f>=E&&c();},checkoutEveryNms:6e4,maskAllInputs:e.maskAllInputs??true,blockSelector:e.blockSelector??"[data-gl-block]",maskTextSelector:e.maskTextSelector??"[data-gl-mask]",sampling:{mousemove:50,mouseInteraction:true,scroll:150,input:"last"}}),A=setInterval(()=>{c();},I),L=setInterval(()=>{let t=Date.now();if(t-g>T){v();return}if(t-O>B){v();return}},1e4),y=()=>{document?.visibilityState==="hidden"&&(c(true),u(r,l,{session_id:i,ended_at:new Date().toISOString()},e.onError));};document.addEventListener("visibilitychange",y);let h=()=>{c(true),u(r,l,{session_id:i,ended_at:new Date().toISOString()},e.onError);};typeof window<"u"&&window.addEventListener("beforeunload",h);let k={sessionId:i,flush:()=>c(true),stop:()=>v()};return m=k,k}async function u(n,e,o,a){try{await fetch(`${n}/v1/replay/sessions`,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(o),keepalive:!0});}catch(r){a?.(r);}}async function q(n){if(typeof CompressionStream>"u"||typeof Blob>"u"||typeof Response>"u")return n;let o=new Blob([n]).stream().pipeThrough(new CompressionStream("gzip")),a=await new Response(o).arrayBuffer();return new Blob([a],{type:"application/gzip"})}async function H(){try{let n=await import('rrweb');return n.record??n.default?.record??null}catch{return null}}export{N as startReplay};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aj-2000-test/goodlogs-sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
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",
|
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
"import": "./dist/replay.js",
|
|
17
17
|
"require": "./dist/replay.cjs",
|
|
18
18
|
"types": "./dist/replay.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"./profiling": {
|
|
21
|
+
"import": "./dist/profiling.js",
|
|
22
|
+
"require": "./dist/profiling.cjs",
|
|
23
|
+
"types": "./dist/profiling.d.ts"
|
|
19
24
|
}
|
|
20
25
|
},
|
|
21
26
|
"files": [
|