@aj-2000-test/goodlogs-sdk 0.3.8 → 0.4.0

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';Object.defineProperty(exports,'__esModule',{value:true});function d(c){return /^[A-Z]/.test(c)}function p(c){let{types:e}=c;return {name:"goodlogs-component-profiler",visitor:{Program:{enter(f,u){let a=u.filename||"",l=u.opts||{};if(a.includes("node_modules"))return;let g=f.hub?.file?.code??"";if(g.includes("withProfiler")||g.includes("GoodLogsProfiler")||l.exclude?.some(r=>new RegExp(r).test(a))||l.include&&!l.include.some(r=>new RegExp(r).test(a))||!/\.[jt]sx$/.test(a))return;let m=l.importSource??"@aj-2000-test/goodlogs-sdk/react",s=false,t=new Set;if(f.traverse({ExportDefaultDeclaration(r){let i=r.node.declaration;if(e.isFunctionDeclaration(i)&&i.id&&d(i.id.name)){let n=i.id.name,o=e.cloneNode(i);r.insertBefore(o),r.node.declaration=e.callExpression(e.identifier("__goodlogs_withProfiler"),[e.identifier(n),e.stringLiteral(n)]),s=true,t.add(n);}e.isIdentifier(i)&&d(i.name)&&!t.has(i.name)&&(r.node.declaration=e.callExpression(e.identifier("__goodlogs_withProfiler"),[e.identifier(i.name),e.stringLiteral(i.name)]),s=true,t.add(i.name));},ExportNamedDeclaration(r){let i=r.node.declaration;if(i){if(e.isFunctionDeclaration(i)&&i.id&&d(i.id.name)){let n=i.id.name,o=e.cloneNode(i);o.id=e.identifier(`_${n}_unwrapped`),r.insertBefore(o),r.replaceWith(e.exportNamedDeclaration(e.variableDeclaration("const",[e.variableDeclarator(e.identifier(n),e.callExpression(e.identifier("__goodlogs_withProfiler"),[e.identifier(`_${n}_unwrapped`),e.stringLiteral(n)]))]))),s=true,t.add(n);}if(e.isVariableDeclaration(i)){for(let n of i.declarations)if(e.isIdentifier(n.id)&&d(n.id.name)&&(e.isArrowFunctionExpression(n.init)||e.isFunctionExpression(n.init))&&!t.has(n.id.name)){let o=n.id.name;n.init=e.callExpression(e.identifier("__goodlogs_withProfiler"),[n.init,e.stringLiteral(o)]),s=true,t.add(o);}}}}}),s){let r=e.importDeclaration([e.importSpecifier(e.identifier("__goodlogs_withProfiler"),e.identifier("withProfiler"))],e.stringLiteral(m));f.unshiftContainer("body",r);}}}}}}var _=p;exports.default=_;exports.goodlogsComponentProfilerPlugin=p;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Babel Plugin: Auto-wrap React components with GoodLogs profiling.
3
+ *
4
+ * Similar to Sentry's @sentry/babel-plugin-component-annotate, this plugin
5
+ * automatically injects `withProfiler()` around exported React components
6
+ * at build time — no manual wrapping needed.
7
+ *
8
+ * Usage in babel.config.js:
9
+ * plugins: [["@aj-2000-test/goodlogs-sdk/babel-plugin"]]
10
+ *
11
+ * Usage in next.config.mjs (experimental):
12
+ * experimental: {
13
+ * babel: { plugins: [["@aj-2000-test/goodlogs-sdk/babel-plugin"]] }
14
+ * }
15
+ *
16
+ * What it does:
17
+ * 1. Detects exported function/arrow components (name starts with uppercase)
18
+ * 2. Injects `import { withProfiler } from "@aj-2000-test/goodlogs-sdk/react"`
19
+ * 3. Wraps the default export: `export default withProfiler(MyComponent, "MyComponent")`
20
+ * 4. Wraps named exports: `export const Foo = withProfiler(_Foo, "Foo")`
21
+ *
22
+ * Skipped:
23
+ * - Non-component exports (lowercase names, non-function)
24
+ * - Files in node_modules
25
+ * - Files that already import withProfiler/GoodLogsProfiler
26
+ */
27
+ type BabelAPI = any;
28
+ declare function goodlogsComponentProfilerPlugin(babel: BabelAPI): unknown;
29
+
30
+ export { goodlogsComponentProfilerPlugin as default, goodlogsComponentProfilerPlugin };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Babel Plugin: Auto-wrap React components with GoodLogs profiling.
3
+ *
4
+ * Similar to Sentry's @sentry/babel-plugin-component-annotate, this plugin
5
+ * automatically injects `withProfiler()` around exported React components
6
+ * at build time — no manual wrapping needed.
7
+ *
8
+ * Usage in babel.config.js:
9
+ * plugins: [["@aj-2000-test/goodlogs-sdk/babel-plugin"]]
10
+ *
11
+ * Usage in next.config.mjs (experimental):
12
+ * experimental: {
13
+ * babel: { plugins: [["@aj-2000-test/goodlogs-sdk/babel-plugin"]] }
14
+ * }
15
+ *
16
+ * What it does:
17
+ * 1. Detects exported function/arrow components (name starts with uppercase)
18
+ * 2. Injects `import { withProfiler } from "@aj-2000-test/goodlogs-sdk/react"`
19
+ * 3. Wraps the default export: `export default withProfiler(MyComponent, "MyComponent")`
20
+ * 4. Wraps named exports: `export const Foo = withProfiler(_Foo, "Foo")`
21
+ *
22
+ * Skipped:
23
+ * - Non-component exports (lowercase names, non-function)
24
+ * - Files in node_modules
25
+ * - Files that already import withProfiler/GoodLogsProfiler
26
+ */
27
+ type BabelAPI = any;
28
+ declare function goodlogsComponentProfilerPlugin(babel: BabelAPI): unknown;
29
+
30
+ export { goodlogsComponentProfilerPlugin as default, goodlogsComponentProfilerPlugin };
@@ -0,0 +1 @@
1
+ function d(c){return /^[A-Z]/.test(c)}function p(c){let{types:e}=c;return {name:"goodlogs-component-profiler",visitor:{Program:{enter(f,u){let a=u.filename||"",l=u.opts||{};if(a.includes("node_modules"))return;let g=f.hub?.file?.code??"";if(g.includes("withProfiler")||g.includes("GoodLogsProfiler")||l.exclude?.some(r=>new RegExp(r).test(a))||l.include&&!l.include.some(r=>new RegExp(r).test(a))||!/\.[jt]sx$/.test(a))return;let m=l.importSource??"@aj-2000-test/goodlogs-sdk/react",s=false,t=new Set;if(f.traverse({ExportDefaultDeclaration(r){let i=r.node.declaration;if(e.isFunctionDeclaration(i)&&i.id&&d(i.id.name)){let n=i.id.name,o=e.cloneNode(i);r.insertBefore(o),r.node.declaration=e.callExpression(e.identifier("__goodlogs_withProfiler"),[e.identifier(n),e.stringLiteral(n)]),s=true,t.add(n);}e.isIdentifier(i)&&d(i.name)&&!t.has(i.name)&&(r.node.declaration=e.callExpression(e.identifier("__goodlogs_withProfiler"),[e.identifier(i.name),e.stringLiteral(i.name)]),s=true,t.add(i.name));},ExportNamedDeclaration(r){let i=r.node.declaration;if(i){if(e.isFunctionDeclaration(i)&&i.id&&d(i.id.name)){let n=i.id.name,o=e.cloneNode(i);o.id=e.identifier(`_${n}_unwrapped`),r.insertBefore(o),r.replaceWith(e.exportNamedDeclaration(e.variableDeclaration("const",[e.variableDeclarator(e.identifier(n),e.callExpression(e.identifier("__goodlogs_withProfiler"),[e.identifier(`_${n}_unwrapped`),e.stringLiteral(n)]))]))),s=true,t.add(n);}if(e.isVariableDeclaration(i)){for(let n of i.declarations)if(e.isIdentifier(n.id)&&d(n.id.name)&&(e.isArrowFunctionExpression(n.init)||e.isFunctionExpression(n.init))&&!t.has(n.id.name)){let o=n.id.name;n.init=e.callExpression(e.identifier("__goodlogs_withProfiler"),[n.init,e.stringLiteral(o)]),s=true,t.add(o);}}}}}),s){let r=e.importDeclaration([e.importSpecifier(e.identifier("__goodlogs_withProfiler"),e.identifier("withProfiler"))],e.stringLiteral(m));f.unshiftContainer("body",r);}}}}}}var _=p;export{_ as default,p as goodlogsComponentProfilerPlugin};
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.8",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(`
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.4.0",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.8",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(`
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.4.0",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
 
@@ -1 +1 @@
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=_;
1
+ 'use strict';function M(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{let n=Math.random()*16|0;return (s==="x"?n:n&3|8).toString(16)})}async function _(s,n={}){if(typeof Profiler>"u")return null;let y=s.endpoint,b=s.apiKey,u=M(),I=n.sampleIntervalMs??10,k=n.maxBufferSize??1e4,P=n.chunkIntervalMs??1e4,w=n.profileType??"cpu",t=null,o=false,l=new Date,f=()=>{try{t=new Profiler({sampleInterval:I,maxBufferSize:k}),l=new Date,t.addEventListener("samplebufferfull",()=>{a();});}catch(e){return n.onError?.(e),false}return true},m=async e=>{if(e.samples.length===0)return;let g=[];for(let r of e.stacks){let d=[],i=r;for(;i;)d.push(i.frameId),i=i.parentId!==void 0?e.stacks[i.parentId]:void 0;g.push(d);}let x=e.frames.map(r=>({function:r.name||"(anonymous)",file:r.resourceId!==void 0?e.resources[r.resourceId]??`resource:${r.resourceId}`:void 0,line:r.line??void 0,column:r.column??void 0})),c=new Map;for(let r of e.samples)r.stackId!=null&&(r.stackId===0&&e.stacks.length>0&&e.stacks[0].parentId===void 0&&e.stacks[0].frameId===0||c.set(r.stackId,(c.get(r.stackId)??0)+1));let E=Array.from(c.entries()).map(([r,d])=>({stack_id:r,count:d})),h=new Date,J=h.getTime()-l.getTime(),L=JSON.stringify({samples:E,stacks:g,frames:x}),T=new URLSearchParams({profiler_id:u,profile_type:w,sample_count:String(e.samples.length),frame_count:String(x.length),duration_ms:String(Math.round(J)),start_ts:l.toISOString(),end_ts:h.toISOString(),...n.service?{service:n.service}:{},...n.release?{release:n.release}:{},...n.environment?{environment:n.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){n.onError?.(r);}},a=async()=>{if(!(!t||o)){try{let e=await t.stop();await m(e);}catch(e){n.onError?.(e);}o||f();}};if(!f())return null;let S=setInterval(()=>{a();},P),p=()=>{document?.visibilityState==="hidden"&&a();},v=()=>{a();};return typeof document<"u"&&document.addEventListener("visibilitychange",p),typeof window<"u"&&window.addEventListener("beforeunload",v),{profilerId:u,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 e=await t.stop();await m(e);}catch(e){n.onError?.(e);}}}}exports.startProfiling=_;
package/dist/profiling.js CHANGED
@@ -1 +1 @@
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};
1
+ function M(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{let n=Math.random()*16|0;return (s==="x"?n:n&3|8).toString(16)})}async function _(s,n={}){if(typeof Profiler>"u")return null;let y=s.endpoint,b=s.apiKey,u=M(),I=n.sampleIntervalMs??10,k=n.maxBufferSize??1e4,P=n.chunkIntervalMs??1e4,w=n.profileType??"cpu",t=null,o=false,l=new Date,f=()=>{try{t=new Profiler({sampleInterval:I,maxBufferSize:k}),l=new Date,t.addEventListener("samplebufferfull",()=>{a();});}catch(e){return n.onError?.(e),false}return true},m=async e=>{if(e.samples.length===0)return;let g=[];for(let r of e.stacks){let d=[],i=r;for(;i;)d.push(i.frameId),i=i.parentId!==void 0?e.stacks[i.parentId]:void 0;g.push(d);}let x=e.frames.map(r=>({function:r.name||"(anonymous)",file:r.resourceId!==void 0?e.resources[r.resourceId]??`resource:${r.resourceId}`:void 0,line:r.line??void 0,column:r.column??void 0})),c=new Map;for(let r of e.samples)r.stackId!=null&&(r.stackId===0&&e.stacks.length>0&&e.stacks[0].parentId===void 0&&e.stacks[0].frameId===0||c.set(r.stackId,(c.get(r.stackId)??0)+1));let E=Array.from(c.entries()).map(([r,d])=>({stack_id:r,count:d})),h=new Date,J=h.getTime()-l.getTime(),L=JSON.stringify({samples:E,stacks:g,frames:x}),T=new URLSearchParams({profiler_id:u,profile_type:w,sample_count:String(e.samples.length),frame_count:String(x.length),duration_ms:String(Math.round(J)),start_ts:l.toISOString(),end_ts:h.toISOString(),...n.service?{service:n.service}:{},...n.release?{release:n.release}:{},...n.environment?{environment:n.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){n.onError?.(r);}},a=async()=>{if(!(!t||o)){try{let e=await t.stop();await m(e);}catch(e){n.onError?.(e);}o||f();}};if(!f())return null;let S=setInterval(()=>{a();},P),p=()=>{document?.visibilityState==="hidden"&&a();},v=()=>{a();};return typeof document<"u"&&document.addEventListener("visibilitychange",p),typeof window<"u"&&window.addEventListener("beforeunload",v),{profilerId:u,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 e=await t.stop();await m(e);}catch(e){n.onError?.(e);}}}}export{_ as startProfiling};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aj-2000-test/goodlogs-sdk",
3
- "version": "0.3.8",
3
+ "version": "0.4.0",
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",
@@ -26,6 +26,11 @@
26
26
  "import": "./dist/react.js",
27
27
  "require": "./dist/react.cjs",
28
28
  "types": "./dist/react.d.ts"
29
+ },
30
+ "./babel-plugin": {
31
+ "import": "./dist/babel-plugin.js",
32
+ "require": "./dist/babel-plugin.cjs",
33
+ "types": "./dist/babel-plugin.d.ts"
29
34
  }
30
35
  },
31
36
  "files": [