@aj-2000-test/goodlogs-sdk 0.3.5 → 0.3.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.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/profiling.cjs +1 -1
- package/dist/profiling.d.cts +1 -1
- package/dist/profiling.d.ts +1 -1
- package/dist/profiling.js +1 -1
- package/dist/react.cjs +1 -0
- package/dist/react.d.cts +52 -0
- package/dist/react.d.ts +52 -0
- package/dist/react.js +1 -0
- package/package.json +12 -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.7",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.7",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/profiling.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';function M(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,
|
|
1
|
+
'use strict';function M(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{let e=Math.random()*16|0;return (s==="x"?e:e&3|8).toString(16)})}async function _(s,e={}){if(typeof Profiler>"u")return null;let y=s.endpoint,b=s.apiKey,f=M(),P=e.sampleIntervalMs??10,w=e.maxBufferSize??1e4,I=e.chunkIntervalMs??1e4,k=e.profileType??"cpu",t=null,o=false,d=new Date,u=()=>{try{t=new Profiler({sampleInterval:P,maxBufferSize:w}),d=new Date,t.addEventListener("samplebufferfull",()=>{a();});}catch(n){return e.onError?.(n),false}return true},m=async n=>{if(n.samples.length===0)return;let g=[];for(let r of n.stacks){let l=[],i=r;for(;i;)l.push(i.frameId),i=i.parentId!==void 0?n.stacks[i.parentId]:void 0;g.push(l);}let x=n.frames.map(r=>({function:r.name||"(anonymous)",file:r.resourceId!==void 0?`resource:${r.resourceId}`:void 0,line:r.line??void 0})),c=new Map;for(let r of n.samples)c.set(r.stackId,(c.get(r.stackId)??0)+1);let E=Array.from(c.entries()).map(([r,l])=>({stack_id:r,count:l})),h=new Date,J=h.getTime()-d.getTime(),L=JSON.stringify({samples:E,stacks:g,frames:x}),T=new URLSearchParams({profiler_id:f,profile_type:k,sample_count:String(n.samples.length),frame_count:String(x.length),duration_ms:String(Math.round(J)),start_ts:d.toISOString(),end_ts:h.toISOString(),...e.service?{service:e.service}:{},...e.release?{release:e.release}:{},...e.environment?{environment:e.environment}:{}});try{await fetch(`${y}/v1/profiles/chunks?${T}`,{method:"POST",headers:{Authorization:`Bearer ${b}`,"Content-Type":"application/json"},body:L,keepalive:!0});}catch(r){e.onError?.(r);}},a=async()=>{if(!(!t||o)){try{let n=await t.stop();await m(n);}catch(n){e.onError?.(n);}o||u();}};if(!u())return null;let S=setInterval(()=>{a();},I),p=()=>{document?.visibilityState==="hidden"&&a();},v=()=>{a();};return typeof document<"u"&&document.addEventListener("visibilitychange",p),typeof window<"u"&&window.addEventListener("beforeunload",v),{profilerId:f,stop:async()=>{if(!o&&(o=true,clearInterval(S),typeof document<"u"&&document.removeEventListener("visibilitychange",p),typeof window<"u"&&window.removeEventListener("beforeunload",v),t))try{let n=await t.stop();await m(n);}catch(n){e.onError?.(n);}}}}exports.startProfiling=_;
|
package/dist/profiling.d.cts
CHANGED
|
@@ -22,7 +22,7 @@ interface ProfilingOptions {
|
|
|
22
22
|
sampleIntervalMs?: number;
|
|
23
23
|
/** Max buffer size in samples before auto-flush (default 10000). */
|
|
24
24
|
maxBufferSize?: number;
|
|
25
|
-
/** Chunk shipping interval ms (default
|
|
25
|
+
/** Chunk shipping interval ms (default 10000 = 10s for browser). */
|
|
26
26
|
chunkIntervalMs?: number;
|
|
27
27
|
/** Profile type tag (default "cpu"). */
|
|
28
28
|
profileType?: string;
|
package/dist/profiling.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ interface ProfilingOptions {
|
|
|
22
22
|
sampleIntervalMs?: number;
|
|
23
23
|
/** Max buffer size in samples before auto-flush (default 10000). */
|
|
24
24
|
maxBufferSize?: number;
|
|
25
|
-
/** Chunk shipping interval ms (default
|
|
25
|
+
/** Chunk shipping interval ms (default 10000 = 10s for browser). */
|
|
26
26
|
chunkIntervalMs?: number;
|
|
27
27
|
/** Profile type tag (default "cpu"). */
|
|
28
28
|
profileType?: string;
|
package/dist/profiling.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function M(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,
|
|
1
|
+
function M(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{let e=Math.random()*16|0;return (s==="x"?e:e&3|8).toString(16)})}async function _(s,e={}){if(typeof Profiler>"u")return null;let y=s.endpoint,b=s.apiKey,f=M(),P=e.sampleIntervalMs??10,w=e.maxBufferSize??1e4,I=e.chunkIntervalMs??1e4,k=e.profileType??"cpu",t=null,o=false,d=new Date,u=()=>{try{t=new Profiler({sampleInterval:P,maxBufferSize:w}),d=new Date,t.addEventListener("samplebufferfull",()=>{a();});}catch(n){return e.onError?.(n),false}return true},m=async n=>{if(n.samples.length===0)return;let g=[];for(let r of n.stacks){let l=[],i=r;for(;i;)l.push(i.frameId),i=i.parentId!==void 0?n.stacks[i.parentId]:void 0;g.push(l);}let x=n.frames.map(r=>({function:r.name||"(anonymous)",file:r.resourceId!==void 0?`resource:${r.resourceId}`:void 0,line:r.line??void 0})),c=new Map;for(let r of n.samples)c.set(r.stackId,(c.get(r.stackId)??0)+1);let E=Array.from(c.entries()).map(([r,l])=>({stack_id:r,count:l})),h=new Date,J=h.getTime()-d.getTime(),L=JSON.stringify({samples:E,stacks:g,frames:x}),T=new URLSearchParams({profiler_id:f,profile_type:k,sample_count:String(n.samples.length),frame_count:String(x.length),duration_ms:String(Math.round(J)),start_ts:d.toISOString(),end_ts:h.toISOString(),...e.service?{service:e.service}:{},...e.release?{release:e.release}:{},...e.environment?{environment:e.environment}:{}});try{await fetch(`${y}/v1/profiles/chunks?${T}`,{method:"POST",headers:{Authorization:`Bearer ${b}`,"Content-Type":"application/json"},body:L,keepalive:!0});}catch(r){e.onError?.(r);}},a=async()=>{if(!(!t||o)){try{let n=await t.stop();await m(n);}catch(n){e.onError?.(n);}o||u();}};if(!u())return null;let S=setInterval(()=>{a();},I),p=()=>{document?.visibilityState==="hidden"&&a();},v=()=>{a();};return typeof document<"u"&&document.addEventListener("visibilitychange",p),typeof window<"u"&&window.addEventListener("beforeunload",v),{profilerId:f,stop:async()=>{if(!o&&(o=true,clearInterval(S),typeof document<"u"&&document.removeEventListener("visibilitychange",p),typeof window<"u"&&window.removeEventListener("beforeunload",v),t))try{let n=await t.stop();await m(n);}catch(n){e.onError?.(n);}}}}export{_ as startProfiling};
|
package/dist/react.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var react=require('react');var r=null,i=[],l=null,p=3e3,g=200,h=1;function c(){l||(l=setInterval(d,p),typeof window<"u"&&window.addEventListener("beforeunload",()=>d()));}function d(){if(!r||i.length===0)return;let e=i;i=[];let t=r.endpoint,n=r.apiKey;try{fetch(`${t}/v1/profiles/renders`,{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify({batch:e}),keepalive:!0}).catch(()=>{});}catch{}}function y(){return typeof window>"u"?null:window.location?.pathname??null}function m(e){return (t,n,o,s,b,f)=>{o<h||(i.push({component:e||t,phase:n,actual_ms:Math.round(o*100)/100,base_ms:Math.round(s*100)/100,commit_time:Math.round(f*100)/100,route:y(),timestamp:new Date().toISOString()}),i.length>=g&&d());}}function R(e){r=e,c();}function P({gl:e,id:t,children:n}){return e&&!r&&(r=e,c()),react.createElement(react.Profiler,{id:t,onRender:m(t)},n)}function _(e,t){let n=t||e.displayName||e.name||"Unknown",o=s=>react.createElement(react.Profiler,{id:n,onRender:m(n)},react.createElement(e,s));return o.displayName=`withProfiler(${n})`,o}exports.GoodLogsProfiler=P;exports.initReactProfiler=R;exports.withProfiler=_;
|
package/dist/react.d.cts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ReactNode, ComponentType, FC } from 'react';
|
|
2
|
+
import { G as GoodLogs } from './client-w3t1Yzjd.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* React Profiler Integration — component render timing.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* import { GoodLogsProfiler, withProfiler } from "@aj-2000-test/goodlogs-sdk/react"
|
|
9
|
+
*
|
|
10
|
+
* // Option 1: Wrap individual components
|
|
11
|
+
* const ProfiledApp = withProfiler(App, "App")
|
|
12
|
+
*
|
|
13
|
+
* // Option 2: Use the Profiler component directly
|
|
14
|
+
* <GoodLogsProfiler gl={gl} id="Checkout">
|
|
15
|
+
* <CheckoutForm />
|
|
16
|
+
* </GoodLogsProfiler>
|
|
17
|
+
*
|
|
18
|
+
* Works in ALL browsers, ALL React versions 16.5+, in production builds.
|
|
19
|
+
* Captures component render times (actual + base), phase (mount/update),
|
|
20
|
+
* and ships them to POST /v1/profiles/renders.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Initialize the React profiler with a GoodLogs instance.
|
|
25
|
+
* Call once at app startup before rendering any profiled components.
|
|
26
|
+
*/
|
|
27
|
+
declare function initReactProfiler(gl: GoodLogs): void;
|
|
28
|
+
/**
|
|
29
|
+
* React Profiler wrapper component. Wraps children in React.Profiler
|
|
30
|
+
* and reports render timings to GoodLogs.
|
|
31
|
+
*
|
|
32
|
+
* ```tsx
|
|
33
|
+
* <GoodLogsProfiler gl={gl} id="Checkout">
|
|
34
|
+
* <CheckoutForm />
|
|
35
|
+
* </GoodLogsProfiler>
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
declare function GoodLogsProfiler({ gl, id, children, }: {
|
|
39
|
+
gl?: GoodLogs;
|
|
40
|
+
id: string;
|
|
41
|
+
children: ReactNode;
|
|
42
|
+
}): ReactNode;
|
|
43
|
+
/**
|
|
44
|
+
* HOC: wraps a component with React.Profiler.
|
|
45
|
+
*
|
|
46
|
+
* ```tsx
|
|
47
|
+
* const ProfiledApp = withProfiler(App, "App")
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
declare function withProfiler<P extends Record<string, unknown>>(Component: ComponentType<P>, displayName?: string): FC<P>;
|
|
51
|
+
|
|
52
|
+
export { GoodLogsProfiler, initReactProfiler, withProfiler };
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ReactNode, ComponentType, FC } from 'react';
|
|
2
|
+
import { G as GoodLogs } from './client-w3t1Yzjd.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* React Profiler Integration — component render timing.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* import { GoodLogsProfiler, withProfiler } from "@aj-2000-test/goodlogs-sdk/react"
|
|
9
|
+
*
|
|
10
|
+
* // Option 1: Wrap individual components
|
|
11
|
+
* const ProfiledApp = withProfiler(App, "App")
|
|
12
|
+
*
|
|
13
|
+
* // Option 2: Use the Profiler component directly
|
|
14
|
+
* <GoodLogsProfiler gl={gl} id="Checkout">
|
|
15
|
+
* <CheckoutForm />
|
|
16
|
+
* </GoodLogsProfiler>
|
|
17
|
+
*
|
|
18
|
+
* Works in ALL browsers, ALL React versions 16.5+, in production builds.
|
|
19
|
+
* Captures component render times (actual + base), phase (mount/update),
|
|
20
|
+
* and ships them to POST /v1/profiles/renders.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Initialize the React profiler with a GoodLogs instance.
|
|
25
|
+
* Call once at app startup before rendering any profiled components.
|
|
26
|
+
*/
|
|
27
|
+
declare function initReactProfiler(gl: GoodLogs): void;
|
|
28
|
+
/**
|
|
29
|
+
* React Profiler wrapper component. Wraps children in React.Profiler
|
|
30
|
+
* and reports render timings to GoodLogs.
|
|
31
|
+
*
|
|
32
|
+
* ```tsx
|
|
33
|
+
* <GoodLogsProfiler gl={gl} id="Checkout">
|
|
34
|
+
* <CheckoutForm />
|
|
35
|
+
* </GoodLogsProfiler>
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
declare function GoodLogsProfiler({ gl, id, children, }: {
|
|
39
|
+
gl?: GoodLogs;
|
|
40
|
+
id: string;
|
|
41
|
+
children: ReactNode;
|
|
42
|
+
}): ReactNode;
|
|
43
|
+
/**
|
|
44
|
+
* HOC: wraps a component with React.Profiler.
|
|
45
|
+
*
|
|
46
|
+
* ```tsx
|
|
47
|
+
* const ProfiledApp = withProfiler(App, "App")
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
declare function withProfiler<P extends Record<string, unknown>>(Component: ComponentType<P>, displayName?: string): FC<P>;
|
|
51
|
+
|
|
52
|
+
export { GoodLogsProfiler, initReactProfiler, withProfiler };
|
package/dist/react.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {createElement,Profiler}from'react';var r=null,i=[],l=null,p=3e3,g=200,h=1;function c(){l||(l=setInterval(d,p),typeof window<"u"&&window.addEventListener("beforeunload",()=>d()));}function d(){if(!r||i.length===0)return;let e=i;i=[];let t=r.endpoint,n=r.apiKey;try{fetch(`${t}/v1/profiles/renders`,{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify({batch:e}),keepalive:!0}).catch(()=>{});}catch{}}function y(){return typeof window>"u"?null:window.location?.pathname??null}function m(e){return (t,n,o,s,b,f)=>{o<h||(i.push({component:e||t,phase:n,actual_ms:Math.round(o*100)/100,base_ms:Math.round(s*100)/100,commit_time:Math.round(f*100)/100,route:y(),timestamp:new Date().toISOString()}),i.length>=g&&d());}}function R(e){r=e,c();}function P({gl:e,id:t,children:n}){return e&&!r&&(r=e,c()),createElement(Profiler,{id:t,onRender:m(t)},n)}function _(e,t){let n=t||e.displayName||e.name||"Unknown",o=s=>createElement(Profiler,{id:n,onRender:m(n)},createElement(e,s));return o.displayName=`withProfiler(${n})`,o}export{P as GoodLogsProfiler,R as initReactProfiler,_ as withProfiler};
|
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.7",
|
|
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",
|
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
"import": "./dist/profiling.js",
|
|
22
22
|
"require": "./dist/profiling.cjs",
|
|
23
23
|
"types": "./dist/profiling.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"./react": {
|
|
26
|
+
"import": "./dist/react.js",
|
|
27
|
+
"require": "./dist/react.cjs",
|
|
28
|
+
"types": "./dist/react.d.ts"
|
|
24
29
|
}
|
|
25
30
|
},
|
|
26
31
|
"files": [
|
|
@@ -47,17 +52,23 @@
|
|
|
47
52
|
],
|
|
48
53
|
"license": "MIT",
|
|
49
54
|
"devDependencies": {
|
|
55
|
+
"@types/react": "^19.2.15",
|
|
56
|
+
"react": "^19.2.6",
|
|
50
57
|
"rrweb": "2.0.0-alpha.18",
|
|
51
58
|
"tsup": "^8.0.0",
|
|
52
59
|
"typescript": "^5.5.0",
|
|
53
60
|
"vitest": "^2.0.0"
|
|
54
61
|
},
|
|
55
62
|
"peerDependencies": {
|
|
63
|
+
"react": "^16.5.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
56
64
|
"rrweb": "^2.0.0-alpha.18"
|
|
57
65
|
},
|
|
58
66
|
"peerDependenciesMeta": {
|
|
59
67
|
"rrweb": {
|
|
60
68
|
"optional": true
|
|
69
|
+
},
|
|
70
|
+
"react": {
|
|
71
|
+
"optional": true
|
|
61
72
|
}
|
|
62
73
|
}
|
|
63
74
|
}
|