mirror of
https://github.com/openai/codex.git
synced 2026-11-25 15:24:26 +00:00
Enrich thread archive analytics with thread context (#39797)
## What changed - Add app-server client, runtime, thread source, and parent thread ID metadata to archive and unarchive analytics events when the reducer has that context. - Omit non-automation feature thread sources and skip unavailable metadata. ## Testing - Cover archive and unarchive event enrichment, filtered feature sources, and threads without cached context. - Verify the app-server archive flow emits the enriched analytics payload. GitOrigin-RevId: 163f9c30721cee0172bb4581b6dcd269e44cd941
This commit is contained in:
1 parent
d9fd91edab
commit
cc801d7048
5 files changed
+198
-12
No files matched your search
@@ -1735,6 +1735,38 @@ impl AnalyticsReducer {
|
||||
);
|
||||
}
|
||||
|
||||
fn thread_archive_event_params(
|
||||
&self,
|
||||
thread_id: String,
|
||||
action: ThreadArchiveAction,
|
||||
) -> ThreadArchiveEventParams {
|
||||
let thread_state = self.threads.get(&thread_id);
|
||||
let connection_state = self
|
||||
.thread_connection_id(&thread_id)
|
||||
.and_then(|connection_id| self.connections.get(&connection_id));
|
||||
let thread_metadata = thread_state.and_then(|thread_state| thread_state.metadata.as_ref());
|
||||
|
||||
ThreadArchiveEventParams {
|
||||
thread_id,
|
||||
action,
|
||||
occurred_at_ms: now_unix_millis(),
|
||||
app_server_client: thread_state
|
||||
.zip(connection_state)
|
||||
.map(|(thread_state, connection_state)| {
|
||||
thread_state.app_server_client(connection_state)
|
||||
}),
|
||||
runtime: connection_state.map(|connection_state| connection_state.runtime.clone()),
|
||||
thread_source: thread_metadata
|
||||
.and_then(|thread_metadata| thread_metadata.thread_source.as_ref())
|
||||
.filter(|thread_source| {
|
||||
!matches!(thread_source, ThreadSource::Feature(feature) if feature != "automation")
|
||||
})
|
||||
.cloned(),
|
||||
parent_thread_id: thread_metadata
|
||||
.and_then(|thread_metadata| thread_metadata.parent_thread_id.clone()),
|
||||
}
|
||||
}
|
||||
|
||||
async fn ingest_notification(
|
||||
&mut self,
|
||||
notification: ServerNotification,
|
||||
@@ -1744,21 +1776,19 @@ impl AnalyticsReducer {
|
||||
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(),
|
||||
},
|
||||
event_params: self.thread_archive_event_params(
|
||||
notification.thread_id,
|
||||
ThreadArchiveAction::Archived,
|
||||
),
|
||||
}));
|
||||
}
|
||||
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(),
|
||||
},
|
||||
event_params: self.thread_archive_event_params(
|
||||
notification.thread_id,
|
||||
ThreadArchiveAction::Unarchived,
|
||||
),
|
||||
}));
|
||||
}
|
||||
ServerNotification::ItemStarted(notification) => {
|
||||
|
||||
Reference in new issue
Block a user