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
Screenshot 2025-05-19 at 5.18.02 PM.png Screenshot 2025-05-19 at 4.57.18 PM.png

How to set up and validate locally

  1. Please make sure that you're on the GitLab Ultimate plan.
  2. Configure your GDK to use ClickHouse
  3. 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)
  4. Feature.enable(:duo_rca_usage_rate)
  5. 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%)
  6. Seed data: SEED_GITLAB_DUO=1 FILTER=gitlab_duo bundle exec rake db:seed_fu
  7. 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
  8. Verify that the Duo RCA: Unique users metric 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

Merge request reports

Loading