@mastra/observability 1.21.0-alpha.1 → 1.21.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/dist/index.js CHANGED
@@ -51,9 +51,7 @@ function routeToHandler(handler, event, logger) {
51
51
  }), handler.name, "score", logger);
52
52
  }
53
53
  break;
54
- case "feedback":
55
- if (handler.onFeedbackEvent) return catchAsyncResult(handler.onFeedbackEvent(event), handler.name, "feedback", logger);
56
- break;
54
+ case "feedback": if (handler.onFeedbackEvent) return catchAsyncResult(handler.onFeedbackEvent(event), handler.name, "feedback", logger);
57
55
  }
58
56
  } catch (err) {
59
57
  logger.error(`[Observability] Handler error [handler=${handler.name}]:`, err);
@@ -202,7 +200,7 @@ const VALUE_STRIP_KEYS = /* @__PURE__ */ new Set([
202
200
  const DEFAULT_DEEP_CLEAN_OPTIONS = Object.freeze({
203
201
  keysToStrip: [],
204
202
  maxDepth: 8,
205
- maxStringLength: 128 * 1024,
203
+ maxStringLength: 131072,
206
204
  maxArrayLength: 50,
207
205
  maxObjectKeys: 50
208
206
  });
@@ -1276,8 +1274,8 @@ function isRecord(value) {
1276
1274
  //#endregion
1277
1275
  //#region src/metrics/pricing-registry.ts
1278
1276
  const DATA_FILE_NAME = "pricing-data.json";
1279
- const REFRESH_INTERVAL_MS = 1440 * 60 * 1e3;
1280
- const MIN_REFRESH_ATTEMPT_INTERVAL_MS = 3600 * 1e3;
1277
+ const REFRESH_INTERVAL_MS = 864e5;
1278
+ const MIN_REFRESH_ATTEMPT_INTERVAL_MS = 36e5;
1281
1279
  const REFRESH_TIMEOUT_MS = 5e3;
1282
1280
  const CACHE_FILE = () => path.join(os.homedir(), ".cache", "mastra", "pricing-data.json");
1283
1281
  const CACHE_VERSION = 1;
@@ -2819,6 +2817,26 @@ var ModelSpanTracker = class {
2819
2817
  this.#stepIndex++;
2820
2818
  }
2821
2819
  /**
2820
+ * A suspended step emits no step-finish; its suspension chunk carries the
2821
+ * step usage instead. Close MODEL_INFERENCE and MODEL_STEP with that usage so
2822
+ * the suspended call is not reported without tokens.
2823
+ */
2824
+ #endSuspendedStep(chunk) {
2825
+ if (chunk.type !== "tool-call-suspended" && chunk.type !== "tool-call-approval") return;
2826
+ const usage = chunk.payload.usage;
2827
+ if (!usage) return;
2828
+ this.#inModelResponse = false;
2829
+ this.#endStepSpan({
2830
+ output: { usage },
2831
+ stepResult: {
2832
+ reason: "suspended",
2833
+ isContinued: false,
2834
+ warnings: []
2835
+ },
2836
+ metadata: {}
2837
+ });
2838
+ }
2839
+ /**
2822
2840
  * Returns the parent span for chunks. Chunks parent under MODEL_INFERENCE
2823
2841
  * (the provider call) when available, falling back to MODEL_STEP only if
2824
2842
  * startStep() was bypassed.
@@ -2916,9 +2934,7 @@ var ModelSpanTracker = class {
2916
2934
  if (this.#currentChunkType !== "text") this.#startChunkSpan("text");
2917
2935
  this.#appendToAccumulator("text", chunk.payload.text);
2918
2936
  break;
2919
- case "text-end":
2920
- this.#endChunkSpan();
2921
- break;
2937
+ case "text-end": this.#endChunkSpan();
2922
2938
  }
2923
2939
  }
2924
2940
  /**
@@ -2933,9 +2949,7 @@ var ModelSpanTracker = class {
2933
2949
  if (this.#currentChunkType !== "reasoning") this.#startChunkSpan("reasoning");
2934
2950
  this.#appendToAccumulator("text", chunk.payload.text);
2935
2951
  break;
2936
- case "reasoning-end":
2937
- this.#endChunkSpan();
2938
- break;
2952
+ case "reasoning-end": this.#endChunkSpan();
2939
2953
  }
2940
2954
  }
2941
2955
  /**
@@ -2978,9 +2992,7 @@ var ModelSpanTracker = class {
2978
2992
  case "object":
2979
2993
  if (this.#currentChunkType !== "object") this.#startChunkSpan("object");
2980
2994
  break;
2981
- case "object-result":
2982
- this.#endChunkSpan(chunk.object);
2983
- break;
2995
+ case "object-result": this.#endChunkSpan(chunk.object);
2984
2996
  }
2985
2997
  }
2986
2998
  /**
@@ -2990,8 +3002,8 @@ var ModelSpanTracker = class {
2990
3002
  #handleToolApprovalChunk(chunk) {
2991
3003
  if (chunk.type !== "tool-call-approval") return;
2992
3004
  const payload = chunk.payload;
2993
- this.#ensureStepAndInference();
2994
- if (this.#chunkParent()?.createEventSpan({
3005
+ if (payload.usage || this.#currentStepSpan) this.#ensureStepAndInference();
3006
+ if ((this.#chunkParent() ?? this.#modelSpan)?.createEventSpan({
2995
3007
  name: `chunk: 'tool-call-approval'`,
2996
3008
  type: SpanType.MODEL_CHUNK,
2997
3009
  attributes: {
@@ -3011,6 +3023,10 @@ var ModelSpanTracker = class {
3011
3023
  wrapStream(stream) {
3012
3024
  return stream.pipeThrough(new TransformStream({ transform: (chunk, controller) => {
3013
3025
  if ((this.#inModelResponse || this.#deferStepClose) && MODEL_RESPONSE_CHUNK_TYPES.has(chunk.type)) this.#captureCompletionStartTime();
3026
+ if (chunk.type === "tool-call-suspended" || chunk.type === "tool-call-approval") {
3027
+ if (chunk.type === "tool-call-approval") this.#handleToolApprovalChunk(chunk);
3028
+ this.#endSuspendedStep(chunk);
3029
+ }
3014
3030
  controller.enqueue(chunk);
3015
3031
  switch (chunk.type) {
3016
3032
  case "text-start":
@@ -3058,13 +3074,11 @@ var ModelSpanTracker = class {
3058
3074
  case "tripwire":
3059
3075
  case "watch":
3060
3076
  case "tool-error":
3061
- case "tool-call-suspended":
3062
3077
  case "reasoning-signature":
3063
3078
  case "redacted-reasoning":
3064
3079
  case "step-output": break;
3065
- case "tool-call-approval":
3066
- this.#handleToolApprovalChunk(chunk);
3067
- break;
3080
+ case "tool-call-suspended":
3081
+ case "tool-call-approval": break;
3068
3082
  case "tool-output": break;
3069
3083
  case "tool-result": {
3070
3084
  const { toolCallId, toolName, isError, dynamic, providerExecuted, providerMetadata, result, args: _args } = chunk.payload || {};
@@ -3081,7 +3095,6 @@ var ModelSpanTracker = class {
3081
3095
  this.#createEventSpan(chunk.type, spanOutput, { metadata });
3082
3096
  break;
3083
3097
  }
3084
- default: break;
3085
3098
  }
3086
3099
  } }));
3087
3100
  }
@@ -3622,10 +3635,14 @@ var DefaultSpan = class extends BaseSpan {
3622
3635
  }
3623
3636
  this.traceId = getOrCreateTraceId(options);
3624
3637
  this.id = generateSpanId();
3625
- if (options.parentSpanId) if (isValidSpanId(options.parentSpanId)) this.parentSpanId = options.parentSpanId;
3626
- else console.error(`[Mastra Tracing] Invalid parentSpanId: must be 1-16 hexadecimal characters, got "${options.parentSpanId}". Ignoring.`);
3627
- if (options.externalParentSpanId) if (isValidSpanId(options.externalParentSpanId)) this.externalParentSpanId = options.externalParentSpanId;
3628
- else console.error(`[Mastra Tracing] Invalid externalParentSpanId: must be 1-16 hexadecimal characters, got "${options.externalParentSpanId}". Ignoring.`);
3638
+ if (options.parentSpanId) {
3639
+ if (isValidSpanId(options.parentSpanId)) this.parentSpanId = options.parentSpanId;
3640
+ else console.error(`[Mastra Tracing] Invalid parentSpanId: must be 1-16 hexadecimal characters, got "${options.parentSpanId}". Ignoring.`);
3641
+ }
3642
+ if (options.externalParentSpanId) {
3643
+ if (isValidSpanId(options.externalParentSpanId)) this.externalParentSpanId = options.externalParentSpanId;
3644
+ else console.error(`[Mastra Tracing] Invalid externalParentSpanId: must be 1-16 hexadecimal characters, got "${options.externalParentSpanId}". Ignoring.`);
3645
+ }
3629
3646
  }
3630
3647
  end(options) {
3631
3648
  if (this.isEvent) return;
@@ -3747,8 +3764,10 @@ function isValidSpanId(spanId) {
3747
3764
  return /^[0-9a-f]{1,16}$/i.test(spanId);
3748
3765
  }
3749
3766
  function getOrCreateTraceId(options) {
3750
- if (options.traceId) if (isValidTraceId(options.traceId)) return options.traceId;
3751
- else console.error(`[Mastra Tracing] Invalid traceId: must be 1-32 hexadecimal characters, got "${options.traceId}". Generating new trace ID.`);
3767
+ if (options.traceId) {
3768
+ if (isValidTraceId(options.traceId)) return options.traceId;
3769
+ else console.error(`[Mastra Tracing] Invalid traceId: must be 1-32 hexadecimal characters, got "${options.traceId}". Generating new trace ID.`);
3770
+ }
3752
3771
  return generateTraceId();
3753
3772
  }
3754
3773
  //#endregion
@@ -3997,17 +4016,13 @@ var EventBuffer = class {
3997
4016
  switch (this.#storageStrategy) {
3998
4017
  case "realtime":
3999
4018
  case "event-sourced":
4000
- case "batch-with-updates":
4001
- this.pushCreate(event);
4002
- break;
4019
+ case "batch-with-updates": this.pushCreate(event);
4003
4020
  }
4004
4021
  break;
4005
4022
  case TracingEventType.SPAN_UPDATED:
4006
4023
  switch (this.#storageStrategy) {
4007
4024
  case "realtime":
4008
- case "batch-with-updates":
4009
- this.pushUpdate(event);
4010
- break;
4025
+ case "batch-with-updates": this.pushUpdate(event);
4011
4026
  }
4012
4027
  break;
4013
4028
  case TracingEventType.SPAN_ENDED:
@@ -4017,14 +4032,10 @@ var EventBuffer = class {
4017
4032
  case "batch-with-updates":
4018
4033
  this.pushUpdate(event);
4019
4034
  break;
4020
- default:
4021
- this.pushCreate(event);
4022
- break;
4035
+ default: this.pushCreate(event);
4023
4036
  }
4024
4037
  break;
4025
- default:
4026
- this.pushCreate(event);
4027
- break;
4038
+ default: this.pushCreate(event);
4028
4039
  }
4029
4040
  }
4030
4041
  /** Re-add failed create events to the buffer, returning events that exceed max retries. */
@@ -4399,17 +4410,13 @@ var DefaultExporter = class extends BaseExporter {
4399
4410
  case "score":
4400
4411
  createScoreEvents.push(createEvent);
4401
4412
  break;
4402
- default:
4403
- createSpanEvents.push(createEvent);
4404
- break;
4413
+ default: createSpanEvents.push(createEvent);
4405
4414
  }
4406
4415
  for (const updateEvent of updates) switch (updateEvent.type) {
4407
4416
  case TracingEventType.SPAN_UPDATED:
4408
4417
  updateSpanEvents.push(updateEvent);
4409
4418
  break;
4410
- case TracingEventType.SPAN_ENDED:
4411
- endSpanEvents.push(updateEvent);
4412
- break;
4419
+ case TracingEventType.SPAN_ENDED: endSpanEvents.push(updateEvent);
4413
4420
  }
4414
4421
  const flushResults = await Promise.all([
4415
4422
  this.flushCreates("feedback", createFeedbackEvents, (events) => this.#observabilityStorage.batchCreateFeedback({ feedbacks: events.map((f) => buildFeedbackRecord(f)) })),
@@ -4426,13 +4433,15 @@ var DefaultExporter = class extends BaseExporter {
4426
4433
  flushResults.push(await this.flushSpanUpdates(updateSpanEvents, deferredUpdates, false));
4427
4434
  flushResults.push(await this.flushSpanUpdates(endSpanEvents, deferredUpdates, true));
4428
4435
  let deferredDropCount = 0;
4429
- if (deferredUpdates.length > 0) if (this.#unsupportedSignals.has("tracing")) {
4430
- deferredDropCount = deferredUpdates.length;
4431
- this.emitDrop("tracing", "unsupported-storage", deferredDropCount);
4432
- deferredUpdates.length = 0;
4433
- } else {
4434
- deferredDropCount = this.#eventBuffer.reAddUpdates(deferredUpdates).length;
4435
- this.emitDrop("tracing", "retry-exhausted", deferredDropCount);
4436
+ if (deferredUpdates.length > 0) {
4437
+ if (this.#unsupportedSignals.has("tracing")) {
4438
+ deferredDropCount = deferredUpdates.length;
4439
+ this.emitDrop("tracing", "unsupported-storage", deferredDropCount);
4440
+ deferredUpdates.length = 0;
4441
+ } else {
4442
+ deferredDropCount = this.#eventBuffer.reAddUpdates(deferredUpdates).length;
4443
+ this.emitDrop("tracing", "retry-exhausted", deferredDropCount);
4444
+ }
4436
4445
  }
4437
4446
  const retryAttempt = flushResults.reduce((earliestAttempt, result) => {
4438
4447
  if (result.retryAttempt === void 0) return earliestAttempt;
@@ -4850,17 +4859,13 @@ var MastraStorageExporter = class extends BaseExporter {
4850
4859
  case "score":
4851
4860
  createScoreEvents.push(createEvent);
4852
4861
  break;
4853
- default:
4854
- createSpanEvents.push(createEvent);
4855
- break;
4862
+ default: createSpanEvents.push(createEvent);
4856
4863
  }
4857
4864
  for (const updateEvent of updates) switch (updateEvent.type) {
4858
4865
  case TracingEventType.SPAN_UPDATED:
4859
4866
  updateSpanEvents.push(updateEvent);
4860
4867
  break;
4861
- case TracingEventType.SPAN_ENDED:
4862
- endSpanEvents.push(updateEvent);
4863
- break;
4868
+ case TracingEventType.SPAN_ENDED: endSpanEvents.push(updateEvent);
4864
4869
  }
4865
4870
  const flushResults = await Promise.all([
4866
4871
  this.flushCreates("feedback", createFeedbackEvents, (events) => this.#observabilityStorage.batchCreateFeedback({ feedbacks: events.map((f) => buildFeedbackRecord(f)) })),
@@ -4877,13 +4882,15 @@ var MastraStorageExporter = class extends BaseExporter {
4877
4882
  flushResults.push(await this.flushSpanUpdates(updateSpanEvents, deferredUpdates, false));
4878
4883
  flushResults.push(await this.flushSpanUpdates(endSpanEvents, deferredUpdates, true));
4879
4884
  let deferredDropCount = 0;
4880
- if (deferredUpdates.length > 0) if (this.#unsupportedSignals.has("tracing")) {
4881
- deferredDropCount = deferredUpdates.length;
4882
- this.emitDrop("tracing", "unsupported-storage", deferredDropCount);
4883
- deferredUpdates.length = 0;
4884
- } else {
4885
- deferredDropCount = this.#eventBuffer.reAddUpdates(deferredUpdates).length;
4886
- this.emitDrop("tracing", "retry-exhausted", deferredDropCount);
4885
+ if (deferredUpdates.length > 0) {
4886
+ if (this.#unsupportedSignals.has("tracing")) {
4887
+ deferredDropCount = deferredUpdates.length;
4888
+ this.emitDrop("tracing", "unsupported-storage", deferredDropCount);
4889
+ deferredUpdates.length = 0;
4890
+ } else {
4891
+ deferredDropCount = this.#eventBuffer.reAddUpdates(deferredUpdates).length;
4892
+ this.emitDrop("tracing", "retry-exhausted", deferredDropCount);
4893
+ }
4887
4894
  }
4888
4895
  const retryAttempt = flushResults.reduce((earliestAttempt, result) => {
4889
4896
  if (result.retryAttempt === void 0) return earliestAttempt;
@@ -5403,10 +5410,13 @@ var BaseObservabilityInstance = class extends MastraBase {
5403
5410
  const parts = key.split(".");
5404
5411
  const rootKey = parts[0];
5405
5412
  const value = requestContext.get(rootKey);
5406
- if (value !== void 0) if (parts.length > 1) {
5407
- const nestedValue = getNestedValue(value, parts.slice(1).join("."));
5408
- if (nestedValue !== void 0) setNestedValue(result, key, nestedValue);
5409
- } else setNestedValue(result, key, value);
5413
+ if (value !== void 0) {
5414
+ if (parts.length > 1) {
5415
+ const nestedPath = parts.slice(1).join(".");
5416
+ const nestedValue = getNestedValue(value, nestedPath);
5417
+ if (nestedValue !== void 0) setNestedValue(result, key, nestedValue);
5418
+ } else setNestedValue(result, key, value);
5419
+ }
5410
5420
  }
5411
5421
  return result;
5412
5422
  }
@@ -5954,7 +5964,7 @@ function formatBaggage(entries) {
5954
5964
  const DEFAULT_LIMITS = {
5955
5965
  maxSpans: 10,
5956
5966
  maxLogs: 10,
5957
- maxPayloadBytes: 1024 * 1024
5967
+ maxPayloadBytes: 1048576
5958
5968
  };
5959
5969
  var ClientObservabilityProxyImpl = class {
5960
5970
  #resolveInstance;
@@ -6889,36 +6899,38 @@ var TrackingExporter = class extends BaseExporter {
6889
6899
  method
6890
6900
  });
6891
6901
  const { exportedSpan } = await this._preExportTracingEvent(event);
6892
- if (!this.skipBuildRootTask && !traceData.hasRoot()) if (exportedSpan.isRootSpan) {
6893
- this.logger.debug(`${this.name}: Building root`, {
6894
- traceId: exportedSpan.traceId,
6895
- spanId: exportedSpan.id
6896
- });
6897
- const rootData = await this._buildRoot({
6898
- span: exportedSpan,
6899
- traceData
6900
- });
6901
- if (rootData) {
6902
- this.logger.debug(`${this.name}: Adding root`, {
6902
+ if (!this.skipBuildRootTask && !traceData.hasRoot()) {
6903
+ if (exportedSpan.isRootSpan) {
6904
+ this.logger.debug(`${this.name}: Building root`, {
6905
+ traceId: exportedSpan.traceId,
6906
+ spanId: exportedSpan.id
6907
+ });
6908
+ const rootData = await this._buildRoot({
6909
+ span: exportedSpan,
6910
+ traceData
6911
+ });
6912
+ if (rootData) {
6913
+ this.logger.debug(`${this.name}: Adding root`, {
6914
+ traceId: exportedSpan.traceId,
6915
+ spanId: exportedSpan.id
6916
+ });
6917
+ traceData.addRoot({
6918
+ rootId: exportedSpan.id,
6919
+ rootData
6920
+ });
6921
+ this.#scheduleProcessWaitingForRoot(traceId);
6922
+ }
6923
+ } else {
6924
+ this.logger.debug(`${this.name}: Root does not exist, adding span to waiting queue.`, {
6903
6925
  traceId: exportedSpan.traceId,
6904
6926
  spanId: exportedSpan.id
6905
6927
  });
6906
- traceData.addRoot({
6907
- rootId: exportedSpan.id,
6908
- rootData
6928
+ traceData.addToWaitingQueue({
6929
+ event,
6930
+ waitingFor: "root"
6909
6931
  });
6910
- this.#scheduleProcessWaitingForRoot(traceId);
6932
+ return;
6911
6933
  }
6912
- } else {
6913
- this.logger.debug(`${this.name}: Root does not exist, adding span to waiting queue.`, {
6914
- traceId: exportedSpan.traceId,
6915
- spanId: exportedSpan.id
6916
- });
6917
- traceData.addToWaitingQueue({
6918
- event,
6919
- waitingFor: "root"
6920
- });
6921
- return;
6922
6934
  }
6923
6935
  if (exportedSpan.metadata && this.name in exportedSpan.metadata) {
6924
6936
  const metadata = exportedSpan.metadata[this.name];
@@ -7045,7 +7057,6 @@ var TrackingExporter = class extends BaseExporter {
7045
7057
  traceData
7046
7058
  });
7047
7059
  if (traceData.activeSpanCount() === 0) this.#scheduleCleanup(traceId);
7048
- break;
7049
7060
  }
7050
7061
  } catch (error) {
7051
7062
  this.logger.error(`${this.name}: exporter error`, {
@@ -7211,7 +7222,7 @@ function chainFormatters(formatters) {
7211
7222
  //#region src/exporters/auth-failure-cooldown.ts
7212
7223
  const AUTH_FAILURE_STATUSES = /* @__PURE__ */ new Set([401, 403]);
7213
7224
  const AUTH_COOLDOWN_BASE_MS = 6e4;
7214
- const AUTH_COOLDOWN_MAX_MS = 15 * 6e4;
7225
+ const AUTH_COOLDOWN_MAX_MS = 9e5;
7215
7226
  const AUTH_COOLDOWN_JITTER_RATIO = .1;
7216
7227
  var AuthFailureError = class extends Error {
7217
7228
  status;
@@ -7640,8 +7651,9 @@ var CloudExporter = class extends BaseExporter {
7640
7651
  succeeded: false,
7641
7652
  authFailureStatus: error.status
7642
7653
  };
7654
+ const errorId = `CLOUD_EXPORTER_FAILED_TO_BATCH_UPLOAD_${signal.toUpperCase()}`;
7643
7655
  const mastraError = new MastraError({
7644
- id: `CLOUD_EXPORTER_FAILED_TO_BATCH_UPLOAD_${signal.toUpperCase()}`,
7656
+ id: errorId,
7645
7657
  domain: ErrorDomain.MASTRA_OBSERVABILITY,
7646
7658
  category: ErrorCategory.USER,
7647
7659
  details: {
@@ -8230,8 +8242,9 @@ var MastraPlatformExporter = class extends BaseExporter {
8230
8242
  succeeded: false,
8231
8243
  authFailureStatus: error.status
8232
8244
  };
8245
+ const errorId = `MASTRA_PLATFORM_EXPORTER_FAILED_TO_BATCH_UPLOAD_${signal.toUpperCase()}`;
8233
8246
  const mastraError = new MastraError({
8234
- id: `MASTRA_PLATFORM_EXPORTER_FAILED_TO_BATCH_UPLOAD_${signal.toUpperCase()}`,
8247
+ id: errorId,
8235
8248
  domain: ErrorDomain.MASTRA_OBSERVABILITY,
8236
8249
  category: ErrorCategory.USER,
8237
8250
  details: {
@@ -9095,16 +9108,18 @@ var TestExporter = class extends BaseExporter {
9095
9108
  for (let i = 0; i < maxLen; i++) {
9096
9109
  const actualLine = actual[i];
9097
9110
  const expectedLine = expected[i];
9098
- if (actualLine !== expectedLine) if (actualLine === void 0) {
9099
- diffs.push(`Line ${i + 1}: Missing in actual`);
9100
- diffs.push(` Expected: ${expectedLine}`);
9101
- } else if (expectedLine === void 0) {
9102
- diffs.push(`Line ${i + 1}: Extra in actual`);
9103
- diffs.push(` Actual: ${actualLine}`);
9104
- } else {
9105
- diffs.push(`Line ${i + 1}:`);
9106
- diffs.push(` Expected: ${expectedLine}`);
9107
- diffs.push(` Actual: ${actualLine}`);
9111
+ if (actualLine !== expectedLine) {
9112
+ if (actualLine === void 0) {
9113
+ diffs.push(`Line ${i + 1}: Missing in actual`);
9114
+ diffs.push(` Expected: ${expectedLine}`);
9115
+ } else if (expectedLine === void 0) {
9116
+ diffs.push(`Line ${i + 1}: Extra in actual`);
9117
+ diffs.push(` Actual: ${actualLine}`);
9118
+ } else {
9119
+ diffs.push(`Line ${i + 1}:`);
9120
+ diffs.push(` Expected: ${expectedLine}`);
9121
+ diffs.push(` Actual: ${actualLine}`);
9122
+ }
9108
9123
  }
9109
9124
  }
9110
9125
  return diffs;
@@ -9867,9 +9882,10 @@ var SensitiveDataFilter = class {
9867
9882
  const filtered = {};
9868
9883
  for (const key of Object.keys(obj)) {
9869
9884
  const normKey = this.normalizeKey(key);
9870
- if (this.isSensitive(normKey)) if (obj[key] && typeof obj[key] === "object") filtered[key] = this.deepFilter(obj[key], seen, indexedState);
9871
- else filtered[key] = this.redactValue(obj[key], normKey, indexedState);
9872
- else filtered[key] = this.deepFilter(obj[key], seen, indexedState);
9885
+ if (this.isSensitive(normKey)) {
9886
+ if (obj[key] && typeof obj[key] === "object") filtered[key] = this.deepFilter(obj[key], seen, indexedState);
9887
+ else filtered[key] = this.redactValue(obj[key], normKey, indexedState);
9888
+ } else filtered[key] = this.deepFilter(obj[key], seen, indexedState);
9873
9889
  }
9874
9890
  return filtered;
9875
9891
  }