-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Audit service rework #19346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v17/improvement/introduce-audit-entry-service
Are you sure you want to change the base?
Audit service rework #19346
Conversation
- Added new async and paged methods - Marked (now) redundant methods as obsolete - Updated all of the usages to use the non-obsolete methods - Added unit tests class `AuditServiceTests` and some unit tests - Updated existing integration test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR reworks the audit service by introducing new asynchronous and paged methods across the codebase and deprecating the old synchronous implementations. Key changes include:
- Replacing sync audit log methods with async versions (e.g. AddAsync, CleanLogsAsync, GetItemsAsync, etc.) and marking outdated methods as obsolete.
- Updating unit and integration tests to use the new async methods.
- Adjusting notification handler registrations and background job implementations to align with the async model.
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
tests/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/BackgroundJobs/Jobs/LogScrubberJobTests.cs | Updated verification to use CleanLogsAsync |
tests/Umbraco.Tests.UnitTests/Umbraco.Core/Services/AuditServiceTests.cs | Updated tests invoking async audit log methods |
tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentEditingServiceTests.cs | Changed to async notification handler and arrays for audit type filters |
tests/Umbraco.Tests.Integration/Umbraco.Core/Services/ContentServiceTests.cs | Converted content variation tests to async calls for audit logs |
src/Umbraco.Infrastructure/Services/Implement/PackagingService.cs | Replaced sync audit calls with async ones and handled responses accordingly |
src/Umbraco.Infrastructure/Events/RelateOnTrashNotificationHandler.cs | Switched to async audit logging and updated constructor dependency injection |
src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.CoreServices.cs | Changed registration from sync to async notification handlers |
src/Umbraco.Infrastructure/BackgroundJobs/Jobs/LogScrubberJob.cs | Updated job execution to await CleanLogsAsync |
src/Umbraco.Core/Services/IAuditService.cs | Updated interface to include new async methods and marked obsolete methods |
src/Umbraco.Core/Events/RelateOnCopyNotificationHandler.cs | Moved to async implementation and added new dependency |
Comments suppressed due to low confidence (2)
src/Umbraco.Infrastructure/Services/Implement/PackagingService.cs:86
- [nitpick] Consider refactoring the blocking call to GetAwaiter().GetResult() by making the method asynchronous and awaiting the async call, to reduce the risk of deadlocks and improve scalability.
_auditService.AddAsync( AuditType.PackagerInstall, user?.Key ?? Constants.Security.SuperUserKey, -1, "Package", $"Package data installed for package '{compiledPackage.Name}'.").GetAwaiter().GetResult();
src/Umbraco.Core/Services/IAuditService.cs:157
- The parameter type for 'sinceDate' differs from the one in GetItemsAsync (DateTimeOffset? vs DateTime?); consider unifying these types for consistency across the audit API.
Task<PagedModel<IAuditItem>> GetPagedItemsByUserAsync( Guid userKey, int skip, int take, Direction orderDirection = Direction.Descending, AuditType[]? auditTypeFilter = null, DateTime? sinceDate = null) => throw new NotImplementedException();
…/improvement/audit-service-rework
Note
This was added on top of #19345, due to method moving from this service to the new
AuditEntryService
.Description
AddAsync
- replacesAdd
(async + accepts user key)GetItemsAsync
- replacesGetLogs
(async + pagination)GetItemsByEntityAsync
- replacesGetPagedItemsByEntity
andGetLogs(objectId)
(async + pagination)CleanLogsAsync
- replacesCleanLogs
(async)AuditServiceTests
and some unit testsTesting
TODO