Repository navigation
support app usage analytics - #11687
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b6a7e9d121
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if !queue.should_enqueue_app_used(&tracking, &app) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
Record dedupe key only after app-used enqueue succeeds
track_app_used checks should_enqueue_app_used before attempting try_send, and should_enqueue_app_used inserts (turn_id, connector_id) into the dedupe set immediately. When the analytics channel is temporarily full, try_send drops the job but the key is still marked as emitted, so later tool calls for the same app in the same turn are suppressed even after the queue has capacity again, causing silent undercounting of codex_app_used events during backpressure.
Useful? React with 👍 / 👎.
| ); | ||
| } | ||
|
|
||
| pub(crate) fn track_app_mentioned( |
There was a problem hiding this comment.
Why do you need this? can you call the underlying track_app_mentioned directly?
There was a problem hiding this comment.
pub(crate) fn track_app_mentioned is a wrapper around the underlying free function. Since the free function does not have access to self.queue, we need to pass it as a param. Can also move the free function’s logic into this method instead; either should be fine.
| #[derive(Clone)] | ||
| pub(crate) struct AnalyticsEventsQueue { | ||
| sender: mpsc::Sender<TrackEventsJob>, | ||
| app_used_emitted_keys: Arc<Mutex<HashSet<(String, String)>>>, |
There was a problem hiding this comment.
I think it is OK, but just to confirm, this will be cleared when you close codex then resume right?
Emit app mentioned and app used events. Dedup by (turn_id, connector_id)
Example event params:
{
"event_type": "codex_app_used",
"connector_id": "asdk_app_xxx",
"thread_id": "019c5527-36d4-xxx",
"turn_id": "019c552c-cd17-xxx",
"app_name": "Slack (OpenAI Internal)",
"product_client_id": "codex_cli_rs",
"invoke_type": "explicit",
"model_slug": "gpt-5.3-codex"
}