diff --git a/src/NuGet.Core/NuGet.Commands/RestoreCommand/RestoreCommand.cs b/src/NuGet.Core/NuGet.Commands/RestoreCommand/RestoreCommand.cs index 3052cce2942..1108f6b3f3f 100644 --- a/src/NuGet.Core/NuGet.Commands/RestoreCommand/RestoreCommand.cs +++ b/src/NuGet.Core/NuGet.Commands/RestoreCommand/RestoreCommand.cs @@ -182,6 +182,12 @@ public async Task ExecuteAsync(CancellationToken token) telemetry.TelemetryEvent[IsCentralPackageTransitivePinningEnabled] = isCentralPackageTransitivePinningEnabled; } + bool auditEnabled = AuditUtility.ParseEnableValue( + _request.Project.RestoreMetadata?.RestoreAuditProperties, + _request.Project.FilePath, + _logger); + telemetry.TelemetryEvent[AuditEnabled] = auditEnabled ? "enabled" : "disabled"; + var restoreTime = Stopwatch.StartNew(); // Local package folders (non-sources) @@ -340,11 +346,6 @@ await _logger.LogAsync(RestoreLogMessage.CreateWarning(NuGetLogCode.NU1803, }); } - bool auditEnabled = AuditUtility.ParseEnableValue( - _request.Project.RestoreMetadata?.RestoreAuditProperties, - _request.Project.FilePath, - _logger); - telemetry.TelemetryEvent[AuditEnabled] = auditEnabled ? "enabled" : "disabled"; bool auditRan = false; if (auditEnabled) { diff --git a/test/NuGet.Core.Tests/NuGet.Commands.Test/RestoreCommandTests/RestoreCommandTests.cs b/test/NuGet.Core.Tests/NuGet.Commands.Test/RestoreCommandTests/RestoreCommandTests.cs index 0added477e8..e46172972ec 100644 --- a/test/NuGet.Core.Tests/NuGet.Commands.Test/RestoreCommandTests/RestoreCommandTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Commands.Test/RestoreCommandTests/RestoreCommandTests.cs @@ -2966,7 +2966,7 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async( var projectInformationEvent = telemetryEvents.Single(e => e.Name.Equals("ProjectRestoreInformation")); - projectInformationEvent.Count.Should().Be(24); + projectInformationEvent.Count.Should().Be(25); projectInformationEvent["RestoreSuccess"].Should().Be(true); projectInformationEvent["NoOpResult"].Should().Be(true); projectInformationEvent["IsCentralVersionManagementEnabled"].Should().Be(false); @@ -2991,6 +2991,7 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async( projectInformationEvent["NoOpCacheFileAgeDays"].Should().NotBeNull(); projectInformationEvent["UseLegacyDependencyResolver"].Should().BeOfType(); projectInformationEvent["UsedLegacyDependencyResolver"].Should().BeOfType(); + projectInformationEvent["Audit.Enabled"].Should().BeOfType(); } [Fact]