Add CodeSuggestions support to GLQL in GitLab UI

What does this MR do and why?

This MR integrates CodeSuggestions analytics into the GitLab UI, enabling users to query Code Suggestions usage data using GLQL in any markdown field. It depends on the backend GraphQL API Expose code suggestions AE to graphql (!226274 - merged) and GLQL MRs Add analytics aggregation support (glql!347 - merged) and Implement CodeSuggestions analytics source (glql!348 - merged).

TODO

What Changed

  • Bumps the GLQL package version to the version that supports CodeSuggestions and analytics mode
  • Added percentage and number presenters for analytics data
  • Updated GLQL parser to handle analytics mode (no default fields for analytics queries)
  • Added transformer support for next pagination in analytics mode
  • Created feature flag: glql_code_suggestion_analytics_aggregation
  • Added frontend tests for new presenters and analytics parsing

References

Screenshots or screen recordings

Scenario GLQL query Output
Every metric and dimension image Google_Chrome_Beta_2026-03-27_12.25.05
In the Data Analyst Agent Requires a lot of cajoling until Data Analyst agent integration for CodeSuggesti... (#592264) is complete Google_Chrome_Beta_2026-03-20_11.59.02 Google_Chrome_Beta_2026-03-20_11.59.29
With feature flag disabled Google_Chrome_Beta_2026-03-19_23.28.55 Google_Chrome_Beta_2026-03-19_23.29.02
Trying to use it outside analytics mode Google_Chrome_Beta_2026-03-19_23.31.18 Google_Chrome_Beta_2026-03-19_23.31.18
Trying to use fields Google_Chrome_Beta_2026-03-19_23.32.04 image
Trying to use dimensions or metrics in standard mode image image

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

UI Testing

  1. Navigate to a seeded projects issue or merge request (by default this is the toolbox group), and go to a markdown enabled field (comments or descriptions for instance)

  2. Test that without the feature flag enabled, the CodeSuggestion type returns an error:

    mode: analytics
    query: type = CodeSuggestion and timestamp >= -30d
    dimensions: language
    metrics: totalCount, acceptanceRate
    sort: totalCount desc
    limit: 10
  3. Enable the feature flag: echo "Feature.enable(:glql_code_suggestion_analytics_aggregation)" | rails c

  4. Refresh the page, test that the query no longer errors and returns results

  5. Now test other variants like: Ide comparison by language

    mode: analytics
    query: type = CodeSuggestion and language in ("ruby", "javascript", "python")
    dimensions: language, ideName
    metrics: totalCount, acceptedCount, rejectedCount, acceptanceRate
    sort: acceptanceRate desc

    Recent activity

    mode: analytics
    query: type = CodeSuggestion and timestamp >= -7d
    dimensions: language
    metrics: totalCount, usersCount, suggestionSizeSum
    sort: usersCount desc
    limit: 5

    User-specific

    mode: analytics
    query: type = CodeSuggestion and user = 2 and timestamp >= -14d
    dimensions: language, ideName
    metrics: totalCount, acceptanceRate, acceptedCount
    sort: totalCount desc
  6. Also verify that percentage presenters like acceptanceRate show as percentages

  7. Also verify that number presenters like totalCount format according to your browser language (e.g. 1,234 or 1.234)

Rest API endpoint

Test the /api/v4/glql REST API endpoint:

# Get a personal access token from GitLab UI: User Settings > Access Tokens

curl -H "PRIVATE-TOKEN: your_token" \
  -H "Content-Type: application/json" \
  -d '{
    "glql_yaml": "query: type = CodeSuggestion and language = \"ruby\"\nmode: \"analytics\"\ndimensions: \"language\"\nmetrics: \"totalCount, acceptanceRate\"\nproject: \"toolbox/gitlab-smoke-tests\""
  }' \
  http://gdk.test:8080/api/v4/glql            

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 GLQL UI integration for CodeSuggestion analytics (#592262)

Edited by Robert Hunt

Merge request reports

Loading