Add analytics presenters for CodeSuggestion data

What does this MR do and why?

Adds formatted presenters for CodeSuggestion analytics dimensions and metrics. This is the second MR in a stack that adds CodeSuggestion analytics support to the GitLab UI.

All presenter components and field key mappings live in FOSS, gated behind the feature flag added in !233396 (merged).

What Changed

New presenter components

  • NumberPresenter: formats numbers with locale-aware separators using formatNumber (e.g. 1,234,567)
  • PercentagePresenter: converts decimal ratios to percentages, strips trailing .0 for whole numbers (e.g. 0.42542.5%, 1100%)
  • UserAvatarPresenter: renders user dimensions as labeled avatars with GlAvatarLabeled, parsing numeric entity IDs from GID strings

Field key mappings

  • Added analytics field keys to presentersByFieldKey in field.vue: acceptanceRate, totalCount, acceptedCount, rejectedCount, shownCount, usersCount, suggestionSizeSum, user
  • Reordered componentForField to check field key mappings before object type mappings (needed for user field key to resolve to UserAvatarPresenter instead of UserPresenter for analytics dimensions)

Tests

  • Added specs for NumberPresenter, PercentagePresenter, and UserAvatarPresenter
  • Added analytics field key test rows to field_spec.js
  • Added MOCK_ANALYTICS_USER and MOCK_DIMENSIONS test fixtures

MR Stack

  1. !233396 (merged) — Backend + GLQL pipeline
  2. This MR — Analytics presenters
  3. !233398 (merged) — ListBasePresenter extraction + ListDimensionsPresenter

References

Screenshots or screen recordings

Scenario GLQL query Output
Every metric and dimension Google_Chrome_Beta_2026-04-27_14.36.27 Google_Chrome_Beta_2026-03-27_12.25.05

How to set up and validate locally

Prerequisites

  • Setup clickhouse
  • Make sure to run migrations: bundle exec rake gitlab:clickhouse:migrate
  • Enable clickhouse analytics: echo "Gitlab::CurrentSettings.current_application_settings.update(use_clickhouse_for_analytics: true)" | rails c
  • Seed test data: FILTER=ai_usage_stats bundle exec rake db:seed_fu
  • Enable the feature flag: echo "Feature.enable(:glql_code_suggestion_analytics_aggregation)" | rails c

UI Testing

  1. Navigate to a seeded project and open a markdown-enabled field (issue description, comment, etc.)
  2. Enter a GLQL analytics query and verify the presenters render correctly:
    mode: analytics
    query: type = CodeSuggestion and timestamp >= -30d
    dimensions: language
    metrics: totalCount, acceptanceRate
    sort: totalCount desc
    limit: 10
  3. Verify that acceptanceRate shows as a percentage (e.g. 85%)
  4. Verify that totalCount formats with locale-aware separators (e.g. 1,234)
  5. Verify that user dimensions render as labeled avatars
Edited by Robert Hunt

Merge request reports

Loading