From 8a98ce02dede15a6777d3314f4eb70a409558352 Mon Sep 17 00:00:00 2001 From: Kyle Pollich Date: Thu, 7 Dec 2023 10:41:58 -0500 Subject: [PATCH] Update preset logic per code review --- .../fleet/server/collectors/agents_per_output.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/fleet/server/collectors/agents_per_output.ts b/x-pack/plugins/fleet/server/collectors/agents_per_output.ts index f18aa50c8d7ce..b7ed480fc61fc 100644 --- a/x-pack/plugins/fleet/server/collectors/agents_per_output.ts +++ b/x-pack/plugins/fleet/server/collectors/agents_per_output.ts @@ -96,11 +96,11 @@ export async function getAgentsPerOutput( }; } - ['balanced', 'custom', 'latency', 'scale', 'throughput'].forEach((preset) => { - if (output.preset === preset) { - outputTelemetryRecord.preset_counts![preset] += 1; - } - }); + if (output.preset && output.preset in outputTelemetryRecord.preset_counts) { + outputTelemetryRecord.preset_counts[ + output.preset as keyof typeof outputTelemetryRecord.preset_counts + ] += 1; + } }); return Object.values(outputTypes);