From fd1c84119de5dfed7c2041b38d97443810960ceb Mon Sep 17 00:00:00 2001 From: Vishnu Narayanan Date: Fri, 9 Jun 2023 16:38:38 +0530 Subject: [PATCH] feat: add audit for web channel --- app/javascript/dashboard/i18n/locale/en/auditLogs.json | 7 +++++++ .../routes/dashboard/settings/auditlogs/Index.vue | 3 +++ app/models/channel/web_widget.rb | 3 +++ .../app/models/enterprise/audit/channel/web_widget.rb | 7 +++++++ 4 files changed, 20 insertions(+) create mode 100644 enterprise/app/models/enterprise/audit/channel/web_widget.rb diff --git a/app/javascript/dashboard/i18n/locale/en/auditLogs.json b/app/javascript/dashboard/i18n/locale/en/auditLogs.json index b1653e027..daf9f0ddc 100644 --- a/app/javascript/dashboard/i18n/locale/en/auditLogs.json +++ b/app/javascript/dashboard/i18n/locale/en/auditLogs.json @@ -38,6 +38,13 @@ "USER_ACTION": { "SIGN_IN": "%{agentName} signed in", "SIGN_OUT": "%{agentName} signed out" + }, + "CHANNEL": { + "WEB_WIDGET": { + "ADD": "%{agentName} created a new web channel (#%{id})", + "EDIT": "%{agentName} updated a web channel (#%{id})", + "DELETE": "%{agentName} deleted a web channel (#%{id})" + } } } } diff --git a/app/javascript/dashboard/routes/dashboard/settings/auditlogs/Index.vue b/app/javascript/dashboard/routes/dashboard/settings/auditlogs/Index.vue index d7d94f2e8..b03831f58 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/auditlogs/Index.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/auditlogs/Index.vue @@ -127,6 +127,9 @@ export default { 'inbox:destroy': `AUDIT_LOGS.INBOX.DELETE`, 'user:sign_in': `AUDIT_LOGS.USER_ACTION.SIGN_IN`, 'user:sign_out': `AUDIT_LOGS.USER_ACTION.SIGN_OUT`, + 'channel::webwidget:create': `AUDIT_LOGS.CHANNEL.WEB_WIDGET.ADD`, + 'channel::webwidget:update': `AUDIT_LOGS.CHANNEL.WEB_WIDGET.EDIT`, + 'channel::webwidget:destroy': `AUDIT_LOGS.CHANNEL.WEB_WIDGET.DELETE`, }; return this.$t(translationKeys[logActionKey] || '', translationPayload); diff --git a/app/models/channel/web_widget.rb b/app/models/channel/web_widget.rb index a75e979b9..d17389762 100644 --- a/app/models/channel/web_widget.rb +++ b/app/models/channel/web_widget.rb @@ -39,6 +39,7 @@ class Channel::WebWidget < ApplicationRecord { selected_feature_flags: [] }].freeze before_validation :validate_pre_chat_options + belongs_to :account validates :website_url, presence: true validates :widget_color, presence: true @@ -105,3 +106,5 @@ class Channel::WebWidget < ApplicationRecord }).perform end end + +Channel::WebWidget.include_mod_with('Audit::Channel::WebWidget') diff --git a/enterprise/app/models/enterprise/audit/channel/web_widget.rb b/enterprise/app/models/enterprise/audit/channel/web_widget.rb new file mode 100644 index 000000000..76156641d --- /dev/null +++ b/enterprise/app/models/enterprise/audit/channel/web_widget.rb @@ -0,0 +1,7 @@ +module Enterprise::Audit::Channel::WebWidget + extend ActiveSupport::Concern + + included do + audited associated_with: :account + end +end