Add invocation_source to gitlab_cli_command_used

What does this MR do and why?

Declares one new additional_properties entry, invocation_source, on the existing gitlab_cli_command_used event. No new event, no new metric, no code change.

The GitLab CLI's MCP server executes a tool call by spawning the glab binary, so an MCP tool call already emits gitlab_cli_command_used today. The problem is that it is indistinguishable from the same command typed by a user: both carry the same command_and_subcommand, and the spawned process inherits the calling agent's environment, so coding_agent matches as well.

That means we can currently see "an agent ran glab mr list" but not whether it went through the MCP server or the agent just shelled out to the CLI. Those are different products to plan for, and we cannot measure which MCP tools are actually used.

glab will send invocation_source to separate them. Because command_and_subcommand already carries the command path, and MCP tool names map onto it one to one (glab_mr_list is mr list), this single property is enough for per-tool usage.

Captured against a local collector on the glab branch, same command three ways:

command coding_agent invocation_source
mr list typed directly claude-code absent
mr list via MCP tool call claude-code mcp
mcp serve (the session itself) claude-code absent

Why this MR goes first

Gitlab::Tracking::EventValidator#validate_additional_properties! raises InvalidPropertyError via track_and_raise_for_dev_exception for any property not declared here. In production that reports rather than raises, so events would still land, but every MCP tool call would report an error. Agents issue far more commands than people do.

So this needs to merge before the CLI side, which is in draft for that reason.

Screenshots or screen recordings

Not applicable, no user-facing change.

How to set up and validate locally

Gitlab::Tracking::EventDefinition.find('gitlab_cli_command_used').additional_properties.keys
# => includes "invocation_source"

MR acceptance checklist

  • Follows the event definition guide
  • Property is optional and omitted when not applicable, matching coding_agent
  • Analytics Instrumentation review

Merge request reports

Loading
Loading