1010using Microsoft . WindowsAzure . Storage ;
1111using Newtonsoft . Json ;
1212using Newtonsoft . Json . Converters ;
13- using Newtonsoft . Json . Linq ;
1413using NuGet . Services . Entities ;
1514using NuGet . Services . FeatureFlags ;
15+ using NuGetGallery . Auditing ;
1616
1717namespace NuGetGallery . Features
1818{
@@ -23,6 +23,7 @@ public class FeatureFlagFileStorageService : IEditableFeatureFlagStorageService
2323 private static readonly JsonSerializer Serializer ;
2424
2525 private readonly ICoreFileStorageService _storage ;
26+ private readonly IAuditingService _auditing ;
2627 private readonly ILogger < FeatureFlagFileStorageService > _logger ;
2728
2829 static FeatureFlagFileStorageService ( )
@@ -40,9 +41,11 @@ static FeatureFlagFileStorageService()
4041
4142 public FeatureFlagFileStorageService (
4243 ICoreFileStorageService storage ,
44+ IAuditingService auditing ,
4345 ILogger < FeatureFlagFileStorageService > logger )
4446 {
4547 _storage = storage ?? throw new ArgumentNullException ( nameof ( storage ) ) ;
48+ _auditing = auditing ?? throw new ArgumentNullException ( nameof ( auditing ) ) ;
4649 _logger = logger ?? throw new ArgumentNullException ( nameof ( logger ) ) ;
4750 }
4851
@@ -118,6 +121,19 @@ public async Task RemoveUserAsync(User user)
118121 }
119122
120123 public async Task < FeatureFlagSaveResult > TrySaveAsync ( FeatureFlags flags , string contentId )
124+ {
125+ var result = await TrySaveInternalAsync ( flags , contentId ) ;
126+ await _auditing . SaveAuditRecordAsync (
127+ new FeatureFlagsAuditRecord (
128+ AuditedFeatureFlagsAction . Update ,
129+ flags ,
130+ contentId ,
131+ result ) ) ;
132+
133+ return result ;
134+ }
135+
136+ private async Task < FeatureFlagSaveResult > TrySaveInternalAsync ( FeatureFlags flags , string contentId )
121137 {
122138 var accessCondition = AccessConditionWrapper . GenerateIfMatchCondition ( contentId ) ;
123139
0 commit comments