@glasstrace/sdk 1.15.1 → 1.16.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.
Files changed (74) hide show
  1. package/README.md +74 -8
  2. package/dist/async-context/index.cjs +21 -2
  3. package/dist/async-context/index.cjs.map +1 -1
  4. package/dist/async-context/index.js +2 -2
  5. package/dist/{capture-error-03qDnC5v.d.cts → capture-error-B0txjNut.d.cts} +2 -2
  6. package/dist/{capture-error-CAfFUyIU.d.ts → capture-error-Dc01rYNR.d.ts} +2 -2
  7. package/dist/{chunk-F7A3QXCT.js → chunk-774XIOZG.js} +2 -2
  8. package/dist/{chunk-VMK2G6QR.js → chunk-AFTCLH77.js} +2 -2
  9. package/dist/{chunk-XMD5OYD6.js → chunk-BGJKEFBN.js} +2 -2
  10. package/dist/{chunk-LQZRGBN5.js → chunk-DW3CZDS6.js} +2 -2
  11. package/dist/{chunk-T4ETJJSK.js → chunk-EWW3TZ52.js} +95 -11
  12. package/dist/{chunk-T4ETJJSK.js.map → chunk-EWW3TZ52.js.map} +1 -1
  13. package/dist/{chunk-7LE2O4ZJ.js → chunk-GBVMPMVV.js} +54 -5
  14. package/dist/{chunk-7LE2O4ZJ.js.map → chunk-GBVMPMVV.js.map} +1 -1
  15. package/dist/{chunk-HMEHYSTS.js → chunk-KM4UNN3Q.js} +2 -2
  16. package/dist/{chunk-MP3QNDXQ.js → chunk-OHSX224U.js} +2 -2
  17. package/dist/{chunk-6ST4QV7T.js → chunk-T7B752NF.js} +3 -3
  18. package/dist/{chunk-ZIYT2Y4B.js → chunk-WOYJAG7H.js} +3 -3
  19. package/dist/cli/init.cjs +18 -5
  20. package/dist/cli/init.cjs.map +1 -1
  21. package/dist/cli/init.js +7 -7
  22. package/dist/cli/mcp-add.cjs +15 -2
  23. package/dist/cli/mcp-add.cjs.map +1 -1
  24. package/dist/cli/mcp-add.js +3 -3
  25. package/dist/cli/uninit.js +3 -3
  26. package/dist/cli/upgrade-instructions.cjs +1 -1
  27. package/dist/cli/upgrade-instructions.js +3 -3
  28. package/dist/cli/validate.cjs +14 -1
  29. package/dist/cli/validate.cjs.map +1 -1
  30. package/dist/cli/validate.js +2 -2
  31. package/dist/{correlation-id-YcfcqOru.d.ts → correlation-id-B9YYmoZw.d.ts} +1 -1
  32. package/dist/{correlation-id-CZ2bstzA.d.cts → correlation-id-CelUvw7j.d.cts} +1 -1
  33. package/dist/edge-entry.cjs +21 -2
  34. package/dist/edge-entry.cjs.map +1 -1
  35. package/dist/edge-entry.d.cts +2 -2
  36. package/dist/edge-entry.d.ts +2 -2
  37. package/dist/edge-entry.js +4 -4
  38. package/dist/import-graph-DBLGNjcI.d.cts +238 -0
  39. package/dist/import-graph-Dka_Fm7j.d.ts +238 -0
  40. package/dist/index.cjs +137 -11
  41. package/dist/index.cjs.map +1 -1
  42. package/dist/{index.d-BQIJ5Dvc.d.cts → index.d-3-cJoY8y.d.cts} +10 -2
  43. package/dist/{index.d-BQIJ5Dvc.d.ts → index.d-3-cJoY8y.d.ts} +10 -2
  44. package/dist/index.d.cts +28 -4
  45. package/dist/index.d.ts +28 -4
  46. package/dist/index.js +5 -5
  47. package/dist/middleware/index.cjs +21 -2
  48. package/dist/middleware/index.cjs.map +1 -1
  49. package/dist/middleware/index.js +2 -2
  50. package/dist/node-entry.cjs +28 -8
  51. package/dist/node-entry.cjs.map +1 -1
  52. package/dist/node-entry.d.cts +4 -4
  53. package/dist/node-entry.d.ts +4 -4
  54. package/dist/node-entry.js +7 -7
  55. package/dist/node-subpath.cjs +27 -1
  56. package/dist/node-subpath.cjs.map +1 -1
  57. package/dist/node-subpath.d.cts +51 -235
  58. package/dist/node-subpath.d.ts +51 -235
  59. package/dist/node-subpath.js +16 -3
  60. package/dist/node-subpath.js.map +1 -1
  61. package/dist/{source-map-uploader-NUONOEJG.js → source-map-uploader-UJPZCUFN.js} +3 -3
  62. package/dist/trpc/index.cjs +21 -2
  63. package/dist/trpc/index.cjs.map +1 -1
  64. package/dist/trpc/index.js +1 -1
  65. package/package.json +1 -1
  66. /package/dist/{chunk-F7A3QXCT.js.map → chunk-774XIOZG.js.map} +0 -0
  67. /package/dist/{chunk-VMK2G6QR.js.map → chunk-AFTCLH77.js.map} +0 -0
  68. /package/dist/{chunk-XMD5OYD6.js.map → chunk-BGJKEFBN.js.map} +0 -0
  69. /package/dist/{chunk-LQZRGBN5.js.map → chunk-DW3CZDS6.js.map} +0 -0
  70. /package/dist/{chunk-HMEHYSTS.js.map → chunk-KM4UNN3Q.js.map} +0 -0
  71. /package/dist/{chunk-MP3QNDXQ.js.map → chunk-OHSX224U.js.map} +0 -0
  72. /package/dist/{chunk-6ST4QV7T.js.map → chunk-T7B752NF.js.map} +0 -0
  73. /package/dist/{chunk-ZIYT2Y4B.js.map → chunk-WOYJAG7H.js.map} +0 -0
  74. /package/dist/{source-map-uploader-NUONOEJG.js.map → source-map-uploader-UJPZCUFN.js.map} +0 -0
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  _resetForTesting,
3
3
  withAsyncCausality
4
- } from "../chunk-LQZRGBN5.js";
4
+ } from "../chunk-DW3CZDS6.js";
5
5
  import "../chunk-CL3OVHPO.js";
6
6
  import "../chunk-DQ25VOKK.js";
7
- import "../chunk-7LE2O4ZJ.js";
7
+ import "../chunk-GBVMPMVV.js";
8
8
  import "../chunk-NSBPE2FW.js";
9
9
  export {
10
10
  _resetForTesting,
@@ -1,8 +1,8 @@
1
- import { G as GlasstraceEnvVars, j as GlasstraceOptions, A as AnonApiKey, k as SdkInitResponse, C as CaptureConfig, l as SdkHealthReport, I as ImportGraphPayload, g as SdkDiagnosticCode } from './index.d-BQIJ5Dvc.cjs';
1
+ import { G as GlasstraceEnvVars, l as GlasstraceOptions, A as AnonApiKey, m as SdkInitResponse, C as CaptureConfig, n as SdkHealthReport, I as ImportGraphPayload, j as SdkDiagnosticCode } from './index.d-3-cJoY8y.cjs';
2
2
  import { ReadableSpan } from './export/ReadableSpan';
3
3
  import { SpanExporter } from './export/SpanExporter';
4
4
  import { ExportResult } from './ExportResult';
5
- import { a as SessionManager } from './correlation-id-CZ2bstzA.cjs';
5
+ import { a as SessionManager } from './correlation-id-CelUvw7j.cjs';
6
6
  import { SpanProcessor } from './SpanProcessor';
7
7
 
8
8
  /**
@@ -1,8 +1,8 @@
1
- import { G as GlasstraceEnvVars, j as GlasstraceOptions, A as AnonApiKey, k as SdkInitResponse, C as CaptureConfig, l as SdkHealthReport, I as ImportGraphPayload, g as SdkDiagnosticCode } from './index.d-BQIJ5Dvc.js';
1
+ import { G as GlasstraceEnvVars, l as GlasstraceOptions, A as AnonApiKey, m as SdkInitResponse, C as CaptureConfig, n as SdkHealthReport, I as ImportGraphPayload, j as SdkDiagnosticCode } from './index.d-3-cJoY8y.js';
2
2
  import { ReadableSpan } from './export/ReadableSpan';
3
3
  import { SpanExporter } from './export/SpanExporter';
4
4
  import { ExportResult } from './ExportResult';
5
- import { a as SessionManager } from './correlation-id-YcfcqOru.js';
5
+ import { a as SessionManager } from './correlation-id-B9YYmoZw.js';
6
6
  import { SpanProcessor } from './SpanProcessor';
7
7
 
8
8
  /**
@@ -2,7 +2,7 @@ import {
2
2
  AnonApiKeySchema,
3
3
  DevApiKeySchema,
4
4
  createAnonApiKey
5
- } from "./chunk-7LE2O4ZJ.js";
5
+ } from "./chunk-GBVMPMVV.js";
6
6
  import {
7
7
  __require
8
8
  } from "./chunk-NSBPE2FW.js";
@@ -659,4 +659,4 @@ export {
659
659
  writeMcpMarker,
660
660
  refreshGenericMcpConfigAtRuntime
661
661
  };
662
- //# sourceMappingURL=chunk-F7A3QXCT.js.map
662
+ //# sourceMappingURL=chunk-774XIOZG.js.map
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-DQ25VOKK.js";
8
8
  import {
9
9
  GLASSTRACE_ATTRIBUTE_NAMES
10
- } from "./chunk-7LE2O4ZJ.js";
10
+ } from "./chunk-GBVMPMVV.js";
11
11
 
12
12
  // src/middleware/index.ts
13
13
  var ATTR = GLASSTRACE_ATTRIBUTE_NAMES;
@@ -136,4 +136,4 @@ export {
136
136
  _resetForTesting,
137
137
  tracedRequestMiddleware
138
138
  };
139
- //# sourceMappingURL=chunk-VMK2G6QR.js.map
139
+ //# sourceMappingURL=chunk-AFTCLH77.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createBuildHash
3
- } from "./chunk-7LE2O4ZJ.js";
3
+ } from "./chunk-GBVMPMVV.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-XMD5OYD6.js.map
178
+ //# sourceMappingURL=chunk-BGJKEFBN.js.map
@@ -8,7 +8,7 @@ import {
8
8
  } from "./chunk-DQ25VOKK.js";
9
9
  import {
10
10
  GLASSTRACE_ATTRIBUTE_NAMES
11
- } from "./chunk-7LE2O4ZJ.js";
11
+ } from "./chunk-GBVMPMVV.js";
12
12
 
13
13
  // src/async-context/index.ts
14
14
  var ATTR = GLASSTRACE_ATTRIBUTE_NAMES;
@@ -121,4 +121,4 @@ export {
121
121
  _resetForTesting,
122
122
  withAsyncCausality
123
123
  };
124
- //# sourceMappingURL=chunk-LQZRGBN5.js.map
124
+ //# sourceMappingURL=chunk-DW3CZDS6.js.map
@@ -54,7 +54,7 @@ import {
54
54
  performInit,
55
55
  recordSpansDropped,
56
56
  recordSpansExported
57
- } from "./chunk-6ST4QV7T.js";
57
+ } from "./chunk-T7B752NF.js";
58
58
  import {
59
59
  isAnonymousMode,
60
60
  isProductionDisabled,
@@ -65,16 +65,21 @@ import {
65
65
  getOrCreateAnonKey,
66
66
  isSyncFsAvailable,
67
67
  readAnonKey
68
- } from "./chunk-F7A3QXCT.js";
68
+ } from "./chunk-774XIOZG.js";
69
69
  import {
70
70
  GLASSTRACE_ATTRIBUTE_NAMES,
71
+ MAX_SIDE_EFFECT_SCALARS_PER_OPERATION,
72
+ SIDE_EFFECT_HASHED_ID_HEX_LENGTH,
73
+ SIDE_EFFECT_HASHED_ID_PREFIX,
71
74
  SIDE_EFFECT_OMISSION_REASONS,
72
75
  SIDE_EFFECT_OPERATION_KINDS,
73
76
  SIDE_EFFECT_OPERATION_PHASES,
74
77
  SIDE_EFFECT_OPERATION_STATUSES,
78
+ SIDE_EFFECT_SCALAR_PREFIX,
75
79
  deriveSessionId,
80
+ isSideEffectScalarKey,
76
81
  isSideEffectSemanticFieldKey
77
- } from "./chunk-7LE2O4ZJ.js";
82
+ } from "./chunk-GBVMPMVV.js";
78
83
  import {
79
84
  isEndMarkerLine,
80
85
  parseStartMarkerLine
@@ -4470,6 +4475,59 @@ function checkSemanticFieldValue(key, value) {
4470
4475
  }
4471
4476
  return { accepted: true, value };
4472
4477
  }
4478
+ var GTHID_STRICT_REGEX = new RegExp(
4479
+ `^${SIDE_EFFECT_HASHED_ID_PREFIX}[0-9a-f]{${SIDE_EFFECT_HASHED_ID_HEX_LENGTH}}$`
4480
+ );
4481
+ var SCALAR_EPOCH_MS_MIN = 1e12;
4482
+ function isTimestampShapedScalarKey(key) {
4483
+ return key.endsWith("Ms");
4484
+ }
4485
+ function checkScalarField(key, value, mode = "strict") {
4486
+ if (typeof key !== "string" || !isSideEffectScalarKey(key)) {
4487
+ return { accepted: false, reason: "unsupported_key" };
4488
+ }
4489
+ if (value instanceof Date) {
4490
+ return { accepted: false, reason: "raw_timestamp" };
4491
+ }
4492
+ if (key.endsWith("Id")) {
4493
+ if (typeof value !== "string") {
4494
+ return { accepted: false, reason: "unhashed_id" };
4495
+ }
4496
+ if (mode === "strict") {
4497
+ if (!GTHID_STRICT_REGEX.test(value)) {
4498
+ return { accepted: false, reason: "unhashed_id" };
4499
+ }
4500
+ return { accepted: true, value };
4501
+ }
4502
+ if (value.length === 0) {
4503
+ return { accepted: false, reason: "raw_payload" };
4504
+ }
4505
+ const unsafe = detectUnsafePattern(value);
4506
+ if (unsafe) {
4507
+ return { accepted: false, reason: unsafe };
4508
+ }
4509
+ if (value.length > MAX_SIDE_EFFECT_FIELD_VALUE_LENGTH) {
4510
+ return { accepted: false, reason: "value_too_long" };
4511
+ }
4512
+ return { accepted: true, value };
4513
+ }
4514
+ if (key.endsWith("Flag")) {
4515
+ if (typeof value !== "boolean") {
4516
+ return { accepted: false, reason: "raw_payload" };
4517
+ }
4518
+ return { accepted: true, value };
4519
+ }
4520
+ if (typeof value !== "number") {
4521
+ return { accepted: false, reason: "raw_payload" };
4522
+ }
4523
+ if (!Number.isFinite(value)) {
4524
+ return { accepted: false, reason: "non_finite" };
4525
+ }
4526
+ if (mode === "strict" && isTimestampShapedScalarKey(key) && value >= SCALAR_EPOCH_MS_MIN) {
4527
+ return { accepted: false, reason: "raw_timestamp" };
4528
+ }
4529
+ return { accepted: true, value };
4530
+ }
4473
4531
  function checkSemanticFieldKey(key) {
4474
4532
  return typeof key === "string" && isSideEffectSemanticFieldKey(key);
4475
4533
  }
@@ -4533,7 +4591,10 @@ var OMISSION_ATTRIBUTE_BY_REASON = {
4533
4591
  unsupported_key: GLASSTRACE_ATTRIBUTE_NAMES.SIDE_EFFECT_OMITTED_UNSUPPORTED_KEY,
4534
4592
  value_too_long: GLASSTRACE_ATTRIBUTE_NAMES.SIDE_EFFECT_OMITTED_VALUE_TOO_LONG,
4535
4593
  not_emitted: GLASSTRACE_ATTRIBUTE_NAMES.SIDE_EFFECT_OMITTED_NOT_EMITTED,
4536
- capture_disabled: GLASSTRACE_ATTRIBUTE_NAMES.SIDE_EFFECT_OMITTED_CAPTURE_DISABLED
4594
+ capture_disabled: GLASSTRACE_ATTRIBUTE_NAMES.SIDE_EFFECT_OMITTED_CAPTURE_DISABLED,
4595
+ raw_timestamp: GLASSTRACE_ATTRIBUTE_NAMES.SIDE_EFFECT_OMITTED_RAW_TIMESTAMP,
4596
+ unhashed_id: GLASSTRACE_ATTRIBUTE_NAMES.SIDE_EFFECT_OMITTED_UNHASHED_ID,
4597
+ non_finite: GLASSTRACE_ATTRIBUTE_NAMES.SIDE_EFFECT_OMITTED_NON_FINITE
4537
4598
  };
4538
4599
  var FIELD_ATTRIBUTE_BY_KEY = {
4539
4600
  templateKey: GLASSTRACE_ATTRIBUTE_NAMES.SIDE_EFFECT_FIELD_TEMPLATE_KEY,
@@ -4592,6 +4653,12 @@ function attachField(span, key, value) {
4592
4653
  } catch {
4593
4654
  }
4594
4655
  }
4656
+ function attachScalar(span, key, value) {
4657
+ try {
4658
+ span.setAttribute(`${SIDE_EFFECT_SCALAR_PREFIX}${key}`, value);
4659
+ } catch {
4660
+ }
4661
+ }
4595
4662
  function recordOmission(span, reason) {
4596
4663
  recordOmissionOnSpan(span, reason);
4597
4664
  }
@@ -4722,6 +4789,23 @@ function runRecordSideEffect(input) {
4722
4789
  attachField(outcome.span, rawKey, valueOutcome.value);
4723
4790
  }
4724
4791
  }
4792
+ const scalars = candidate.scalars;
4793
+ if (scalars && typeof scalars === "object") {
4794
+ let scalarCount = 0;
4795
+ for (const [rawKey, rawValue] of Object.entries(scalars)) {
4796
+ if (scalarCount >= MAX_SIDE_EFFECT_SCALARS_PER_OPERATION) {
4797
+ recordOmission(outcome.span, "value_too_long");
4798
+ break;
4799
+ }
4800
+ scalarCount += 1;
4801
+ const scalarOutcome = checkScalarField(rawKey, rawValue);
4802
+ if (!scalarOutcome.accepted) {
4803
+ recordOmission(outcome.span, scalarOutcome.reason);
4804
+ continue;
4805
+ }
4806
+ attachScalar(outcome.span, rawKey, scalarOutcome.value);
4807
+ }
4808
+ }
4725
4809
  }
4726
4810
 
4727
4811
  // src/runtime-state.ts
@@ -4996,11 +5080,11 @@ function registerGlasstrace(options) {
4996
5080
  setCoreState(CoreState.REGISTERING);
4997
5081
  maybeWarnStaleAgentInstructions({
4998
5082
  projectRoot: process.cwd(),
4999
- sdkVersion: "1.15.1"
5083
+ sdkVersion: "1.16.0"
5000
5084
  });
5001
5085
  startRuntimeStateWriter({
5002
5086
  projectRoot: process.cwd(),
5003
- sdkVersion: "1.15.1"
5087
+ sdkVersion: "1.16.0"
5004
5088
  });
5005
5089
  const config = resolveConfig(options);
5006
5090
  setSideEffectVerboseFlag(config.verbose);
@@ -5168,8 +5252,8 @@ async function backgroundInit(config, anonKeyForInit, generation) {
5168
5252
  if (config.verbose) {
5169
5253
  console.info("[glasstrace] Background init firing.");
5170
5254
  }
5171
- const healthReport = collectHealthReport("1.15.1");
5172
- const initResult = await performInit(config, anonKeyForInit, "1.15.1", healthReport);
5255
+ const healthReport = collectHealthReport("1.16.0");
5256
+ const initResult = await performInit(config, anonKeyForInit, "1.16.0", healthReport);
5173
5257
  if (generation !== registrationGeneration) return;
5174
5258
  const currentState = getCoreState();
5175
5259
  if (currentState === CoreState.SHUTTING_DOWN || currentState === CoreState.SHUTDOWN) {
@@ -5192,7 +5276,7 @@ async function backgroundInit(config, anonKeyForInit, generation) {
5192
5276
  }
5193
5277
  maybeInstallConsoleCapture();
5194
5278
  if (didLastInitSucceed()) {
5195
- startHeartbeat(config, anonKeyForInit, "1.15.1", generation, (newApiKey, accountId) => {
5279
+ startHeartbeat(config, anonKeyForInit, "1.16.0", generation, (newApiKey, accountId) => {
5196
5280
  setAuthState(AuthState.CLAIMING);
5197
5281
  emitLifecycleEvent("auth:claim_started", { accountId });
5198
5282
  setResolvedApiKey(newApiKey);
@@ -5489,7 +5573,7 @@ async function handleSourceMapUpload(distDir) {
5489
5573
  );
5490
5574
  return;
5491
5575
  }
5492
- const { discoverSourceMapFiles, computeBuildHash, uploadSourceMaps } = await import("./source-map-uploader-NUONOEJG.js");
5576
+ const { discoverSourceMapFiles, computeBuildHash, uploadSourceMaps } = await import("./source-map-uploader-UJPZCUFN.js");
5493
5577
  const files = await discoverSourceMapFiles(distDir);
5494
5578
  if (files.length === 0) {
5495
5579
  console.info("[glasstrace] No source map files found. Skipping upload.");
@@ -5590,4 +5674,4 @@ export {
5590
5674
  withGlasstraceConfig,
5591
5675
  captureError
5592
5676
  };
5593
- //# sourceMappingURL=chunk-T4ETJJSK.js.map
5677
+ //# sourceMappingURL=chunk-EWW3TZ52.js.map