From 0492d528b1c0a83f290e1664b3e9ded21b5cb38c Mon Sep 17 00:00:00 2001
From: Paul W <19602001-paintedbicycle-gitlab@users.noreply.gitlab.com>
Date: Thu, 27 Jun 2024 20:51:22 +0000
Subject: [PATCH] Add tracking and metrics to admin audit events / audit logs
 page

---
 .../events/view_admin_audit_logs_pageload.yml | 16 ++++++++++++++
 ...view_admin_audit_logs_pageload_monthly.yml | 22 +++++++++++++++++++
 ...view_admin_audit_logs_pageload_monthly.yml | 21 ++++++++++++++++++
 ..._view_admin_audit_logs_pageload_weekly.yml | 22 +++++++++++++++++++
 ..._view_admin_audit_logs_pageload_weekly.yml | 21 ++++++++++++++++++
 ee/app/views/admin/audit_logs/index.html.haml |  2 ++
 6 files changed, 104 insertions(+)
 create mode 100644 config/events/view_admin_audit_logs_pageload.yml
 create mode 100644 config/metrics/counts_28d/count_distinct_user_id_from_view_admin_audit_logs_pageload_monthly.yml
 create mode 100644 config/metrics/counts_28d/count_total_view_admin_audit_logs_pageload_monthly.yml
 create mode 100644 config/metrics/counts_7d/count_distinct_user_id_from_view_admin_audit_logs_pageload_weekly.yml
 create mode 100644 config/metrics/counts_7d/count_total_view_admin_audit_logs_pageload_weekly.yml

diff --git a/config/events/view_admin_audit_logs_pageload.yml b/config/events/view_admin_audit_logs_pageload.yml
new file mode 100644
index 000000000000..fc95d49aaf86
--- /dev/null
+++ b/config/events/view_admin_audit_logs_pageload.yml
@@ -0,0 +1,16 @@
+---
+description: Tracks pageviews for the admin audit events / logs page
+internal_events: true
+action: view_admin_audit_logs_pageload
+identifiers:
+- user
+product_group: personal_productivity
+milestone: '17.2'
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/156830
+distributions:
+- ce
+- ee
+tiers:
+- free
+- premium
+- ultimate
diff --git a/config/metrics/counts_28d/count_distinct_user_id_from_view_admin_audit_logs_pageload_monthly.yml b/config/metrics/counts_28d/count_distinct_user_id_from_view_admin_audit_logs_pageload_monthly.yml
new file mode 100644
index 000000000000..6cd4c5da0e99
--- /dev/null
+++ b/config/metrics/counts_28d/count_distinct_user_id_from_view_admin_audit_logs_pageload_monthly.yml
@@ -0,0 +1,22 @@
+---
+key_path: redis_hll_counters.count_distinct_user_id_from_view_admin_audit_logs_pageload_monthly
+description: Monthly count of unique users who visited the admin audit events / audit logs page
+product_group: personal_productivity
+performance_indicator_type: []
+value_type: number
+status: active
+milestone: '17.2'
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/156830
+time_frame: 28d
+data_source: internal_events
+data_category: optional
+distribution:
+- ce
+- ee
+tier:
+- free
+- premium
+- ultimate
+events:
+- name: view_admin_audit_logs_pageload
+  unique: user.id
diff --git a/config/metrics/counts_28d/count_total_view_admin_audit_logs_pageload_monthly.yml b/config/metrics/counts_28d/count_total_view_admin_audit_logs_pageload_monthly.yml
new file mode 100644
index 000000000000..94438249d9b7
--- /dev/null
+++ b/config/metrics/counts_28d/count_total_view_admin_audit_logs_pageload_monthly.yml
@@ -0,0 +1,21 @@
+---
+key_path: counts.count_total_view_admin_audit_logs_pageload_monthly
+description: Monthly count of total users who visited the admin audit events / audit logs page
+product_group: personal_productivity
+performance_indicator_type: []
+value_type: number
+status: active
+milestone: '17.2'
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/156830
+time_frame: 28d
+data_source: internal_events
+data_category: optional
+distribution:
+- ce
+- ee
+tier:
+- free
+- premium
+- ultimate
+events:
+- name: view_admin_audit_logs_pageload
diff --git a/config/metrics/counts_7d/count_distinct_user_id_from_view_admin_audit_logs_pageload_weekly.yml b/config/metrics/counts_7d/count_distinct_user_id_from_view_admin_audit_logs_pageload_weekly.yml
new file mode 100644
index 000000000000..6ddeff804731
--- /dev/null
+++ b/config/metrics/counts_7d/count_distinct_user_id_from_view_admin_audit_logs_pageload_weekly.yml
@@ -0,0 +1,22 @@
+---
+key_path: redis_hll_counters.count_distinct_user_id_from_view_admin_audit_logs_pageload_weekly
+description: Weekly count of unique users who visited the admin audit events / audit logs page
+product_group: personal_productivity
+performance_indicator_type: []
+value_type: number
+status: active
+milestone: '17.2'
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/156830
+time_frame: 7d
+data_source: internal_events
+data_category: optional
+distribution:
+- ce
+- ee
+tier:
+- free
+- premium
+- ultimate
+events:
+- name: view_admin_audit_logs_pageload
+  unique: user.id
diff --git a/config/metrics/counts_7d/count_total_view_admin_audit_logs_pageload_weekly.yml b/config/metrics/counts_7d/count_total_view_admin_audit_logs_pageload_weekly.yml
new file mode 100644
index 000000000000..cfddf83d92ad
--- /dev/null
+++ b/config/metrics/counts_7d/count_total_view_admin_audit_logs_pageload_weekly.yml
@@ -0,0 +1,21 @@
+---
+key_path: counts.count_total_view_admin_audit_logs_pageload_weekly
+description: Weekly count of total users who visited the admin audit events / audit logs page
+product_group: personal_productivity
+performance_indicator_type: []
+value_type: number
+status: active
+milestone: '17.2'
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/156830
+time_frame: 7d
+data_source: internal_events
+data_category: optional
+distribution:
+- ce
+- ee
+tier:
+- free
+- premium
+- ultimate
+events:
+- name: view_admin_audit_logs_pageload
diff --git a/ee/app/views/admin/audit_logs/index.html.haml b/ee/app/views/admin/audit_logs/index.html.haml
index a3a1b0983366..bfd574d441b4 100644
--- a/ee/app/views/admin/audit_logs/index.html.haml
+++ b/ee/app/views/admin/audit_logs/index.html.haml
@@ -1,5 +1,7 @@
 - page_title _('Audit Events')
 
+%div{ data: { event_tracking_load: 'true', event_tracking: 'view_admin_audit_logs_pageload' } }
+
 %h1.page-title.gl-font-size-h-display= _('Instance audit events')
 %p.light
   = _('Track important events in your GitLab instance.')
-- 
GitLab