aKode fase 2c: eliminato il codice di invio dati (crate analytics, otel-trace-websocket, sentry, esportatori OTLP); /feedback salva solo in locale; chiavi legacy [analytics]/[otel] accettate e ignorate; test di analytics/OTLP/upload rimossi
Some checks failed
blocking-ci / rust-ci (push) Has been cancelled
blocking-ci / sdk (push) Has been cancelled
blocking-ci / CI required (push) Has been cancelled
blocking-ci / Bazel (push) Has been cancelled
blocking-ci / Blob size policy (push) Has been cancelled
blocking-ci / cargo-deny (push) Has been cancelled
blocking-ci / Codespell (push) Has been cancelled
blocking-ci / repo-checks (push) Has been cancelled
postmerge-ci / rust-ci-full (push) Has been cancelled
postmerge-ci / v8-canary (push) Has been cancelled
postmerge-ci / Postmerge CI results (push) Has been cancelled
Some checks failed
blocking-ci / rust-ci (push) Has been cancelled
blocking-ci / sdk (push) Has been cancelled
blocking-ci / CI required (push) Has been cancelled
blocking-ci / Bazel (push) Has been cancelled
blocking-ci / Blob size policy (push) Has been cancelled
blocking-ci / cargo-deny (push) Has been cancelled
blocking-ci / Codespell (push) Has been cancelled
blocking-ci / repo-checks (push) Has been cancelled
postmerge-ci / rust-ci-full (push) Has been cancelled
postmerge-ci / v8-canary (push) Has been cancelled
postmerge-ci / Postmerge CI results (push) Has been cancelled
This commit is contained in:
@@ -6,9 +6,7 @@ use std::future::Future;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use codex_analytics::CompactionTrigger;
|
||||
use codex_analytics::HookRunFact;
|
||||
use codex_analytics::build_track_events_context;
|
||||
use crate::compaction_metadata::CompactionTrigger;
|
||||
use codex_hooks::InterruptRequest;
|
||||
use codex_hooks::PermissionRequestDecision;
|
||||
use codex_hooks::PermissionRequestOutcome;
|
||||
@@ -962,7 +960,6 @@ pub(crate) async fn emit_hook_completed_events(
|
||||
|
||||
for completed in completed_events {
|
||||
emit_hook_completed_metrics(turn_context, &completed);
|
||||
track_hook_completed_analytics(sess, turn_context, &completed);
|
||||
if should_emit_hook_notification(&completed.run) {
|
||||
sess.send_event(turn_context, EventMsg::HookCompleted(completed))
|
||||
.await;
|
||||
@@ -986,44 +983,6 @@ fn emit_hook_completed_metrics(turn_context: &TurnContext, completed: &HookCompl
|
||||
}
|
||||
}
|
||||
|
||||
fn track_hook_completed_analytics(
|
||||
sess: &Arc<Session>,
|
||||
turn_context: &Arc<TurnContext>,
|
||||
completed: &HookCompletedEvent,
|
||||
) {
|
||||
let (tracking, hook) =
|
||||
hook_run_analytics_payload(sess.thread_id.to_string(), turn_context, completed);
|
||||
sess.services
|
||||
.analytics_events_client
|
||||
.track_hook_run(tracking, hook);
|
||||
}
|
||||
|
||||
fn hook_run_analytics_payload(
|
||||
thread_id: String,
|
||||
turn_context: &TurnContext,
|
||||
completed: &HookCompletedEvent,
|
||||
) -> (codex_analytics::TrackEventsContext, HookRunFact) {
|
||||
(
|
||||
build_track_events_context(
|
||||
turn_context.model_info().slug.clone(),
|
||||
thread_id,
|
||||
completed
|
||||
.turn_id
|
||||
.clone()
|
||||
.unwrap_or_else(|| turn_context.sub_id.clone()),
|
||||
turn_context.originator.clone(),
|
||||
/*turn_metadata*/ None,
|
||||
),
|
||||
HookRunFact {
|
||||
event_name: completed.run.event_name,
|
||||
hook_source: completed.run.source,
|
||||
handler_type: completed.run.handler_type,
|
||||
execution_mode: completed.run.execution_mode,
|
||||
status: completed.run.status,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
fn hook_run_metric_tags(run: &HookRunSummary) -> [(&'static str, &'static str); 5] {
|
||||
let hook_name = match run.event_name {
|
||||
HookEventName::PreToolUse => "PreToolUse",
|
||||
@@ -1177,9 +1136,7 @@ mod tests {
|
||||
use super::additional_context_messages;
|
||||
use super::emit_hook_completed_events;
|
||||
use super::emit_hook_started_events;
|
||||
use super::hook_run_analytics_payload;
|
||||
use super::hook_run_metric_tags;
|
||||
use crate::session::tests::make_session_and_context;
|
||||
use crate::session::tests::make_session_and_context_with_rx;
|
||||
use codex_protocol::protocol::HookCompletedEvent;
|
||||
use codex_protocol::protocol::HookRunSummary;
|
||||
@@ -1329,47 +1286,8 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn hook_run_analytics_payload_uses_completed_turn_id() {
|
||||
let (_session, turn_context) = make_session_and_context().await;
|
||||
let completed = HookCompletedEvent {
|
||||
turn_id: Some("turn-from-hook".to_string()),
|
||||
run: sample_hook_run(HookRunStatus::Blocked, HookSource::Project),
|
||||
};
|
||||
|
||||
let (tracking, hook) =
|
||||
hook_run_analytics_payload("thread-123".to_string(), &turn_context, &completed);
|
||||
|
||||
assert_eq!(tracking.thread_id, "thread-123");
|
||||
assert_eq!(tracking.turn_id, "turn-from-hook");
|
||||
assert_eq!(tracking.model_slug, turn_context.model_info().slug);
|
||||
assert_eq!(hook.event_name, HookEventName::Stop);
|
||||
assert_eq!(hook.handler_type, HookHandlerType::Command);
|
||||
assert_eq!(hook.execution_mode, HookExecutionMode::Sync);
|
||||
assert_eq!(hook.hook_source, HookSource::Project);
|
||||
assert_eq!(hook.status, HookRunStatus::Blocked);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn hook_run_analytics_payload_falls_back_to_turn_context_id() {
|
||||
let (_session, turn_context) = make_session_and_context().await;
|
||||
let mut run = sample_hook_run(HookRunStatus::Failed, HookSource::Unknown);
|
||||
run.handler_type = HookHandlerType::Prompt;
|
||||
run.execution_mode = HookExecutionMode::Async;
|
||||
let completed = HookCompletedEvent { turn_id: None, run };
|
||||
|
||||
let (tracking, hook) =
|
||||
hook_run_analytics_payload("thread-123".to_string(), &turn_context, &completed);
|
||||
|
||||
assert_eq!(tracking.turn_id, turn_context.sub_id);
|
||||
assert_eq!(hook.handler_type, HookHandlerType::Prompt);
|
||||
assert_eq!(hook.execution_mode, HookExecutionMode::Async);
|
||||
assert_eq!(hook.hook_source, HookSource::Unknown);
|
||||
assert_eq!(hook.status, HookRunStatus::Failed);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hook_run_metric_tags_match_analytics_shape() {
|
||||
fn hook_run_metric_tags_match_expected_shape() {
|
||||
let mut run = sample_hook_run(HookRunStatus::Blocked, HookSource::Project);
|
||||
run.handler_type = HookHandlerType::McpTool;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user