Add Duo RCA usage rate to usage metrics table in AI impact analytics
What does this MR do and why?
Adds Duo RCA: Unique users metric to AI impact usage metrics table in the AI impact analytics dashboard behind the duo_rca_usage_rate feature flag.
References
Screenshots or screen recordings
| Before | After |
|---|---|
![]() |
![]() |
How to set up and validate locally
- Please make sure that you're on the GitLab Ultimate plan.
- Configure your GDK to use ClickHouse
- Make sure ClickHouse is being used for Analytics by running this in the Rails console:
Gitlab::CurrentSettings.current_application_settings.update(use_clickhouse_for_analytics: true) Feature.enable(:duo_rca_usage_rate)- Apply the patch below to
- Temporarily fix local bug currently affecting lifecycle metrics
- Mock AI Impact analytics dashboard permissions
- Mock the number of Duo Pro seats included in your subscription (otherwise the metric will show as
0%)
- Seed data:
SEED_GITLAB_DUO=1 FILTER=gitlab_duo bundle exec rake db:seed_fu - Navigate to the AI Impact analytics dashboard for the new group created by the above seeder:
http://${LOCAL_INSTANCE}/groups/gitlab-duo/-/analytics/dashboards/ai_impact - Verify that the
Duo RCA: Unique usersmetric appears in the AI impact usage metrics table
Patch
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb
index 3df7203757a23..aa6a091351e13 100644
--- a/config/initializers/1_settings.rb
+++ b/config/initializers/1_settings.rb
@@ -1365,7 +1365,7 @@
# Bullet settings
#
Settings['bullet'] ||= {}
-Settings.bullet['enabled'] ||= Rails.env.development?
+Settings.bullet['enabled'] = false
#
# Shutdown settings
diff --git a/ee/app/models/ee/user.rb b/ee/app/models/ee/user.rb
index bc355f6b16f29..3cc4aed92766f 100644
--- a/ee/app/models/ee/user.rb
+++ b/ee/app/models/ee/user.rb
@@ -523,6 +523,7 @@ def using_gitlab_com_seat?(namespace)
end
def assigned_to_duo_enterprise?(container)
+ return true
namespace = ::Gitlab::Saas.feature_available?(:gitlab_duo_saas_only) ? container.root_ancestor : nil
GitlabSubscriptions::AddOnPurchase
@@ -533,6 +534,7 @@ def assigned_to_duo_enterprise?(container)
end
def assigned_to_duo_pro?(container)
+ return true
namespace = ::Gitlab::Saas.feature_available?(:gitlab_duo_saas_only) ? container.root_ancestor : nil
GitlabSubscriptions::AddOnPurchase
diff --git a/ee/app/services/analytics/ai_analytics/ai_metrics_service.rb b/ee/app/services/analytics/ai_analytics/ai_metrics_service.rb
index 40e33585d5226..9382d77a90306 100644
--- a/ee/app/services/analytics/ai_analytics/ai_metrics_service.rb
+++ b/ee/app/services/analytics/ai_analytics/ai_metrics_service.rb
@@ -28,13 +28,13 @@ def add_duo_assigned(data)
# TODO: Refactor after https://gitlab.com/gitlab-org/gitlab/-/issues/489759 is done.
# current code assumes that addons are mutually exclusive
- pro_users = GitlabSubscriptions::AddOnAssignedUsersFinder.new(
+ GitlabSubscriptions::AddOnAssignedUsersFinder.new(
current_user, namespace, add_on_name: :code_suggestions).execute
- enterprise_users = GitlabSubscriptions::AddOnAssignedUsersFinder.new(
+ GitlabSubscriptions::AddOnAssignedUsersFinder.new(
current_user, namespace, add_on_name: :duo_enterprise).execute
- data.merge(duo_assigned_users_count: pro_users.count + enterprise_users.count)
+ data.merge(duo_assigned_users_count: 100)
end
def add_usage(data, *service_classes)
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #513252 (closed)
Edited by Rudy Crespo

