Add AiTracking for Duo Chat tool calls

What does this MR do and why?

Web Chat already emits tool_succeeded_duo_chat and tool_failed_duo_chat. Those events never reached ClickHouse because they were not registered in AiTracking.

This registers them as event IDs 48 and 49 and allowlists session_id, tool_name, flow_type, trigger_source, and model in extras. After this ships, someone with ClickHouse access can list the tools used in a given chat session.

This does not add GLQL dimensions. Tool names stay in extras, same as MCP tool calls.

Because these are registered under the chat feature, Chat event totals (for example totalEventCount in user metrics) will now include tool calls. The Duo Chat adoption count is unaffected since it only counts request_duo_chat_response.

References

#626895 (closed)

Screenshots or screen recordings

Not applicable. Tracking-only change, no UI.

How to set up and validate locally

  1. Enable ClickHouse in GDK if it is not already on.
  2. In rails console:
    Gitlab::InternalEvents.track_event(
      'tool_succeeded_duo_chat',
      user: User.first,
      project: Project.first,
      additional_properties: {
        session_id: '42',
        tool_name: 'create_issue',
        flow_type: 'chat',
        trigger_source: 'web_chat',
        model: 'claude-3-5-sonnet'
      }
    )
  3. Confirm extras on the stored event:
    Ai::UsageEvent.last.slice('event', 'extras')
    Expected extras include integer session_id: 42, tool_name: "create_issue", and model: "claude-3-5-sonnet".
  4. After the ClickHouse write buffer flushes, the same row should appear in ai_usage_events as event 48.

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.

Edited by Dasha Adushkina

Merge request reports

Loading
Loading