@glasstrace/sdk 1.2.1 → 1.3.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.
- package/README.md +47 -0
- package/dist/{chunk-HV5ID2WJ.js → chunk-A63WX7NR.js} +3 -3
- package/dist/{chunk-2GCN27SI.js → chunk-AGCYKZFY.js} +2 -2
- package/dist/{chunk-47B2G3FE.js → chunk-AKZGMT33.js} +2 -2
- package/dist/{chunk-MD5XPCTQ.js → chunk-AYUL5QMZ.js} +2 -2
- package/dist/{chunk-YMLMZCPR.js → chunk-FMEWG3FY.js} +2 -2
- package/dist/{chunk-NFPDYME5.js → chunk-FVHVDBGX.js} +3 -3
- package/dist/{chunk-EBYISKQP.js → chunk-GTPTKN5A.js} +2 -1
- package/dist/{chunk-EBYISKQP.js.map → chunk-GTPTKN5A.js.map} +1 -1
- package/dist/{chunk-CTJO7PUZ.js → chunk-JMYKR5Z3.js} +75 -9
- package/dist/chunk-JMYKR5Z3.js.map +1 -0
- package/dist/cli/init.cjs +1 -1
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.js +6 -6
- package/dist/cli/mcp-add.cjs.map +1 -1
- package/dist/cli/mcp-add.js +2 -2
- package/dist/cli/uninit.js +3 -3
- package/dist/cli/validate.cjs.map +1 -1
- package/dist/cli/validate.js +2 -2
- package/dist/edge-entry.cjs +1 -0
- package/dist/edge-entry.cjs.map +1 -1
- package/dist/edge-entry.js +2 -2
- package/dist/index.cjs +74 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -5
- package/dist/node-entry.cjs +74 -4
- package/dist/node-entry.cjs.map +1 -1
- package/dist/node-entry.js +7 -7
- package/dist/node-subpath.cjs.map +1 -1
- package/dist/node-subpath.js +3 -3
- package/dist/{source-map-uploader-RA4Z7TWA.js → source-map-uploader-M2P5CDOB.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-CTJO7PUZ.js.map +0 -1
- /package/dist/{chunk-HV5ID2WJ.js.map → chunk-A63WX7NR.js.map} +0 -0
- /package/dist/{chunk-2GCN27SI.js.map → chunk-AGCYKZFY.js.map} +0 -0
- /package/dist/{chunk-47B2G3FE.js.map → chunk-AKZGMT33.js.map} +0 -0
- /package/dist/{chunk-MD5XPCTQ.js.map → chunk-AYUL5QMZ.js.map} +0 -0
- /package/dist/{chunk-YMLMZCPR.js.map → chunk-FMEWG3FY.js.map} +0 -0
- /package/dist/{chunk-NFPDYME5.js.map → chunk-FVHVDBGX.js.map} +0 -0
- /package/dist/{source-map-uploader-RA4Z7TWA.js.map → source-map-uploader-M2P5CDOB.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -12,12 +12,12 @@ import {
|
|
|
12
12
|
registerGlasstrace,
|
|
13
13
|
waitForReady,
|
|
14
14
|
withGlasstraceConfig
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-JMYKR5Z3.js";
|
|
16
16
|
import {
|
|
17
17
|
GlasstraceSpanProcessor,
|
|
18
18
|
SdkError,
|
|
19
19
|
captureCorrelationId
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-AGCYKZFY.js";
|
|
21
21
|
import "./chunk-DQ25VOKK.js";
|
|
22
22
|
import "./chunk-3TU62WD6.js";
|
|
23
23
|
import {
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
performInit,
|
|
28
28
|
saveCachedConfig,
|
|
29
29
|
sendInitRequest
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-A63WX7NR.js";
|
|
31
31
|
import {
|
|
32
32
|
isAnonymousMode,
|
|
33
33
|
isProductionDisabled,
|
|
@@ -37,10 +37,10 @@ import {
|
|
|
37
37
|
import {
|
|
38
38
|
getOrCreateAnonKey,
|
|
39
39
|
readAnonKey
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-AYUL5QMZ.js";
|
|
41
41
|
import {
|
|
42
42
|
deriveSessionId
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-GTPTKN5A.js";
|
|
44
44
|
import "./chunk-NSBPE2FW.js";
|
|
45
45
|
export {
|
|
46
46
|
GlasstraceExporter,
|
package/dist/node-entry.cjs
CHANGED
|
@@ -14724,6 +14724,7 @@ var init_dist = __esm({
|
|
|
14724
14724
|
FETCH_DURATION_MS: "glasstrace.fetch.duration_ms",
|
|
14725
14725
|
FETCH_TARGET: "glasstrace.fetch.target",
|
|
14726
14726
|
ENV_REFERENCED: "glasstrace.env.referenced",
|
|
14727
|
+
BUILD_HASH: "glasstrace.build.hash",
|
|
14727
14728
|
SOURCE_FILE: "glasstrace.source.file",
|
|
14728
14729
|
SOURCE_LINE: "glasstrace.source.line",
|
|
14729
14730
|
SOURCE_MAPPED: "glasstrace.source.mapped",
|
|
@@ -18422,6 +18423,19 @@ function prepareErrorResponseBody(body) {
|
|
|
18422
18423
|
return truncateErrorResponseBody(sanitized);
|
|
18423
18424
|
}
|
|
18424
18425
|
|
|
18426
|
+
// src/build-info.ts
|
|
18427
|
+
var UNSET = "";
|
|
18428
|
+
function readBuildHashFromEnv() {
|
|
18429
|
+
const raw = process.env.GLASSTRACE_BUILD_HASH;
|
|
18430
|
+
if (typeof raw !== "string") return UNSET;
|
|
18431
|
+
const trimmed = raw.trim();
|
|
18432
|
+
return trimmed.length > 0 ? trimmed : UNSET;
|
|
18433
|
+
}
|
|
18434
|
+
var cachedBuildHash = readBuildHashFromEnv();
|
|
18435
|
+
function getBuildHash() {
|
|
18436
|
+
return cachedBuildHash === UNSET ? void 0 : cachedBuildHash;
|
|
18437
|
+
}
|
|
18438
|
+
|
|
18425
18439
|
// src/enriching-exporter.ts
|
|
18426
18440
|
var ATTR2 = GLASSTRACE_ATTRIBUTE_NAMES;
|
|
18427
18441
|
var API_KEY_PENDING = "pending";
|
|
@@ -18537,6 +18551,10 @@ var GlasstraceExporter = class {
|
|
|
18537
18551
|
if (env) {
|
|
18538
18552
|
extra[ATTR2.ENVIRONMENT] = env;
|
|
18539
18553
|
}
|
|
18554
|
+
const buildHash = getBuildHash();
|
|
18555
|
+
if (buildHash) {
|
|
18556
|
+
extra[ATTR2.BUILD_HASH] = buildHash;
|
|
18557
|
+
}
|
|
18540
18558
|
const existingCid = attrs["glasstrace.correlation.id"];
|
|
18541
18559
|
if (typeof existingCid === "string") {
|
|
18542
18560
|
extra[ATTR2.CORRELATION_ID] = existingCid;
|
|
@@ -22569,7 +22587,7 @@ function registerGlasstrace(options) {
|
|
|
22569
22587
|
setCoreState(CoreState.REGISTERING);
|
|
22570
22588
|
startRuntimeStateWriter({
|
|
22571
22589
|
projectRoot: process.cwd(),
|
|
22572
|
-
sdkVersion: "1.
|
|
22590
|
+
sdkVersion: "1.3.0"
|
|
22573
22591
|
});
|
|
22574
22592
|
const config2 = resolveConfig(options);
|
|
22575
22593
|
if (config2.verbose) {
|
|
@@ -22735,8 +22753,8 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
|
|
|
22735
22753
|
if (config2.verbose) {
|
|
22736
22754
|
console.info("[glasstrace] Background init firing.");
|
|
22737
22755
|
}
|
|
22738
|
-
const healthReport = collectHealthReport("1.
|
|
22739
|
-
const initResult = await performInit(config2, anonKeyForInit, "1.
|
|
22756
|
+
const healthReport = collectHealthReport("1.3.0");
|
|
22757
|
+
const initResult = await performInit(config2, anonKeyForInit, "1.3.0", healthReport);
|
|
22740
22758
|
if (generation !== registrationGeneration) return;
|
|
22741
22759
|
const currentState = getCoreState();
|
|
22742
22760
|
if (currentState === CoreState.SHUTTING_DOWN || currentState === CoreState.SHUTDOWN) {
|
|
@@ -22759,7 +22777,7 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
|
|
|
22759
22777
|
}
|
|
22760
22778
|
maybeInstallConsoleCapture();
|
|
22761
22779
|
if (didLastInitSucceed()) {
|
|
22762
|
-
startHeartbeat(config2, anonKeyForInit, "1.
|
|
22780
|
+
startHeartbeat(config2, anonKeyForInit, "1.3.0", generation, (newApiKey, accountId) => {
|
|
22763
22781
|
setAuthState(AuthState.CLAIMING);
|
|
22764
22782
|
emitLifecycleEvent("auth:claim_started", { accountId });
|
|
22765
22783
|
setResolvedApiKey(newApiKey);
|
|
@@ -22917,7 +22935,54 @@ async function handleSourceMapUpload(distDir) {
|
|
|
22917
22935
|
|
|
22918
22936
|
// src/capture-error.ts
|
|
22919
22937
|
init_esm();
|
|
22938
|
+
init_dist();
|
|
22920
22939
|
init_error_nudge();
|
|
22940
|
+
|
|
22941
|
+
// src/stack-frame.ts
|
|
22942
|
+
var PAREN_FRAME = /^\s*at\s+(?:[^()]+\s+)?\(([^()\s]+):(\d+):(\d+)\)\s*$/;
|
|
22943
|
+
var BARE_FRAME = /^\s*at\s+(?:async\s+)?([^()\s]+):(\d+):(\d+)\s*$/;
|
|
22944
|
+
var INTERNAL_FRAME_PATTERNS = [
|
|
22945
|
+
/^node:/,
|
|
22946
|
+
/^node:internal\//,
|
|
22947
|
+
/[/\\]node_modules[/\\]@glasstrace[/\\]sdk[/\\]/,
|
|
22948
|
+
/[/\\]packages[/\\]sdk[/\\]src[/\\]capture-error\./,
|
|
22949
|
+
/[/\\]packages[/\\]sdk[/\\]src[/\\]stack-frame\./
|
|
22950
|
+
];
|
|
22951
|
+
function isInternalFrame(file2) {
|
|
22952
|
+
return INTERNAL_FRAME_PATTERNS.some((re2) => re2.test(file2));
|
|
22953
|
+
}
|
|
22954
|
+
function parseTopStackFrame(stack) {
|
|
22955
|
+
if (typeof stack !== "string" || stack.length === 0) return null;
|
|
22956
|
+
let cursor = 0;
|
|
22957
|
+
while (cursor < stack.length) {
|
|
22958
|
+
const newlineAt = stack.indexOf("\n", cursor);
|
|
22959
|
+
const lineEnd = newlineAt === -1 ? stack.length : newlineAt;
|
|
22960
|
+
const line = stack.slice(cursor, lineEnd);
|
|
22961
|
+
cursor = lineEnd + 1;
|
|
22962
|
+
if (!/^\s*at\s/.test(line)) continue;
|
|
22963
|
+
let file2;
|
|
22964
|
+
let lineStr;
|
|
22965
|
+
const parenMatch = PAREN_FRAME.exec(line);
|
|
22966
|
+
if (parenMatch) {
|
|
22967
|
+
file2 = parenMatch[1];
|
|
22968
|
+
lineStr = parenMatch[2];
|
|
22969
|
+
} else {
|
|
22970
|
+
const bareMatch = BARE_FRAME.exec(line);
|
|
22971
|
+
if (bareMatch) {
|
|
22972
|
+
file2 = bareMatch[1];
|
|
22973
|
+
lineStr = bareMatch[2];
|
|
22974
|
+
}
|
|
22975
|
+
}
|
|
22976
|
+
if (!file2 || !lineStr) continue;
|
|
22977
|
+
if (isInternalFrame(file2)) continue;
|
|
22978
|
+
const lineNum = Number.parseInt(lineStr, 10);
|
|
22979
|
+
if (!Number.isFinite(lineNum) || lineNum <= 0) continue;
|
|
22980
|
+
return { file: file2, line: lineNum };
|
|
22981
|
+
}
|
|
22982
|
+
return null;
|
|
22983
|
+
}
|
|
22984
|
+
|
|
22985
|
+
// src/capture-error.ts
|
|
22921
22986
|
function captureError(error48) {
|
|
22922
22987
|
try {
|
|
22923
22988
|
const span = trace.getSpan(context.active());
|
|
@@ -22929,6 +22994,11 @@ function captureError(error48) {
|
|
|
22929
22994
|
attributes["error.type"] = error48.constructor.name;
|
|
22930
22995
|
if (error48.stack) {
|
|
22931
22996
|
attributes["error.stack"] = error48.stack;
|
|
22997
|
+
const frame = parseTopStackFrame(error48.stack);
|
|
22998
|
+
if (frame) {
|
|
22999
|
+
attributes[GLASSTRACE_ATTRIBUTE_NAMES.SOURCE_FILE] = frame.file;
|
|
23000
|
+
attributes[GLASSTRACE_ATTRIBUTE_NAMES.SOURCE_LINE] = frame.line;
|
|
23001
|
+
}
|
|
22932
23002
|
}
|
|
22933
23003
|
}
|
|
22934
23004
|
span.addEvent("glasstrace.error", attributes);
|