@aj-2000-test/goodlogs-sdk 0.5.2 → 0.5.3
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/bin/goodlogs.cjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/bin/goodlogs.cjs
CHANGED
|
@@ -18,7 +18,7 @@ const fs = require("fs");
|
|
|
18
18
|
const path = require("path");
|
|
19
19
|
|
|
20
20
|
function parseArgs(argv) {
|
|
21
|
-
const out = { _: [], release: null, apiKey: null, endpoint: "https://api.goodlogs.
|
|
21
|
+
const out = { _: [], release: null, apiKey: null, endpoint: "https://api.goodlogs.dev", verbose: false, deleteAfter: false, dryRun: false, concurrency: 3 };
|
|
22
22
|
for (let i = 2; i < argv.length; i++) {
|
|
23
23
|
const a = argv[i];
|
|
24
24
|
if (a === "--release") out.release = argv[++i];
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var S=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var $={
|
|
1
|
+
'use strict';var S=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var $={eu:"https://api.goodlogs.dev",us:"https://api.goodlogs.dev",ap:"https://api.goodlogs.dev"};function O(i){let e=i.split("_");return e.length>=4&&e[0]==="gl"?e[2]:"eu"}function y(i,e){if(e)return e;let t=O(i);return $[t]||$.eu}var G=5e3,F=50,v="0.5.3",w="gl_anon_id",k="gl_session_id";function b(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{let e=Math.random()*16|0;return (i==="x"?e:e&3|8).toString(16)})}function U(){let i={$goodlogs_sdk:"js",$goodlogs_sdk_version:v};return typeof navigator>"u"||(typeof screen<"u"&&(i.$screen=`${screen.width}x${screen.height}`),typeof navigator<"u"&&(i.$language=navigator.language??""),typeof location<"u"&&(i.$url=location.href,i.$path=location.pathname,i.$page=location.pathname.split("/").filter(Boolean).pop()||"/"),typeof document<"u"&&(document.referrer&&(i.$referrer=document.referrer),document.title&&(i.$title=document.title))),i}function M(i,e){let t={$session_id:i,$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(i,e,t,n,r){let s=M(i,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>",o=r[2]?.replace(/^.*[/\\]/,"")??"",d=r[3];return `${s}@${o}:${d}`}}}catch{}}function X(i){let e=[],t=i;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 i=localStorage.getItem(w);if(i)return i;let e=b();return localStorage.setItem(w,e),e}return b()}function W(){if(typeof sessionStorage<"u"){let i=sessionStorage.getItem(k);if(i)return i;let e=b();return sessionStorage.setItem(k,e),e}return b()}function J(){let i="";for(let e=0;e<32;e++)i+=(Math.random()*16|0).toString(16);return i}function z(){let i="";for(let e=0;e<16;e++)i+=(Math.random()*16|0).toString(16);return i}function Y(i,e){switch(i){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(i){if(!i)return [];let e=[];for(let t of i.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(),o=r[2];e.push({function:s&&s!=="<anonymous>"?s:void 0,filename:o,lineno:Number(r[3]),colno:Number(r[4]),abs_path:o,in_app:!o.includes("node_modules/")&&!o.includes("/dist/")&&!o.startsWith("internal/")});continue}if(r=/^([^@]*)@(.+?):(\d+):(\d+)$/.exec(n),r){let s=r[1]?.trim(),o=r[2];e.push({function:s||void 0,filename:o,lineno:Number(r[3]),colno:Number(r[4]),abs_path:o,in_app:!o.includes("node_modules/")&&!o.includes("/dist/")});}}return e}var R=class R{constructor(e){this.userProperties={};this.originalFetch=null;this.xhrPatched=false;this._debug=false;this.beforeSend=null;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.beforeSend=e.beforeSend??null,this.anonymousId=V(),this.sessionId=W(),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.attachAutoBreadcrumbs()),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.d.cts
CHANGED
|
@@ -318,7 +318,7 @@ interface TelemetryOptions {
|
|
|
318
318
|
*/
|
|
319
319
|
declare function sendTelemetry(event: TelemetryEvent, options?: TelemetryOptions): void;
|
|
320
320
|
|
|
321
|
-
/** Region-to-API URL mapping.
|
|
321
|
+
/** Region-to-API URL mapping. Single EU region — all keys route here. */
|
|
322
322
|
declare const REGION_URLS: Record<string, string>;
|
|
323
323
|
/** Extract region from API key prefix: gl_sk_us_xxx → "us", gl_pk_eu_xxx → "eu" */
|
|
324
324
|
declare function resolveRegion(apiKey: string): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -318,7 +318,7 @@ interface TelemetryOptions {
|
|
|
318
318
|
*/
|
|
319
319
|
declare function sendTelemetry(event: TelemetryEvent, options?: TelemetryOptions): void;
|
|
320
320
|
|
|
321
|
-
/** Region-to-API URL mapping.
|
|
321
|
+
/** Region-to-API URL mapping. Single EU region — all keys route here. */
|
|
322
322
|
declare const REGION_URLS: Record<string, string>;
|
|
323
323
|
/** Extract region from API key prefix: gl_sk_us_xxx → "us", gl_pk_eu_xxx → "eu" */
|
|
324
324
|
declare function resolveRegion(apiKey: string): string;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var S=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var $={
|
|
1
|
+
var S=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var $={eu:"https://api.goodlogs.dev",us:"https://api.goodlogs.dev",ap:"https://api.goodlogs.dev"};function O(i){let e=i.split("_");return e.length>=4&&e[0]==="gl"?e[2]:"eu"}function y(i,e){if(e)return e;let t=O(i);return $[t]||$.eu}var G=5e3,F=50,v="0.5.3",w="gl_anon_id",k="gl_session_id";function b(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{let e=Math.random()*16|0;return (i==="x"?e:e&3|8).toString(16)})}function U(){let i={$goodlogs_sdk:"js",$goodlogs_sdk_version:v};return typeof navigator>"u"||(typeof screen<"u"&&(i.$screen=`${screen.width}x${screen.height}`),typeof navigator<"u"&&(i.$language=navigator.language??""),typeof location<"u"&&(i.$url=location.href,i.$path=location.pathname,i.$page=location.pathname.split("/").filter(Boolean).pop()||"/"),typeof document<"u"&&(document.referrer&&(i.$referrer=document.referrer),document.title&&(i.$title=document.title))),i}function M(i,e){let t={$session_id:i,$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(i,e,t,n,r){let s=M(i,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>",o=r[2]?.replace(/^.*[/\\]/,"")??"",d=r[3];return `${s}@${o}:${d}`}}}catch{}}function X(i){let e=[],t=i;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 i=localStorage.getItem(w);if(i)return i;let e=b();return localStorage.setItem(w,e),e}return b()}function W(){if(typeof sessionStorage<"u"){let i=sessionStorage.getItem(k);if(i)return i;let e=b();return sessionStorage.setItem(k,e),e}return b()}function J(){let i="";for(let e=0;e<32;e++)i+=(Math.random()*16|0).toString(16);return i}function z(){let i="";for(let e=0;e<16;e++)i+=(Math.random()*16|0).toString(16);return i}function Y(i,e){switch(i){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(i){if(!i)return [];let e=[];for(let t of i.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(),o=r[2];e.push({function:s&&s!=="<anonymous>"?s:void 0,filename:o,lineno:Number(r[3]),colno:Number(r[4]),abs_path:o,in_app:!o.includes("node_modules/")&&!o.includes("/dist/")&&!o.startsWith("internal/")});continue}if(r=/^([^@]*)@(.+?):(\d+):(\d+)$/.exec(n),r){let s=r[1]?.trim(),o=r[2];e.push({function:s||void 0,filename:o,lineno:Number(r[3]),colno:Number(r[4]),abs_path:o,in_app:!o.includes("node_modules/")&&!o.includes("/dist/")});}}return e}var R=class R{constructor(e){this.userProperties={};this.originalFetch=null;this.xhrPatched=false;this._debug=false;this.beforeSend=null;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.beforeSend=e.beforeSend??null,this.anonymousId=V(),this.sessionId=W(),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.attachAutoBreadcrumbs()),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
|
|