feat: Audit Logs for Account User Changes (#7405)

- Audit log for user invitations: https://linear.app/chatwoot/issue/CW-1768/invited-a-user-to-the-account
- Audit log for change role: https://linear.app/chatwoot/issue/CW-1767/name-or-email-changed-the-role-of-the-user-email-to-agent-or-admin
- Audit log for status change: https://linear.app/chatwoot/issue/CW-1766/availability-status-as-events-for-audit-logs


Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
This commit is contained in:
Sojan Jose
2023-06-28 22:42:06 +05:30
committed by GitHub
parent d05c953eef
commit 40830046e8
13 changed files with 384 additions and 46 deletions

View File

@@ -0,0 +1,13 @@
module Enterprise::Audit::AccountUser
extend ActiveSupport::Concern
included do
audited only: [
:availability,
:role,
:account_id,
:inviter_id,
:user_id
], on: [:create, :update], associated_with: :account
end
end

View File

@@ -2,12 +2,13 @@ module Enterprise::Audit::User
extend ActiveSupport::Concern
included do
# required only for sign_in and sign_out events, which we are logging manually
# hence the proc that always returns false
audited only: [
:availability,
:display_name,
:email,
:name
]
audited associated_with: :account
], unless: proc { |_u| true }
end
end

View File

@@ -7,6 +7,7 @@ json.audit_logs do
json.id audit_log.id
json.auditable_id audit_log.auditable_id
json.auditable_type audit_log.auditable_type
json.auditable audit_log.auditable.try(:push_event_data)
json.associated_id audit_log.associated_id
json.associated_type audit_log.associated_type
json.user_id audit_log.user_id