From 45f38b6cfcd61f4620456dc7805eb42bbb331f7d Mon Sep 17 00:00:00 2001 From: John McPherson Date: Thu, 8 Aug 2024 13:18:50 -0700 Subject: [PATCH 1/2] Send unit telemetry on success --- .../Telemetry/Telemetry.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.Management.Configuration/Telemetry/Telemetry.cpp b/src/Microsoft.Management.Configuration/Telemetry/Telemetry.cpp index a7b90d0fa9..6f5e82cf4e 100644 --- a/src/Microsoft.Management.Configuration/Telemetry/Telemetry.cpp +++ b/src/Microsoft.Management.Configuration/Telemetry/Telemetry.cpp @@ -263,12 +263,12 @@ namespace winrt::Microsoft::Management::Configuration::implementation std::string_view action, const IConfigurationUnitResultInformation& resultInformation) const noexcept try { - // We only want to send telemetry for failures of publicly available units. - if (!IsTelemetryEnabled() || SUCCEEDED(static_cast(resultInformation.ResultCode()))) + if (!IsTelemetryEnabled()) { return; } + // We only want to send telemetry for publicly available units. IConfigurationUnitProcessorDetails details = unit.Details(); if (!details || !details.IsPublic()) { From 830a2cfb463028902f50ba349f2c8d193b7545bd Mon Sep 17 00:00:00 2001 From: John McPherson Date: Thu, 8 Aug 2024 13:43:07 -0700 Subject: [PATCH 2/2] Fix unit test --- .../Tests/ConfigurationProcessorTelemetryTests.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.Management.Configuration.UnitTests/Tests/ConfigurationProcessorTelemetryTests.cs b/src/Microsoft.Management.Configuration.UnitTests/Tests/ConfigurationProcessorTelemetryTests.cs index aff7f271c8..3910de7ee0 100644 --- a/src/Microsoft.Management.Configuration.UnitTests/Tests/ConfigurationProcessorTelemetryTests.cs +++ b/src/Microsoft.Management.Configuration.UnitTests/Tests/ConfigurationProcessorTelemetryTests.cs @@ -50,7 +50,8 @@ public void Telemetry_NoUnitEventOnSuccess() GetConfigurationUnitSettingsResult result = testObjects.Processor.GetUnitSettings(testObjects.Unit); - Assert.Empty(this.EventSink.Events); + Assert.Single(this.EventSink.Events); + Assert.Equal(TelemetryEvent.ConfigUnitRunName, this.EventSink.Events[0].Name); } ///