mirror of
https://github.com/openai/codex.git
synced 2026-11-23 15:18:14 +00:00
[codex] Attribute app-server analytics by thread originator (#29935)
## Why Desktop Work threads and regular Codex threads can share the same app-server connection. App-server analytics currently copy `product_client_id` from connection metadata for every thread-scoped event, so Work thread activity is attributed to the Desktop connection instead of the thread's resolved originator. This prevents analytics from distinguishing the two products on a shared connection. ## What changed - Publish the resolved originator after a thread is materialized, covering new, resumed, forked, and subagent threads. - Store that originator in the analytics reducer's existing per-thread state. - Override only `app_server_client.product_client_id` for thread, turn, tool, review, goal, guardian, and compaction events while preserving the connection's client name, version, and transport metadata. - Fall back to the connection-wide product client ID when a thread has no originator override. - Preserve persisted originators in thread initialization analytics for resume and fork flows. ## Validation - `just test -p codex-analytics thread_originator_overrides_shared_connection_across_thread_events subagent_events_keep_thread_originator_with_explicit_turn_connection` - `just test -p codex-app-server turn_start_tracks_thread_originator_in_analytics thread_start_tracks_thread_initialized_analytics thread_fork_tracks_thread_initialized_analytics thread_resume_tracks_thread_initialized_analytics` - `just test -p codex-core thread_manager`
This commit is contained in:
1 parent
da78d5fdc5
commit
841f30598c
12 files changed
+431
-57
No files matched your search
@@ -435,6 +435,31 @@ impl AnalyticsEventsClient {
|
||||
connection_id: u64,
|
||||
request_id: RequestId,
|
||||
response: ClientResponsePayload,
|
||||
) {
|
||||
self.track_response_inner(
|
||||
connection_id,
|
||||
request_id,
|
||||
response,
|
||||
/*thread_originator*/ None,
|
||||
);
|
||||
}
|
||||
|
||||
pub fn track_response_with_thread_originator(
|
||||
&self,
|
||||
connection_id: u64,
|
||||
request_id: RequestId,
|
||||
response: ClientResponsePayload,
|
||||
thread_originator: String,
|
||||
) {
|
||||
self.track_response_inner(connection_id, request_id, response, Some(thread_originator));
|
||||
}
|
||||
|
||||
fn track_response_inner(
|
||||
&self,
|
||||
connection_id: u64,
|
||||
request_id: RequestId,
|
||||
response: ClientResponsePayload,
|
||||
thread_originator: Option<String>,
|
||||
) {
|
||||
if !matches!(
|
||||
response,
|
||||
@@ -450,6 +475,7 @@ impl AnalyticsEventsClient {
|
||||
connection_id,
|
||||
request_id,
|
||||
response: Box::new(response),
|
||||
thread_originator,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user