-
Notifications
You must be signed in to change notification settings - Fork 2
Feature| New Formatters for activities #477
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
Conversation
ebf2d45 to
a58c130
Compare
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 adds new audit log formatters for various Summit-related entities to improve activity tracking and auditing capabilities. The changes include creating 18 new formatter classes, updating 4 existing formatters to use a consistent change details pattern, and enhancing the base formatter infrastructure.
Key Changes
- Added 18 new audit log formatters for entities like SummitMetric, SummitSponsorship, RSVP-related entities, Presentation categories, and Company
- Updated existing formatters (SummitMemberSchedule, SpeakerAssistance, PresentationSubmission, PresentationSpeaker) to use the standardized
buildChangeDetails()method - Enhanced AbstractAuditLogFormatter with console execution detection and nullable context support
- Updated base entity formatters (EntityCreation, EntityUpdate, EntityDeletion) to include user information and entity IDs in audit messages
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 19 comments.
Show a summary per file
| File | Description |
|---|---|
| config/audit_log.php | Added configuration mappings for 7 new entity types to their respective audit log formatters |
| app/Audit/AbstractAuditLogFormatter.php | Added nullable context support, console execution detection for worker jobs, and mixed type hint for format method |
| app/Audit/ConcreteFormatters/SummitMetricAuditLogFormatter.php | New formatter for Summit metrics with creation, update, and deletion logging |
| app/Audit/ConcreteFormatters/SummitSponsorshipAuditLogFormatter.php | New formatter for Summit sponsorships tracking sponsor and type information |
| app/Audit/ConcreteFormatters/SummitPresentationCommentAuditLogFormatter.php | New formatter for presentation comments with presenter and creator tracking |
| app/Audit/ConcreteFormatters/SummitProposedScheduleAllowedLocationAuditLogFormatter.php | New formatter for proposed schedule allowed locations tracking track and location details |
| app/Audit/ConcreteFormatters/SummitSelectedPresentationAuditLogFormatter.php | New formatter for selected presentations with collection and member information |
| app/Audit/ConcreteFormatters/SummitBookableVenueRoomAttributeValueAuditLogFormatter.php | New formatter for bookable venue room attribute values |
| app/Audit/ConcreteFormatters/SummitSelectedPresentationListAuditLogFormatter.php | New formatter for selected presentation lists with category and owner tracking |
| app/Audit/ConcreteFormatters/SummitEventTypeAuditLogFormatter.php | New formatter for event types with summit, color, and visibility attributes |
| app/Audit/ConcreteFormatters/SponsorAuditLogFormatter.php | New formatter for sponsors linking company and summit information |
| app/Audit/ConcreteFormatters/SpeakerAssistanceAuditLogFormatter.php | Updated to use buildChangeDetails() for consistent change tracking |
| app/Audit/ConcreteFormatters/RSVPTemplateAuditLogFormatter.php | New formatter for RSVP templates with status and question count tracking |
| app/Audit/ConcreteFormatters/RSVPQuestionTemplateAuditLogFormatter.php | New formatter for RSVP question templates with type and position information |
| app/Audit/ConcreteFormatters/RSVPInvitationAuditLogFormatter.php | New formatter for RSVP invitations tracking attendee and event details |
| app/Audit/ConcreteFormatters/RSVPAuditLogFormatter.php | New formatter for RSVPs with status and seat type tracking |
| app/Audit/ConcreteFormatters/PresentationTypeAuditLogFormatter.php | New formatter for presentation types with speaker configuration details |
| app/Audit/ConcreteFormatters/PresentationCategoryGroupAuditLogFormatter.php | New formatter for track groups with color and voting limits |
| app/Audit/ConcreteFormatters/PresentationCategoryAuditLogFormatter.php | New formatter for presentation categories with code and summit association |
| app/Audit/ConcreteFormatters/CompanyAuditLogFormatter.php | New formatter for companies with location and visibility tracking |
| app/Audit/ConcreteFormatters/ChildEntityFormatters/RSVPAnswerAuditLogFormatter.php | New child entity formatter for RSVP answers |
| app/Audit/ConcreteFormatters/SummitMemberScheduleAuditLogFormatter.php | Updated to include constructor and handle null event properties |
| app/Audit/ConcreteFormatters/PresentationFormatters/PresentationSubmissionAuditLogFormatter.php | Updated to use buildChangeDetails() replacing custom field tracking |
| app/Audit/ConcreteFormatters/PresentationFormatters/PresentationSpeakerAuditLogFormatter.php | Updated to use buildChangeDetails() for speaker property changes |
| app/Audit/ConcreteFormatters/PresentationFormatters/BasePresentationAuditLogFormatter.php | Modified to pass change_set to formatUpdate method |
| app/Audit/ConcreteFormatters/EntityUpdateAuditLogFormatter.php | Enhanced with user information and entity ID in update messages |
| app/Audit/ConcreteFormatters/EntityDeletionAuditLogFormatter.php | Enhanced with user information and entity ID in deletion messages |
| app/Audit/ConcreteFormatters/EntityCreationAuditLogFormatter.php | Enhanced with user information and entity ID, added constructor |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
app/Audit/ConcreteFormatters/SummitProposedScheduleAllowedLocationAuditLogFormatter.php
Show resolved
Hide resolved
app/Audit/ConcreteFormatters/SummitSelectedPresentationAuditLogFormatter.php
Show resolved
Hide resolved
app/Audit/ConcreteFormatters/SummitBookableVenueRoomAttributeValueAuditLogFormatter.php
Show resolved
Hide resolved
app/Audit/ConcreteFormatters/SummitPresentationCommentAuditLogFormatter.php
Show resolved
Hide resolved
app/Audit/ConcreteFormatters/SummitSelectedPresentationListAuditLogFormatter.php
Show resolved
Hide resolved
| { | ||
| public function __construct() | ||
| { | ||
| parent::__construct('entity_creation'); |
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.
@andrestejerina97 what is the purpoise of this hardcoded string?
we should be using here only constants defined here
at
| interface IAuditStrategy |
| public function __construct(?IChildEntityAuditLogFormatter $child_entity_formatter) | ||
| public function __construct(?IChildEntityAuditLogFormatter $child_entity_formatter = null) | ||
| { | ||
| parent::__construct('entity_deletion'); |
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.
| public function __construct(?IChildEntityAuditLogFormatter $child_entity_formatter) | ||
| public function __construct(?IChildEntityAuditLogFormatter $child_entity_formatter = null) | ||
| { | ||
| parent::__construct('entity_update'); |
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.
| return null; | ||
| } | ||
|
|
||
| try { |
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.
nitpick:
this pattern
-
get entity audit context
ie
$name = $subject->getName() ?? 'Unknown'; $label = $subject->getLabel() ?? 'Unknown'; $templateId = $subject->getTemplate()?->getId() ?? 'unknown'; $id = $subject->getId() ?? 'unknown'; $className = class_basename($subject); -
switch
switch ($this->event_type) {
is repeated over and over on all formatters
perhaps it would be better to extract this to a couple of abstract methods at
AbstractAuditLogFormatter ?
like
protected abstract function AbstractAuditLogFormatter::getEntityAuditCtx($subject):array
and override it at
protected abstract function RSVPQuestionTemplateAuditLogFormatter::getEntityAuditCtx($subject):array{
return [
'name' => $subject->getName() ?? 'Unknown';
'label' => $subject->getLabel() ?? 'Unknown',
'templateId' => $subject->getTemplate()?->getId() ?? 'unknown',
'id' => $subject->getId() ?? 'unknown'.
'className' => class_basename($subject),
];
}
and also define at AbstractAuditLogFormatter
public function format($subject, array $change_set): ?string{
$entity_audit_ctx = $this->getEntityAuditCtx($subject);
switch ($this->event_type) {
case IAuditStrategy::EVENT_ENTITY_CREATION:
return $this->getEntityCreationLog($subject, $entity_audit_ctx);
case IAuditStrategy::EVENT_ENTITY_UPDATE:
return $this->getEntityUpdateLog($subject, $entity_audit_ctx);
case IAuditStrategy::EVENT_ENTITY_DELETION:
return $this->getEntittyDeleteLog($subject, $entity_audit_ctx);
}
} catch (\Exception $ex) {
Log::warning("RSVPQuestionTemplateAuditLogFormatter error: " . $ex->getMessage());
}
return null;
}
then define those 3 as abstract at AbstractAuditLogFormatter
protected abstract function getEntityCreationLog($subject , array $ctx):string;
protected abstract function getEntityUpdateLog($subject , array $ctx):string;
protected abstract function getEntittyDeleteLog($subject , array $ctx):string;
and do the proper implementation at RSVPQuestionTemplateAuditLogFormatter ?
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.
@smarcet Yes, that was what was suggested last week and we are working on it. We put it on hold since it would be a massive refactor of all formatters and we wanted to test the entire flow and see logs flowing.
Once we are confident this work we will summit a PR in which we push the switch to the abstract layer, we'll have 3 or 4 more methods inside the interface that will be called in each switch case.
That will give us safety in the sense that everything is being covered and will also make the custom formatters more readable and extendable since all that will be needed will be to implement those methods.
Thanks.
smarcet
left a comment
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.
@andrestejerina97 @martinquiroga-exo please review comments
smarcet
left a comment
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.
LGTM
ref: https://app.clickup.com/t/86b7xjy2r