574400 AI User Metrics Extension

What does this MR do and why?

Expanding on AI Metrics we provide for user

Technical changes:

  • Refactors AiUserMetricsService to accept a feature parameter and execute one query per feature
  • Refactors AiUserMetricsService to use Clickhouse query builder. Which also addresses this priority3 #554058 (closed)
  • Dynamically generates GraphQL types for each registered AI feature using FeatureUserMetricType factory class based on the features defined in AI Tracking Class
  • Implements nested metric types (codeSuggestions, chat, codeReview, agenticChat, etc.) with auto-generated event count fields
  • Adds totalEventCount field at both the top level and per-feature level
  • Deprecates codeSuggestionsAcceptedCount and duoChatInteractionsCount in favor of nested feature metrics
  • References

Screenshots or screen recordings

Before After

How to set up and validate locally

query getUserAiUserMetrics($fullPath: ID!, $startDate: Date!, $endDate: Date!) {
  group(fullPath: $fullPath) {
    id
    aiUserMetrics(startDate: $startDate, endDate: $endDate) {
      nodes {
        user {
          id
          name
        }
        totalEventCount
        codeSuggestions {
          codeSuggestionShownInIdeEventCount
          codeSuggestionAcceptedInIdeEventCount
          codeSuggestionRejectedInIdeEventCount
          totalEventCount
        }
        chat {
          requestDuoChatResponseEventCount
          totalEventCount
        }
        codeReview {
          encounterDuoCodeReviewErrorDuringReviewEventCount
          findNoIssuesDuoCodeReviewAfterReviewEventCount
          findNothingToReviewDuoCodeReviewOnMrEventCount
          postCommentDuoCodeReviewOnDiffEventCount
          reactThumbsUpOnDuoCodeReviewCommentEventCount
          reactThumbsDownOnDuoCodeReviewCommentEventCount
          requestReviewDuoCodeReviewOnMrByAuthorEventCount
          requestReviewDuoCodeReviewOnMrByNonAuthorEventCount
          excludedFilesFromDuoCodeReviewEventCount
          totalEventCount
        }
        agenticChat {
          agentPlatformSessionCreatedEventCount
          agentPlatformSessionStartedEventCount
          agentPlatformSessionFinishedEventCount
          agentPlatformSessionDroppedEventCount
          agentPlatformSessionStoppedEventCount
          agentPlatformSessionResumedEventCount
          totalEventCount
        }
      }
    }
  }
}

Variables:

{ "fullPath": "your-group-path", "startDate": "2025-11-01", "endDate": "2025-11-30" }

Test deprecated fields (still functional):

query {
  group(fullPath: "your-group-path") {
    aiUserMetrics(startDate: "2025-11-01", endDate: "2025-11-30") {
      nodes {
        user { id }
        codeSuggestionsAcceptedCount
        duoChatInteractionsCount
      }
    }
  }
}

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 #574400 (closed)

Edited by Amr Taha

Merge request reports

Loading