mirror of
https://github.com/openai/codex.git
synced 2026-04-24 06:35:50 +00:00
- add event for thread initialization - thread/start, thread/fork, thread/resume - feature flagged behind `FeatureFlag::GeneralAnalytics` - does not yet support threads started by subagents PR stack: - --> [[telemetry] thread events #15690](https://github.com/openai/codex/pull/15690) - [[telemetry] subagent events #15915](https://github.com/openai/codex/pull/15915) - [[telemetry] turn events #15591](https://github.com/openai/codex/pull/15591) - [[telemetry] steer events #15697](https://github.com/openai/codex/pull/15697) - [[telemetry] queued prompt data #15804](https://github.com/openai/codex/pull/15804) Sample extracted logs in Codex-backend ``` INFO | 2026-03-29 16:39:37 | codex_backend.routers.analytics_events | analytics_events.track_analytics_events:398 | Tracked analytics event codex_thread_initialized thread_id=019d3bf7-9f5f-7f82-9877-6d48d1052531 product_surface=codex product_client_id=CODEX_CLI client_name=codex-tui client_version=0.0.0 rpc_transport=in_process experimental_api_enabled=True codex_rs_version=0.0.0 runtime_os=macos runtime_os_version=26.4.0 runtime_arch=aarch64 model=gpt-5.3-codex ephemeral=False thread_source=user initialization_mode=new subagent_source=None parent_thread_id=None created_at=1774827577 | INFO | 2026-03-29 16:45:46 | codex_backend.routers.analytics_events | analytics_events.track_analytics_events:398 | Tracked analytics event codex_thread_initialized thread_id=019d3b84-5731-79d0-9b3b-9c6efe5f5066 product_surface=codex product_client_id=CODEX_CLI client_name=codex-tui client_version=0.0.0 rpc_transport=in_process experimental_api_enabled=True codex_rs_version=0.0.0 runtime_os=macos runtime_os_version=26.4.0 runtime_arch=aarch64 model=gpt-5.3-codex ephemeral=False thread_source=user initialization_mode=resumed subagent_source=None parent_thread_id=None created_at=1774820022 | INFO | 2026-03-29 16:45:49 | codex_backend.routers.analytics_events | analytics_events.track_analytics_events:398 | Tracked analytics event codex_thread_initialized thread_id=019d3bfd-4cd6-7c12-a13e-48cef02e8c4d product_surface=codex product_client_id=CODEX_CLI client_name=codex-tui client_version=0.0.0 rpc_transport=in_process experimental_api_enabled=True codex_rs_version=0.0.0 runtime_os=macos runtime_os_version=26.4.0 runtime_arch=aarch64 model=gpt-5.3-codex ephemeral=False thread_source=user initialization_mode=forked subagent_source=None parent_thread_id=None created_at=1774827949 | INFO | 2026-03-29 17:20:29 | codex_backend.routers.analytics_events | analytics_events.track_analytics_events:398 | Tracked analytics event codex_thread_initialized thread_id=019d3c1d-0412-7ed2-ad24-c9c0881a36b0 product_surface=codex product_client_id=CODEX_SERVICE_EXEC client_name=codex_exec client_version=0.0.0 rpc_transport=in_process experimental_api_enabled=True codex_rs_version=0.0.0 runtime_os=macos runtime_os_version=26.4.0 runtime_arch=aarch64 model=gpt-5.3-codex ephemeral=False thread_source=user initialization_mode=new subagent_source=None parent_thread_id=None created_at=1774830027 | ``` Notes - `product_client_id` gets canonicalized in codex-backend - subagent threads are addressed in a following pr
117 lines
2.8 KiB
Rust
117 lines
2.8 KiB
Rust
use crate::events::AppServerRpcTransport;
|
|
use crate::events::CodexRuntimeMetadata;
|
|
use codex_app_server_protocol::ClientRequest;
|
|
use codex_app_server_protocol::ClientResponse;
|
|
use codex_app_server_protocol::InitializeParams;
|
|
use codex_app_server_protocol::RequestId;
|
|
use codex_app_server_protocol::ServerNotification;
|
|
use codex_plugin::PluginTelemetryMetadata;
|
|
use codex_protocol::protocol::SkillScope;
|
|
use serde::Serialize;
|
|
use std::path::PathBuf;
|
|
|
|
#[derive(Clone)]
|
|
pub struct TrackEventsContext {
|
|
pub model_slug: String,
|
|
pub thread_id: String,
|
|
pub turn_id: String,
|
|
}
|
|
|
|
pub fn build_track_events_context(
|
|
model_slug: String,
|
|
thread_id: String,
|
|
turn_id: String,
|
|
) -> TrackEventsContext {
|
|
TrackEventsContext {
|
|
model_slug,
|
|
thread_id,
|
|
turn_id,
|
|
}
|
|
}
|
|
|
|
#[derive(Clone, Debug)]
|
|
pub struct SkillInvocation {
|
|
pub skill_name: String,
|
|
pub skill_scope: SkillScope,
|
|
pub skill_path: PathBuf,
|
|
pub invocation_type: InvocationType,
|
|
}
|
|
|
|
#[derive(Clone, Copy, Debug, Serialize)]
|
|
#[serde(rename_all = "lowercase")]
|
|
pub enum InvocationType {
|
|
Explicit,
|
|
Implicit,
|
|
}
|
|
|
|
pub struct AppInvocation {
|
|
pub connector_id: Option<String>,
|
|
pub app_name: Option<String>,
|
|
pub invocation_type: Option<InvocationType>,
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub(crate) enum AnalyticsFact {
|
|
Initialize {
|
|
connection_id: u64,
|
|
params: InitializeParams,
|
|
product_client_id: String,
|
|
runtime: CodexRuntimeMetadata,
|
|
rpc_transport: AppServerRpcTransport,
|
|
},
|
|
Request {
|
|
connection_id: u64,
|
|
request_id: RequestId,
|
|
request: Box<ClientRequest>,
|
|
},
|
|
Response {
|
|
connection_id: u64,
|
|
response: Box<ClientResponse>,
|
|
},
|
|
Notification(Box<ServerNotification>),
|
|
// Facts that do not naturally exist on the app-server protocol surface, or
|
|
// would require non-trivial protocol reshaping on this branch.
|
|
Custom(CustomAnalyticsFact),
|
|
}
|
|
|
|
pub(crate) enum CustomAnalyticsFact {
|
|
SkillInvoked(SkillInvokedInput),
|
|
AppMentioned(AppMentionedInput),
|
|
AppUsed(AppUsedInput),
|
|
PluginUsed(PluginUsedInput),
|
|
PluginStateChanged(PluginStateChangedInput),
|
|
}
|
|
|
|
pub(crate) struct SkillInvokedInput {
|
|
pub tracking: TrackEventsContext,
|
|
pub invocations: Vec<SkillInvocation>,
|
|
}
|
|
|
|
pub(crate) struct AppMentionedInput {
|
|
pub tracking: TrackEventsContext,
|
|
pub mentions: Vec<AppInvocation>,
|
|
}
|
|
|
|
pub(crate) struct AppUsedInput {
|
|
pub tracking: TrackEventsContext,
|
|
pub app: AppInvocation,
|
|
}
|
|
|
|
pub(crate) struct PluginUsedInput {
|
|
pub tracking: TrackEventsContext,
|
|
pub plugin: PluginTelemetryMetadata,
|
|
}
|
|
|
|
pub(crate) struct PluginStateChangedInput {
|
|
pub plugin: PluginTelemetryMetadata,
|
|
pub state: PluginState,
|
|
}
|
|
|
|
#[derive(Clone, Copy)]
|
|
pub(crate) enum PluginState {
|
|
Installed,
|
|
Uninstalled,
|
|
Enabled,
|
|
Disabled,
|
|
}
|