Track thread archive analytics (#37199)

## What changed

- Emit `codex_thread_archive_event` when a thread is successfully archived or
  unarchived, including the thread ID, action, and producer timestamp.
- Route archive notifications through the analytics client while preserving
  normal app-server notification delivery.

## Testing

- Extend app-server coverage for archive and unarchive analytics, including
  descendant archives and a repeated archive request that fails without
  producing another event.

GitOrigin-RevId: 0d973c232fd795b7cd6cddd47ecc9446234c44dd
This commit is contained in:
Eddie Chen authored and copyberry committed 2026-08-06 02:30:18 +00:00
1 parent 547080e4d6
commit 70b4653232
6 files changed
+176 -4

No files matched your search

+24
View File
@@ -51,6 +51,9 @@ use crate::events::ReviewTrigger;
use crate::events::Reviewer;
use crate::events::SkillInvocationEventParams;
use crate::events::SkillInvocationEventRequest;
use crate::events::ThreadArchiveAction;
use crate::events::ThreadArchiveEvent;
use crate::events::ThreadArchiveEventParams;
use crate::events::ThreadInitializedEvent;
use crate::events::ThreadInitializedEventParams;
use crate::events::ToolItemFailureKind;
@@ -98,6 +101,7 @@ use crate::facts::TurnStatus;
use crate::facts::TurnSteerRejectionReason;
use crate::facts::TurnSteerResult;
use crate::facts::TurnTokenUsageFact;
use crate::now_unix_millis;
use crate::now_unix_seconds;
use crate::option_i64_to_u64;
use crate::serialize_enum_as_string;
@@ -1572,6 +1576,26 @@ impl AnalyticsReducer {
out: &mut Vec<TrackEventRequest>,
) {
match notification {
ServerNotification::ThreadArchived(notification) => {
out.push(TrackEventRequest::ThreadArchive(ThreadArchiveEvent {
event_type: "codex_thread_archive_event",
event_params: ThreadArchiveEventParams {
thread_id: notification.thread_id,
action: ThreadArchiveAction::Archived,
occurred_at_ms: now_unix_millis(),
},
}));
}
ServerNotification::ThreadUnarchived(notification) => {
out.push(TrackEventRequest::ThreadArchive(ThreadArchiveEvent {
event_type: "codex_thread_archive_event",
event_params: ThreadArchiveEventParams {
thread_id: notification.thread_id,
action: ThreadArchiveAction::Unarchived,
occurred_at_ms: now_unix_millis(),
},
}));
}
ServerNotification::ItemStarted(notification) => {
let Some(item_id) = tracked_tool_item_id(&notification.item) else {
return;