From 1b82d746cfe4542152e10a28738127b250d46165 Mon Sep 17 00:00:00 2001
From: Paul W <19602001-paintedbicycle-gitlab@users.noreply.gitlab.com>
Date: Mon, 24 Jun 2024 10:22:38 +0000
Subject: [PATCH] Add tracking and metrics to admin gitaly servers page

---
 .../admin/gitaly_servers/index.html.haml      |  2 +-
 .../view_admin_gitaly_servers_pageload.yml    | 16 ++++++++++++++
 ..._admin_gitaly_servers_pageload_monthly.yml | 22 +++++++++++++++++++
 ..._admin_gitaly_servers_pageload_monthly.yml | 21 ++++++++++++++++++
 ...w_admin_gitaly_servers_pageload_weekly.yml | 22 +++++++++++++++++++
 ...w_admin_gitaly_servers_pageload_weekly.yml | 21 ++++++++++++++++++
 6 files changed, 103 insertions(+), 1 deletion(-)
 create mode 100644 config/events/view_admin_gitaly_servers_pageload.yml
 create mode 100644 config/metrics/counts_28d/count_distinct_user_id_from_view_admin_gitaly_servers_pageload_monthly.yml
 create mode 100644 config/metrics/counts_28d/count_total_view_admin_gitaly_servers_pageload_monthly.yml
 create mode 100644 config/metrics/counts_7d/count_distinct_user_id_from_view_admin_gitaly_servers_pageload_weekly.yml
 create mode 100644 config/metrics/counts_7d/count_total_view_admin_gitaly_servers_pageload_weekly.yml

diff --git a/app/views/admin/gitaly_servers/index.html.haml b/app/views/admin/gitaly_servers/index.html.haml
index 0bfa9c207ae33..41f8dea13bb33 100644
--- a/app/views/admin/gitaly_servers/index.html.haml
+++ b/app/views/admin/gitaly_servers/index.html.haml
@@ -4,7 +4,7 @@
 = render ::Layouts::PageHeadingComponent.new(_('Gitaly servers'))
 = render Pajamas::CardComponent.new(card_options: { class: 'gl-new-card' }, header_options: { class: 'gl-new-card-header' }, body_options: { class: 'gl-new-card-body gl-px-0' }) do |c|
   - c.with_header do
-    .gl-new-card-title-wrapper
+    .gl-new-card-title-wrapper{ data: { event_tracking_load: 'true', event_tracking: 'view_admin_gitaly_servers_pageload' } }
       %h3.gl-new-card-title
         = _('Gitaly servers')
       .gl-new-card-count
diff --git a/config/events/view_admin_gitaly_servers_pageload.yml b/config/events/view_admin_gitaly_servers_pageload.yml
new file mode 100644
index 0000000000000..dca034ece20c9
--- /dev/null
+++ b/config/events/view_admin_gitaly_servers_pageload.yml
@@ -0,0 +1,16 @@
+---
+description: Tracks pageviews for the admin gitaly servers page
+internal_events: true
+action: view_admin_gitaly_servers_pageload
+identifiers:
+- user
+product_group: personal_productivity
+milestone: '17.2'
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/156811
+distributions:
+- ce
+- ee
+tiers:
+- free
+- premium
+- ultimate
diff --git a/config/metrics/counts_28d/count_distinct_user_id_from_view_admin_gitaly_servers_pageload_monthly.yml b/config/metrics/counts_28d/count_distinct_user_id_from_view_admin_gitaly_servers_pageload_monthly.yml
new file mode 100644
index 0000000000000..64878c58470a0
--- /dev/null
+++ b/config/metrics/counts_28d/count_distinct_user_id_from_view_admin_gitaly_servers_pageload_monthly.yml
@@ -0,0 +1,22 @@
+---
+key_path: redis_hll_counters.count_distinct_user_id_from_view_admin_gitaly_servers_pageload_monthly
+description: Monthly count of unique users who visit the gitaly servers 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/156811
+time_frame: 28d
+data_source: internal_events
+data_category: optional
+distribution:
+- ce
+- ee
+tier:
+- free
+- premium
+- ultimate
+events:
+- name: view_admin_gitaly_servers_pageload
+  unique: user.id
diff --git a/config/metrics/counts_28d/count_total_view_admin_gitaly_servers_pageload_monthly.yml b/config/metrics/counts_28d/count_total_view_admin_gitaly_servers_pageload_monthly.yml
new file mode 100644
index 0000000000000..bcfb3e952fb2a
--- /dev/null
+++ b/config/metrics/counts_28d/count_total_view_admin_gitaly_servers_pageload_monthly.yml
@@ -0,0 +1,21 @@
+---
+key_path: counts.count_total_view_admin_gitaly_servers_pageload_monthly
+description: Monthly count of total users who visit the gitaly servers 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/156811
+time_frame: 28d
+data_source: internal_events
+data_category: optional
+distribution:
+- ce
+- ee
+tier:
+- free
+- premium
+- ultimate
+events:
+- name: view_admin_gitaly_servers_pageload
diff --git a/config/metrics/counts_7d/count_distinct_user_id_from_view_admin_gitaly_servers_pageload_weekly.yml b/config/metrics/counts_7d/count_distinct_user_id_from_view_admin_gitaly_servers_pageload_weekly.yml
new file mode 100644
index 0000000000000..fc5b10ea26e7d
--- /dev/null
+++ b/config/metrics/counts_7d/count_distinct_user_id_from_view_admin_gitaly_servers_pageload_weekly.yml
@@ -0,0 +1,22 @@
+---
+key_path: redis_hll_counters.count_distinct_user_id_from_view_admin_gitaly_servers_pageload_weekly
+description: Weekly count of unique users who visit the gitaly servers 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/156811
+time_frame: 7d
+data_source: internal_events
+data_category: optional
+distribution:
+- ce
+- ee
+tier:
+- free
+- premium
+- ultimate
+events:
+- name: view_admin_gitaly_servers_pageload
+  unique: user.id
diff --git a/config/metrics/counts_7d/count_total_view_admin_gitaly_servers_pageload_weekly.yml b/config/metrics/counts_7d/count_total_view_admin_gitaly_servers_pageload_weekly.yml
new file mode 100644
index 0000000000000..d678f00d9ac63
--- /dev/null
+++ b/config/metrics/counts_7d/count_total_view_admin_gitaly_servers_pageload_weekly.yml
@@ -0,0 +1,21 @@
+---
+key_path: counts.count_total_view_admin_gitaly_servers_pageload_weekly
+description: Weekly count of total users who visit the gitaly servers 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/156811
+time_frame: 7d
+data_source: internal_events
+data_category: optional
+distribution:
+- ce
+- ee
+tier:
+- free
+- premium
+- ultimate
+events:
+- name: view_admin_gitaly_servers_pageload
-- 
GitLab