-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
feat: add support for audit log #3547
Conversation
@asbiin the code is not ready to review yet, but please read the description, and let me know what you think. |
…o 2020-02-02-audit-log
@asbiin ready for review! |
Alright so I still need to add tests for the controllers. But the rest of the code is ready for review. Sorry for the size of this PR. |
@asbiin ready! |
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.
Just some little changes
That's really great! |
Exactly. Simply dispatch the job with the proper payload and that's it. |
@asbiin The API documentation also has been written in the marketing website. |
Kudos, SonarCloud Quality Gate passed!
|
This pull request has been automatically locked since there |
This PR adds the concept of audit logs.
An audit log is a message explaining what a user did by using the application.
For instance, when creating a new contact, an audit log would be created that would log
User X has created contact Y
. This is useful for two important points:We will display logs in three places:
For the scope of this PR, I've only added one action: creating a contact. Once it’s merged, we'll be able to do it for all the other actions.
How it works:
It’s simple. We have a new model called
AuditLog
, which containscontact_created
). This will be used to generate the right sentence that will explain what the user didAudit logs are created inside Services. You need to call the job called
LogAccountAudit
and dispatch it. This job in itself does nothing - it just calls a new service that will handle all the heavy load:LogAccountAction
which actually creates the audit log.The only drawback is that we need to add a new parameter when calling a service:
author_id
, which is actually the id of the user who does the action. We have to, otherwise we won't know who did the action. This will require that we change most of the current services to support this. I've done it for the CreateContact service in the scope of this PR.To display an audit log, we need to "process" it, as we store a key (the action) and a JSON to describe it. This is the responsability of the
AuditLogHelper
, a new helper that takes those two and translates them in a human readable sentence.How to use
For every service, we simply need to dispatch the
LogAccountAudit
job with the right parameters and that's it. It’s really simple, and everything will be taken care of.In the Settings page:
In the Contact new History tab:
Checklist
vCard
and.csv
files.UNRELEASED
.