@glasstrace/sdk 0.7.1 → 0.7.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/dist/{chunk-PLJVIWHN.js → chunk-CKK6VKKC.js} +32 -10
- package/dist/chunk-CKK6VKKC.js.map +1 -0
- package/dist/cli/init.cjs +157 -99
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.d.cts +6 -1
- package/dist/cli/init.d.ts +6 -1
- package/dist/cli/init.js +82 -85
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/mcp-add.cjs +9 -4
- package/dist/cli/mcp-add.cjs.map +1 -1
- package/dist/cli/mcp-add.js +3 -13
- package/dist/cli/mcp-add.js.map +1 -1
- package/dist/index.cjs +27 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +28 -28
- package/dist/index.js.map +1 -1
- package/package.json +1 -6
- package/dist/chunk-PLJVIWHN.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -306,8 +306,12 @@ declare function performInit(config: ResolvedConfig, anonKey: AnonApiKey | null,
|
|
|
306
306
|
/**
|
|
307
307
|
* Returns the current capture config from the three-tier fallback chain:
|
|
308
308
|
* 1. In-memory config from latest init response
|
|
309
|
-
* 2. File cache
|
|
309
|
+
* 2. File cache (read at most once per process lifetime)
|
|
310
310
|
* 3. DEFAULT_CAPTURE_CONFIG
|
|
311
|
+
*
|
|
312
|
+
* The disk read is cached via `configCacheChecked` to avoid repeated
|
|
313
|
+
* synchronous I/O on the hot path (called by GlasstraceExporter on
|
|
314
|
+
* every span export batch).
|
|
311
315
|
*/
|
|
312
316
|
declare function getActiveConfig(): CaptureConfig;
|
|
313
317
|
|
package/dist/index.d.ts
CHANGED
|
@@ -306,8 +306,12 @@ declare function performInit(config: ResolvedConfig, anonKey: AnonApiKey | null,
|
|
|
306
306
|
/**
|
|
307
307
|
* Returns the current capture config from the three-tier fallback chain:
|
|
308
308
|
* 1. In-memory config from latest init response
|
|
309
|
-
* 2. File cache
|
|
309
|
+
* 2. File cache (read at most once per process lifetime)
|
|
310
310
|
* 3. DEFAULT_CAPTURE_CONFIG
|
|
311
|
+
*
|
|
312
|
+
* The disk read is cached via `configCacheChecked` to avoid repeated
|
|
313
|
+
* synchronous I/O on the hot path (called by GlasstraceExporter on
|
|
314
|
+
* every span export batch).
|
|
311
315
|
*/
|
|
312
316
|
declare function getActiveConfig(): CaptureConfig;
|
|
313
317
|
|
package/dist/index.js
CHANGED
|
@@ -193,6 +193,7 @@ var CONFIG_FILE = "config";
|
|
|
193
193
|
var TWENTY_FOUR_HOURS_MS = 24 * 60 * 60 * 1e3;
|
|
194
194
|
var INIT_TIMEOUT_MS = 1e4;
|
|
195
195
|
var currentConfig = null;
|
|
196
|
+
var configCacheChecked = false;
|
|
196
197
|
var rateLimitBackoff = false;
|
|
197
198
|
function loadCachedConfig(projectRoot) {
|
|
198
199
|
const root = projectRoot ?? process.cwd();
|
|
@@ -434,9 +435,13 @@ function getActiveConfig() {
|
|
|
434
435
|
if (currentConfig) {
|
|
435
436
|
return currentConfig.config;
|
|
436
437
|
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
438
|
+
if (!configCacheChecked) {
|
|
439
|
+
configCacheChecked = true;
|
|
440
|
+
const cached = loadCachedConfig();
|
|
441
|
+
if (cached) {
|
|
442
|
+
currentConfig = cached;
|
|
443
|
+
return cached.config;
|
|
444
|
+
}
|
|
440
445
|
}
|
|
441
446
|
return { ...DEFAULT_CAPTURE_CONFIG };
|
|
442
447
|
}
|
|
@@ -3632,15 +3637,7 @@ function registerGlasstrace(options) {
|
|
|
3632
3637
|
() => Promise.resolve(anonKey),
|
|
3633
3638
|
() => sessionManager.getSessionId(getResolvedApiKey())
|
|
3634
3639
|
);
|
|
3635
|
-
|
|
3636
|
-
console.info("[glasstrace] Background init firing.");
|
|
3637
|
-
}
|
|
3638
|
-
const initResult = await performInit(config, anonKey, "0.7.1");
|
|
3639
|
-
if (initResult?.claimResult) {
|
|
3640
|
-
setResolvedApiKey(initResult.claimResult.newApiKey);
|
|
3641
|
-
notifyApiKeyResolved();
|
|
3642
|
-
}
|
|
3643
|
-
maybeInstallConsoleCapture();
|
|
3640
|
+
await backgroundInit(config, anonKey, currentGeneration);
|
|
3644
3641
|
} catch (err) {
|
|
3645
3642
|
console.warn(
|
|
3646
3643
|
`[glasstrace] Background init failed: ${err instanceof Error ? err.message : String(err)}`
|
|
@@ -3656,15 +3653,7 @@ function registerGlasstrace(options) {
|
|
|
3656
3653
|
notifyApiKeyResolved();
|
|
3657
3654
|
effectiveKey = anonKey;
|
|
3658
3655
|
if (currentGeneration !== registrationGeneration) return;
|
|
3659
|
-
|
|
3660
|
-
console.info("[glasstrace] Background init firing.");
|
|
3661
|
-
}
|
|
3662
|
-
const initResult = await performInit(config, anonKey, "0.7.1");
|
|
3663
|
-
if (initResult?.claimResult) {
|
|
3664
|
-
setResolvedApiKey(initResult.claimResult.newApiKey);
|
|
3665
|
-
notifyApiKeyResolved();
|
|
3666
|
-
}
|
|
3667
|
-
maybeInstallConsoleCapture();
|
|
3656
|
+
await backgroundInit(config, anonKey, currentGeneration);
|
|
3668
3657
|
} catch (err) {
|
|
3669
3658
|
console.warn(
|
|
3670
3659
|
`[glasstrace] Background init failed: ${err instanceof Error ? err.message : String(err)}`
|
|
@@ -3682,11 +3671,7 @@ function registerGlasstrace(options) {
|
|
|
3682
3671
|
} catch {
|
|
3683
3672
|
}
|
|
3684
3673
|
if (currentGeneration !== registrationGeneration) return;
|
|
3685
|
-
|
|
3686
|
-
console.info("[glasstrace] Background init firing.");
|
|
3687
|
-
}
|
|
3688
|
-
await performInit(config, anonKeyForInit, "0.7.1");
|
|
3689
|
-
maybeInstallConsoleCapture();
|
|
3674
|
+
await backgroundInit(config, anonKeyForInit, currentGeneration);
|
|
3690
3675
|
} catch (err) {
|
|
3691
3676
|
console.warn(
|
|
3692
3677
|
`[glasstrace] Background init failed: ${err instanceof Error ? err.message : String(err)}`
|
|
@@ -3703,6 +3688,18 @@ function registerGlasstrace(options) {
|
|
|
3703
3688
|
);
|
|
3704
3689
|
}
|
|
3705
3690
|
}
|
|
3691
|
+
async function backgroundInit(config, anonKeyForInit, generation) {
|
|
3692
|
+
if (config.verbose) {
|
|
3693
|
+
console.info("[glasstrace] Background init firing.");
|
|
3694
|
+
}
|
|
3695
|
+
const initResult = await performInit(config, anonKeyForInit, "0.7.3");
|
|
3696
|
+
if (generation !== registrationGeneration) return;
|
|
3697
|
+
if (initResult?.claimResult) {
|
|
3698
|
+
setResolvedApiKey(initResult.claimResult.newApiKey);
|
|
3699
|
+
notifyApiKeyResolved();
|
|
3700
|
+
}
|
|
3701
|
+
maybeInstallConsoleCapture();
|
|
3702
|
+
}
|
|
3706
3703
|
function getDiscoveryHandler() {
|
|
3707
3704
|
return discoveryHandler;
|
|
3708
3705
|
}
|
|
@@ -3726,7 +3723,7 @@ function isDiscoveryEnabled(config) {
|
|
|
3726
3723
|
import * as fs2 from "fs/promises";
|
|
3727
3724
|
import * as path2 from "path";
|
|
3728
3725
|
import * as crypto from "crypto";
|
|
3729
|
-
import {
|
|
3726
|
+
import { execFileSync } from "child_process";
|
|
3730
3727
|
async function collectSourceMaps(buildDir) {
|
|
3731
3728
|
const results = [];
|
|
3732
3729
|
try {
|
|
@@ -3760,7 +3757,7 @@ async function walkDir(baseDir, currentDir, results) {
|
|
|
3760
3757
|
}
|
|
3761
3758
|
async function computeBuildHash(maps) {
|
|
3762
3759
|
try {
|
|
3763
|
-
const sha =
|
|
3760
|
+
const sha = execFileSync("git", ["rev-parse", "HEAD"], { encoding: "utf-8" }).trim();
|
|
3764
3761
|
if (sha) {
|
|
3765
3762
|
return sha;
|
|
3766
3763
|
}
|
|
@@ -4062,6 +4059,9 @@ function captureError(error) {
|
|
|
4062
4059
|
};
|
|
4063
4060
|
if (error instanceof Error) {
|
|
4064
4061
|
attributes["error.type"] = error.constructor.name;
|
|
4062
|
+
if (error.stack) {
|
|
4063
|
+
attributes["error.stack"] = error.stack;
|
|
4064
|
+
}
|
|
4065
4065
|
}
|
|
4066
4066
|
span.addEvent("glasstrace.error", attributes);
|
|
4067
4067
|
maybeShowMcpNudge(String(error));
|