@glasstrace/sdk 1.3.1 → 1.3.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.
Files changed (49) hide show
  1. package/README.md +38 -0
  2. package/dist/{chunk-X4IK6KES.js → chunk-3HWBR7XM.js} +3 -3
  3. package/dist/chunk-3HWBR7XM.js.map +1 -0
  4. package/dist/{chunk-XS3BO7RY.js → chunk-BQKPRFLF.js} +3 -3
  5. package/dist/{chunk-USLH3OTM.js → chunk-E62DL2H4.js} +3 -3
  6. package/dist/{chunk-DW2UJUNB.js → chunk-LQKJ27LO.js} +11 -2
  7. package/dist/chunk-LQKJ27LO.js.map +1 -0
  8. package/dist/{chunk-MQHLWSIX.js → chunk-M4ZI7J3N.js} +100 -62
  9. package/dist/{chunk-MQHLWSIX.js.map → chunk-M4ZI7J3N.js.map} +1 -1
  10. package/dist/{chunk-JFR42QG5.js → chunk-QJVAKVQJ.js} +2 -2
  11. package/dist/{chunk-CRM3EYOL.js → chunk-WKOQJCFN.js} +2 -2
  12. package/dist/{chunk-5PFPEA4C.js → chunk-XNKG4WNQ.js} +35 -14
  13. package/dist/chunk-XNKG4WNQ.js.map +1 -0
  14. package/dist/{chunk-3TU62WD6.js → chunk-YG3X7TUI.js} +1 -1
  15. package/dist/chunk-YG3X7TUI.js.map +1 -0
  16. package/dist/cli/init.cjs +51 -13
  17. package/dist/cli/init.cjs.map +1 -1
  18. package/dist/cli/init.js +6 -6
  19. package/dist/cli/mcp-add.cjs +49 -11
  20. package/dist/cli/mcp-add.cjs.map +1 -1
  21. package/dist/cli/mcp-add.js +2 -2
  22. package/dist/cli/uninit.cjs.map +1 -1
  23. package/dist/cli/uninit.js +3 -3
  24. package/dist/cli/validate.cjs +49 -11
  25. package/dist/cli/validate.cjs.map +1 -1
  26. package/dist/cli/validate.js +2 -2
  27. package/dist/edge-entry.cjs +88 -50
  28. package/dist/edge-entry.cjs.map +1 -1
  29. package/dist/edge-entry.js +2 -2
  30. package/dist/index.cjs +135 -68
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.js +6 -6
  33. package/dist/node-entry.cjs +135 -68
  34. package/dist/node-entry.cjs.map +1 -1
  35. package/dist/node-entry.js +8 -8
  36. package/dist/node-subpath.cjs +49 -11
  37. package/dist/node-subpath.cjs.map +1 -1
  38. package/dist/node-subpath.js +4 -4
  39. package/dist/{source-map-uploader-LACAGKIW.js → source-map-uploader-JAD3XM4F.js} +4 -4
  40. package/package.json +1 -1
  41. package/dist/chunk-3TU62WD6.js.map +0 -1
  42. package/dist/chunk-5PFPEA4C.js.map +0 -1
  43. package/dist/chunk-DW2UJUNB.js.map +0 -1
  44. package/dist/chunk-X4IK6KES.js.map +0 -1
  45. /package/dist/{chunk-XS3BO7RY.js.map → chunk-BQKPRFLF.js.map} +0 -0
  46. /package/dist/{chunk-USLH3OTM.js.map → chunk-E62DL2H4.js.map} +0 -0
  47. /package/dist/{chunk-JFR42QG5.js.map → chunk-QJVAKVQJ.js.map} +0 -0
  48. /package/dist/{chunk-CRM3EYOL.js.map → chunk-WKOQJCFN.js.map} +0 -0
  49. /package/dist/{source-map-uploader-LACAGKIW.js.map → source-map-uploader-JAD3XM4F.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createBuildHash
3
- } from "./chunk-MQHLWSIX.js";
3
+ } from "./chunk-M4ZI7J3N.js";
4
4
 
5
5
  // src/import-graph.ts
6
6
  import * as fs from "node:fs/promises";
@@ -175,4 +175,4 @@ export {
175
175
  extractImports,
176
176
  buildImportGraph
177
177
  };
178
- //# sourceMappingURL=chunk-JFR42QG5.js.map
178
+ //# sourceMappingURL=chunk-QJVAKVQJ.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-DQ25VOKK.js";
4
4
  import {
5
5
  GLASSTRACE_ATTRIBUTE_NAMES
6
- } from "./chunk-MQHLWSIX.js";
6
+ } from "./chunk-M4ZI7J3N.js";
7
7
 
8
8
  // src/errors.ts
9
9
  var SdkError = class extends Error {
@@ -102,4 +102,4 @@ export {
102
102
  GlasstraceSpanProcessor,
103
103
  captureCorrelationId
104
104
  };
105
- //# sourceMappingURL=chunk-CRM3EYOL.js.map
105
+ //# sourceMappingURL=chunk-WKOQJCFN.js.map
@@ -20,7 +20,7 @@ import {
20
20
  maybeShowMcpNudge,
21
21
  maybeShowServerActionNudge,
22
22
  sdkLog
23
- } from "./chunk-3TU62WD6.js";
23
+ } from "./chunk-YG3X7TUI.js";
24
24
  import {
25
25
  _setCurrentConfig,
26
26
  collectHealthReport,
@@ -33,7 +33,7 @@ import {
33
33
  performInit,
34
34
  recordSpansDropped,
35
35
  recordSpansExported
36
- } from "./chunk-X4IK6KES.js";
36
+ } from "./chunk-3HWBR7XM.js";
37
37
  import {
38
38
  isAnonymousMode,
39
39
  isProductionDisabled,
@@ -42,12 +42,13 @@ import {
42
42
  import {
43
43
  atomicWriteFileSync,
44
44
  getOrCreateAnonKey,
45
+ isSyncFsAvailable,
45
46
  readAnonKey
46
- } from "./chunk-DW2UJUNB.js";
47
+ } from "./chunk-LQKJ27LO.js";
47
48
  import {
48
49
  GLASSTRACE_ATTRIBUTE_NAMES,
49
50
  deriveSessionId
50
- } from "./chunk-MQHLWSIX.js";
51
+ } from "./chunk-M4ZI7J3N.js";
51
52
  import {
52
53
  __require
53
54
  } from "./chunk-NSBPE2FW.js";
@@ -266,14 +267,30 @@ function prepareErrorResponseBody(body) {
266
267
 
267
268
  // src/build-info.ts
268
269
  var UNSET = "";
270
+ var SHA_SHAPE = /^[0-9a-f]{7,64}$/i;
271
+ function redactBuildHash(value) {
272
+ const sanitize = (s) => s.replace(/[\x00-\x1F\x7F]/g, "?");
273
+ if (value.length <= 12) return sanitize(value.slice(0, 4)) + "...";
274
+ return sanitize(value.slice(0, 8)) + "..." + sanitize(value.slice(-4));
275
+ }
269
276
  function readBuildHashFromEnv() {
270
277
  const raw = process.env.GLASSTRACE_BUILD_HASH;
271
278
  if (typeof raw !== "string") return UNSET;
272
279
  const trimmed = raw.trim();
273
- return trimmed.length > 0 ? trimmed : UNSET;
280
+ if (trimmed.length === 0) return UNSET;
281
+ if (!SHA_SHAPE.test(trimmed)) {
282
+ sdkLog(
283
+ "warn",
284
+ `[glasstrace] warning: GLASSTRACE_BUILD_HASH=${redactBuildHash(trimmed)} does not match expected SHA shape (7-64 hex characters); source-map enrichment may not work as expected.`
285
+ );
286
+ }
287
+ return trimmed;
274
288
  }
275
- var cachedBuildHash = readBuildHashFromEnv();
289
+ var cachedBuildHash = null;
276
290
  function getBuildHash() {
291
+ if (cachedBuildHash === null) {
292
+ cachedBuildHash = readBuildHashFromEnv();
293
+ }
277
294
  return cachedBuildHash === UNSET ? void 0 : cachedBuildHash;
278
295
  }
279
296
 
@@ -4139,6 +4156,10 @@ var _debounceTimer = null;
4139
4156
  var _started = false;
4140
4157
  function startRuntimeStateWriter(options) {
4141
4158
  if (_started) return;
4159
+ if (!isSyncFsAvailable()) {
4160
+ _started = true;
4161
+ return;
4162
+ }
4142
4163
  _started = true;
4143
4164
  _projectRoot = options.projectRoot;
4144
4165
  _sdkVersion = options.sdkVersion;
@@ -4224,7 +4245,7 @@ function registerGlasstrace(options) {
4224
4245
  setCoreState(CoreState.REGISTERING);
4225
4246
  startRuntimeStateWriter({
4226
4247
  projectRoot: process.cwd(),
4227
- sdkVersion: "1.3.1"
4248
+ sdkVersion: "1.3.3"
4228
4249
  });
4229
4250
  const config = resolveConfig(options);
4230
4251
  if (config.verbose) {
@@ -4390,8 +4411,8 @@ async function backgroundInit(config, anonKeyForInit, generation) {
4390
4411
  if (config.verbose) {
4391
4412
  console.info("[glasstrace] Background init firing.");
4392
4413
  }
4393
- const healthReport = collectHealthReport("1.3.1");
4394
- const initResult = await performInit(config, anonKeyForInit, "1.3.1", healthReport);
4414
+ const healthReport = collectHealthReport("1.3.3");
4415
+ const initResult = await performInit(config, anonKeyForInit, "1.3.3", healthReport);
4395
4416
  if (generation !== registrationGeneration) return;
4396
4417
  const currentState = getCoreState();
4397
4418
  if (currentState === CoreState.SHUTTING_DOWN || currentState === CoreState.SHUTDOWN) {
@@ -4414,7 +4435,7 @@ async function backgroundInit(config, anonKeyForInit, generation) {
4414
4435
  }
4415
4436
  maybeInstallConsoleCapture();
4416
4437
  if (didLastInitSucceed()) {
4417
- startHeartbeat(config, anonKeyForInit, "1.3.1", generation, (newApiKey, accountId) => {
4438
+ startHeartbeat(config, anonKeyForInit, "1.3.3", generation, (newApiKey, accountId) => {
4418
4439
  setAuthState(AuthState.CLAIMING);
4419
4440
  emitLifecycleEvent("auth:claim_started", { accountId });
4420
4441
  setResolvedApiKey(newApiKey);
@@ -4709,7 +4730,7 @@ async function handleSourceMapUpload(distDir) {
4709
4730
  );
4710
4731
  return;
4711
4732
  }
4712
- const { discoverSourceMapFiles, computeBuildHash, uploadSourceMaps } = await import("./source-map-uploader-LACAGKIW.js");
4733
+ const { discoverSourceMapFiles, computeBuildHash, uploadSourceMaps } = await import("./source-map-uploader-JAD3XM4F.js");
4713
4734
  const files = await discoverSourceMapFiles(distDir);
4714
4735
  if (files.length === 0) {
4715
4736
  console.info("[glasstrace] No source map files found. Skipping upload.");
@@ -4729,8 +4750,8 @@ async function handleSourceMapUpload(distDir) {
4729
4750
  }
4730
4751
 
4731
4752
  // src/stack-frame.ts
4732
- var PAREN_FRAME = /^\s*at\s+(?:[^()]+\s+)?\(([^()\s]+):(\d+):(\d+)\)\s*$/;
4733
- var BARE_FRAME = /^\s*at\s+(?:async\s+)?([^()\s]+):(\d+):(\d+)\s*$/;
4753
+ var PAREN_FRAME = /^\s*at\s+(?!eval\s+\(eval\s+at\b)(?:[^()]+\s+)?\(([^()\s]+(?:\([A-Za-z0-9_.-]+\)[^()\s]*)*):(\d+):(\d+)\)\s*$/;
4754
+ var BARE_FRAME = /^\s*at\s+(?:async\s+)?([^()\s]+(?:\([A-Za-z0-9_.-]+\)[^()\s]*)*):(\d+):(\d+)\s*$/;
4734
4755
  var INTERNAL_FRAME_PATTERNS = [
4735
4756
  /^node:/,
4736
4757
  /^node:internal\//,
@@ -4812,4 +4833,4 @@ export {
4812
4833
  withGlasstraceConfig,
4813
4834
  captureError
4814
4835
  };
4815
- //# sourceMappingURL=chunk-5PFPEA4C.js.map
4836
+ //# sourceMappingURL=chunk-XNKG4WNQ.js.map