@glasstrace/sdk 1.2.0 → 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-JKI4OCFV.js → chunk-A63WX7NR.js} +3 -3
- package/dist/{chunk-6RNBUUBR.js → chunk-AGCYKZFY.js} +2 -2
- package/dist/{chunk-4EZ6JTDG.js → chunk-AKZGMT33.js} +2 -2
- package/dist/{chunk-TWTWRJ25.js → chunk-AYUL5QMZ.js} +2 -2
- package/dist/{chunk-DST4UBXU.js → chunk-FMEWG3FY.js} +2 -2
- package/dist/{chunk-TWHCJKRS.js → chunk-FVHVDBGX.js} +3 -3
- package/dist/{chunk-X5MAXP5T.js → chunk-GTPTKN5A.js} +6 -3
- package/dist/{chunk-X5MAXP5T.js.map → chunk-GTPTKN5A.js.map} +1 -1
- package/dist/{chunk-6RIH6SFM.js → chunk-JMYKR5Z3.js} +89 -17
- package/dist/chunk-JMYKR5Z3.js.map +1 -0
- package/dist/cli/init.cjs +5 -3
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.js +6 -6
- package/dist/cli/mcp-add.cjs +4 -2
- 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 +4 -2
- package/dist/cli/validate.cjs.map +1 -1
- package/dist/cli/validate.js +2 -2
- package/dist/edge-entry.cjs +5 -2
- package/dist/edge-entry.cjs.map +1 -1
- package/dist/edge-entry.js +2 -2
- package/dist/index.cjs +92 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -5
- package/dist/node-entry.cjs +92 -14
- package/dist/node-entry.cjs.map +1 -1
- package/dist/node-entry.js +7 -7
- package/dist/node-subpath.cjs +4 -2
- package/dist/node-subpath.cjs.map +1 -1
- package/dist/node-subpath.js +3 -3
- package/dist/{source-map-uploader-DPUUCLNW.js → source-map-uploader-M2P5CDOB.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-6RIH6SFM.js.map +0 -1
- /package/dist/{chunk-JKI4OCFV.js.map → chunk-A63WX7NR.js.map} +0 -0
- /package/dist/{chunk-6RNBUUBR.js.map → chunk-AGCYKZFY.js.map} +0 -0
- /package/dist/{chunk-4EZ6JTDG.js.map → chunk-AKZGMT33.js.map} +0 -0
- /package/dist/{chunk-TWTWRJ25.js.map → chunk-AYUL5QMZ.js.map} +0 -0
- /package/dist/{chunk-DST4UBXU.js.map → chunk-FMEWG3FY.js.map} +0 -0
- /package/dist/{chunk-TWHCJKRS.js.map → chunk-FVHVDBGX.js.map} +0 -0
- /package/dist/{source-map-uploader-DPUUCLNW.js.map → source-map-uploader-M2P5CDOB.js.map} +0 -0
package/dist/edge-entry.js
CHANGED
|
@@ -2,9 +2,9 @@ import {
|
|
|
2
2
|
GlasstraceSpanProcessor,
|
|
3
3
|
SdkError,
|
|
4
4
|
captureCorrelationId
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-AGCYKZFY.js";
|
|
6
6
|
import "./chunk-DQ25VOKK.js";
|
|
7
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-GTPTKN5A.js";
|
|
8
8
|
import "./chunk-NSBPE2FW.js";
|
|
9
9
|
export {
|
|
10
10
|
GlasstraceSpanProcessor,
|
package/dist/index.cjs
CHANGED
|
@@ -14667,13 +14667,15 @@ var init_dist = __esm({
|
|
|
14667
14667
|
});
|
|
14668
14668
|
PresignedUploadResponseSchema = external_exports.object({
|
|
14669
14669
|
uploadId: external_exports.string().uuid(),
|
|
14670
|
-
expiresAt: external_exports.number().int().
|
|
14670
|
+
expiresAt: external_exports.number().int().nonnegative(),
|
|
14671
14671
|
files: external_exports.array(
|
|
14672
14672
|
external_exports.object({
|
|
14673
14673
|
filePath: external_exports.string().min(1),
|
|
14674
14674
|
clientToken: external_exports.string().min(1),
|
|
14675
14675
|
pathname: external_exports.string().min(1),
|
|
14676
|
-
maxBytes: external_exports.number().int().positive()
|
|
14676
|
+
maxBytes: external_exports.number().int().positive(),
|
|
14677
|
+
/** Vercel Blob access mode — explicit in the contract per DISC-756. */
|
|
14678
|
+
access: external_exports.enum(["public"])
|
|
14677
14679
|
})
|
|
14678
14680
|
).min(1).max(100)
|
|
14679
14681
|
});
|
|
@@ -14719,6 +14721,7 @@ var init_dist = __esm({
|
|
|
14719
14721
|
FETCH_DURATION_MS: "glasstrace.fetch.duration_ms",
|
|
14720
14722
|
FETCH_TARGET: "glasstrace.fetch.target",
|
|
14721
14723
|
ENV_REFERENCED: "glasstrace.env.referenced",
|
|
14724
|
+
BUILD_HASH: "glasstrace.build.hash",
|
|
14722
14725
|
SOURCE_FILE: "glasstrace.source.file",
|
|
14723
14726
|
SOURCE_LINE: "glasstrace.source.line",
|
|
14724
14727
|
SOURCE_MAPPED: "glasstrace.source.mapped",
|
|
@@ -18224,16 +18227,22 @@ var ERROR_RESPONSE_BODY_TRUNCATION_MARKER = "...[truncated]";
|
|
|
18224
18227
|
var REDACTED = "[REDACTED]";
|
|
18225
18228
|
var ERROR_STATUS_MIN = 400;
|
|
18226
18229
|
var ERROR_STATUS_MAX = 599;
|
|
18227
|
-
function
|
|
18230
|
+
function coerceHttpStatus(value) {
|
|
18228
18231
|
let numeric;
|
|
18229
|
-
if (typeof
|
|
18230
|
-
numeric =
|
|
18231
|
-
} else if (typeof
|
|
18232
|
-
|
|
18232
|
+
if (typeof value === "number") {
|
|
18233
|
+
numeric = value;
|
|
18234
|
+
} else if (typeof value === "string") {
|
|
18235
|
+
const trimmed = value.trim();
|
|
18236
|
+
if (trimmed.length === 0) return void 0;
|
|
18237
|
+
numeric = Number(trimmed);
|
|
18233
18238
|
} else {
|
|
18234
|
-
return
|
|
18239
|
+
return void 0;
|
|
18235
18240
|
}
|
|
18236
|
-
|
|
18241
|
+
return Number.isFinite(numeric) ? numeric : void 0;
|
|
18242
|
+
}
|
|
18243
|
+
function isHttpErrorStatus(status) {
|
|
18244
|
+
const numeric = coerceHttpStatus(status);
|
|
18245
|
+
if (numeric === void 0) return false;
|
|
18237
18246
|
return numeric >= ERROR_STATUS_MIN && numeric <= ERROR_STATUS_MAX;
|
|
18238
18247
|
}
|
|
18239
18248
|
var REDACTION_PATTERNS = [
|
|
@@ -18338,6 +18347,19 @@ function prepareErrorResponseBody(body) {
|
|
|
18338
18347
|
return truncateErrorResponseBody(sanitized);
|
|
18339
18348
|
}
|
|
18340
18349
|
|
|
18350
|
+
// src/build-info.ts
|
|
18351
|
+
var UNSET = "";
|
|
18352
|
+
function readBuildHashFromEnv() {
|
|
18353
|
+
const raw = process.env.GLASSTRACE_BUILD_HASH;
|
|
18354
|
+
if (typeof raw !== "string") return UNSET;
|
|
18355
|
+
const trimmed = raw.trim();
|
|
18356
|
+
return trimmed.length > 0 ? trimmed : UNSET;
|
|
18357
|
+
}
|
|
18358
|
+
var cachedBuildHash = readBuildHashFromEnv();
|
|
18359
|
+
function getBuildHash() {
|
|
18360
|
+
return cachedBuildHash === UNSET ? void 0 : cachedBuildHash;
|
|
18361
|
+
}
|
|
18362
|
+
|
|
18341
18363
|
// src/enriching-exporter.ts
|
|
18342
18364
|
var ATTR = GLASSTRACE_ATTRIBUTE_NAMES;
|
|
18343
18365
|
var API_KEY_PENDING = "pending";
|
|
@@ -18453,6 +18475,10 @@ var GlasstraceExporter = class {
|
|
|
18453
18475
|
if (env) {
|
|
18454
18476
|
extra[ATTR.ENVIRONMENT] = env;
|
|
18455
18477
|
}
|
|
18478
|
+
const buildHash = getBuildHash();
|
|
18479
|
+
if (buildHash) {
|
|
18480
|
+
extra[ATTR.BUILD_HASH] = buildHash;
|
|
18481
|
+
}
|
|
18456
18482
|
const existingCid = attrs["glasstrace.correlation.id"];
|
|
18457
18483
|
if (typeof existingCid === "string") {
|
|
18458
18484
|
extra[ATTR.CORRELATION_ID] = existingCid;
|
|
@@ -18493,7 +18519,7 @@ var GlasstraceExporter = class {
|
|
|
18493
18519
|
}
|
|
18494
18520
|
}
|
|
18495
18521
|
}
|
|
18496
|
-
const statusCode = attrs["http.status_code"] ?? attrs["http.response.status_code"];
|
|
18522
|
+
const statusCode = coerceHttpStatus(attrs["http.status_code"]) ?? coerceHttpStatus(attrs["http.response.status_code"]);
|
|
18497
18523
|
if (statusCode !== void 0) {
|
|
18498
18524
|
extra[ATTR.HTTP_STATUS_CODE] = statusCode;
|
|
18499
18525
|
}
|
|
@@ -22485,7 +22511,7 @@ function registerGlasstrace(options) {
|
|
|
22485
22511
|
setCoreState(CoreState.REGISTERING);
|
|
22486
22512
|
startRuntimeStateWriter({
|
|
22487
22513
|
projectRoot: process.cwd(),
|
|
22488
|
-
sdkVersion: "1.
|
|
22514
|
+
sdkVersion: "1.3.0"
|
|
22489
22515
|
});
|
|
22490
22516
|
const config2 = resolveConfig(options);
|
|
22491
22517
|
if (config2.verbose) {
|
|
@@ -22651,8 +22677,8 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
|
|
|
22651
22677
|
if (config2.verbose) {
|
|
22652
22678
|
console.info("[glasstrace] Background init firing.");
|
|
22653
22679
|
}
|
|
22654
|
-
const healthReport = collectHealthReport("1.
|
|
22655
|
-
const initResult = await performInit(config2, anonKeyForInit, "1.
|
|
22680
|
+
const healthReport = collectHealthReport("1.3.0");
|
|
22681
|
+
const initResult = await performInit(config2, anonKeyForInit, "1.3.0", healthReport);
|
|
22656
22682
|
if (generation !== registrationGeneration) return;
|
|
22657
22683
|
const currentState = getCoreState();
|
|
22658
22684
|
if (currentState === CoreState.SHUTTING_DOWN || currentState === CoreState.SHUTDOWN) {
|
|
@@ -22675,7 +22701,7 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
|
|
|
22675
22701
|
}
|
|
22676
22702
|
maybeInstallConsoleCapture();
|
|
22677
22703
|
if (didLastInitSucceed()) {
|
|
22678
|
-
startHeartbeat(config2, anonKeyForInit, "1.
|
|
22704
|
+
startHeartbeat(config2, anonKeyForInit, "1.3.0", generation, (newApiKey, accountId) => {
|
|
22679
22705
|
setAuthState(AuthState.CLAIMING);
|
|
22680
22706
|
emitLifecycleEvent("auth:claim_started", { accountId });
|
|
22681
22707
|
setResolvedApiKey(newApiKey);
|
|
@@ -22833,7 +22859,54 @@ async function handleSourceMapUpload(distDir) {
|
|
|
22833
22859
|
|
|
22834
22860
|
// src/capture-error.ts
|
|
22835
22861
|
init_esm();
|
|
22862
|
+
init_dist();
|
|
22836
22863
|
init_error_nudge();
|
|
22864
|
+
|
|
22865
|
+
// src/stack-frame.ts
|
|
22866
|
+
var PAREN_FRAME = /^\s*at\s+(?:[^()]+\s+)?\(([^()\s]+):(\d+):(\d+)\)\s*$/;
|
|
22867
|
+
var BARE_FRAME = /^\s*at\s+(?:async\s+)?([^()\s]+):(\d+):(\d+)\s*$/;
|
|
22868
|
+
var INTERNAL_FRAME_PATTERNS = [
|
|
22869
|
+
/^node:/,
|
|
22870
|
+
/^node:internal\//,
|
|
22871
|
+
/[/\\]node_modules[/\\]@glasstrace[/\\]sdk[/\\]/,
|
|
22872
|
+
/[/\\]packages[/\\]sdk[/\\]src[/\\]capture-error\./,
|
|
22873
|
+
/[/\\]packages[/\\]sdk[/\\]src[/\\]stack-frame\./
|
|
22874
|
+
];
|
|
22875
|
+
function isInternalFrame(file2) {
|
|
22876
|
+
return INTERNAL_FRAME_PATTERNS.some((re2) => re2.test(file2));
|
|
22877
|
+
}
|
|
22878
|
+
function parseTopStackFrame(stack) {
|
|
22879
|
+
if (typeof stack !== "string" || stack.length === 0) return null;
|
|
22880
|
+
let cursor = 0;
|
|
22881
|
+
while (cursor < stack.length) {
|
|
22882
|
+
const newlineAt = stack.indexOf("\n", cursor);
|
|
22883
|
+
const lineEnd = newlineAt === -1 ? stack.length : newlineAt;
|
|
22884
|
+
const line = stack.slice(cursor, lineEnd);
|
|
22885
|
+
cursor = lineEnd + 1;
|
|
22886
|
+
if (!/^\s*at\s/.test(line)) continue;
|
|
22887
|
+
let file2;
|
|
22888
|
+
let lineStr;
|
|
22889
|
+
const parenMatch = PAREN_FRAME.exec(line);
|
|
22890
|
+
if (parenMatch) {
|
|
22891
|
+
file2 = parenMatch[1];
|
|
22892
|
+
lineStr = parenMatch[2];
|
|
22893
|
+
} else {
|
|
22894
|
+
const bareMatch = BARE_FRAME.exec(line);
|
|
22895
|
+
if (bareMatch) {
|
|
22896
|
+
file2 = bareMatch[1];
|
|
22897
|
+
lineStr = bareMatch[2];
|
|
22898
|
+
}
|
|
22899
|
+
}
|
|
22900
|
+
if (!file2 || !lineStr) continue;
|
|
22901
|
+
if (isInternalFrame(file2)) continue;
|
|
22902
|
+
const lineNum = Number.parseInt(lineStr, 10);
|
|
22903
|
+
if (!Number.isFinite(lineNum) || lineNum <= 0) continue;
|
|
22904
|
+
return { file: file2, line: lineNum };
|
|
22905
|
+
}
|
|
22906
|
+
return null;
|
|
22907
|
+
}
|
|
22908
|
+
|
|
22909
|
+
// src/capture-error.ts
|
|
22837
22910
|
function captureError(error48) {
|
|
22838
22911
|
try {
|
|
22839
22912
|
const span = trace.getSpan(context.active());
|
|
@@ -22845,6 +22918,11 @@ function captureError(error48) {
|
|
|
22845
22918
|
attributes["error.type"] = error48.constructor.name;
|
|
22846
22919
|
if (error48.stack) {
|
|
22847
22920
|
attributes["error.stack"] = error48.stack;
|
|
22921
|
+
const frame = parseTopStackFrame(error48.stack);
|
|
22922
|
+
if (frame) {
|
|
22923
|
+
attributes[GLASSTRACE_ATTRIBUTE_NAMES.SOURCE_FILE] = frame.file;
|
|
22924
|
+
attributes[GLASSTRACE_ATTRIBUTE_NAMES.SOURCE_LINE] = frame.line;
|
|
22925
|
+
}
|
|
22848
22926
|
}
|
|
22849
22927
|
}
|
|
22850
22928
|
span.addEvent("glasstrace.error", attributes);
|