Add worktree classification to thread telemetry (#43621)

## What changed

Add `is_worktree` to thread initialization analytics and the `codex.thread.started` metric using validated Git repository metadata. Classify linked worktrees as `true` and primary checkouts as `false`; report an unavailable classification as `null` in analytics and `unknown` in metrics. Subagent initialization analytics leave the field unset (`null`).

## Testing

Add analytics coverage for primary checkouts, linked worktrees, unknown repositories, and event serialization. Extend the account-switch telemetry test to check that the `is_worktree` tag reaches the next account's collector.

GitOrigin-RevId: bc9bcd3c0212c0a123e4bcfed0c7020eef17dda6
This commit is contained in:
Benjamin Carlsson authored and copyberry committed 2026-09-07 23:38:35 +00:00
1 parent c977cc0c19
commit 4b0f44d304
5 files changed
+90 -8

No files matched your search

+6
View File
@@ -2102,6 +2102,11 @@ impl AnalyticsReducer {
out: &mut Vec<TrackEventRequest>,
) {
let session_source: SessionSource = thread.source.into();
let is_worktree =
codex_git_utils::repository_identity(thread.cwd.as_path()).and_then(|_| {
codex_git_utils::get_git_repo_root(thread.cwd.canonicalize().ok()?.as_path())
.map(|root| root.join(".git").is_file())
});
let session_id = thread.session_id;
let thread_id = thread.id;
let parent_thread_id = thread.parent_thread_id;
@@ -2133,6 +2138,7 @@ impl AnalyticsReducer {
runtime: connection_state.runtime.clone(),
model,
ephemeral: thread.ephemeral,
is_worktree,
thread_source: thread_metadata.thread_source,
initialization_mode,
subagent_source: thread_metadata.subagent_source.clone(),