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,7 +6,6 @@ use app_test_support::ChatGptAuthFixture;
|
||||
use app_test_support::MockResponsesConfig;
|
||||
use app_test_support::TestAppServer;
|
||||
use app_test_support::create_mock_responses_server_repeating_assistant;
|
||||
use app_test_support::start_analytics_events_server;
|
||||
use app_test_support::write_chatgpt_auth;
|
||||
#[cfg(unix)]
|
||||
use codex_app_server_protocol::ConfigReadParams;
|
||||
@@ -57,8 +56,6 @@ use tempfile::TempDir;
|
||||
use tokio::io::AsyncWriteExt;
|
||||
use tokio::time::timeout;
|
||||
|
||||
use super::analytics::wait_for_analytics_event;
|
||||
|
||||
const DEFAULT_TIMEOUT: Duration = Duration::from_secs(60);
|
||||
const SECONDARY_MIGRATION_SOURCE: &str = concat!("cur", "sor");
|
||||
|
||||
@@ -1325,18 +1322,10 @@ async fn external_agent_config_import_reports_failed_sync_import_in_completion()
|
||||
)?;
|
||||
std::fs::write(codex_home.path().join("config.toml"), "invalid = [")?;
|
||||
let home_dir = codex_home.path().display().to_string();
|
||||
let analytics_capture_file = codex_home.path().join("analytics-events.jsonl");
|
||||
let analytics_capture_file = analytics_capture_file.display().to_string();
|
||||
let mut mcp = TestAppServer::builder()
|
||||
.with_codex_home(codex_home.path())
|
||||
.without_auto_env()
|
||||
.with_env_overrides(&[
|
||||
("HOME", Some(home_dir.as_str())),
|
||||
(
|
||||
"CODEX_ANALYTICS_EVENTS_CAPTURE_FILE",
|
||||
Some(analytics_capture_file.as_str()),
|
||||
),
|
||||
])
|
||||
.with_env_overrides(&[("HOME", Some(home_dir.as_str()))])
|
||||
.build_initialized_with_timeout(DEFAULT_TIMEOUT)
|
||||
.await?;
|
||||
|
||||
@@ -1399,63 +1388,13 @@ async fn external_agent_config_import_reports_failed_sync_import_in_completion()
|
||||
assert!(commands_result.successes.is_empty());
|
||||
assert!(commands_result.failures.is_empty());
|
||||
|
||||
let events = timeout(DEFAULT_TIMEOUT, async {
|
||||
loop {
|
||||
let contents = match std::fs::read_to_string(&analytics_capture_file) {
|
||||
Ok(contents) => contents,
|
||||
Err(err) if err.kind() == std::io::ErrorKind::NotFound => {
|
||||
tokio::time::sleep(Duration::from_millis(25)).await;
|
||||
continue;
|
||||
}
|
||||
Err(err) => return Err(err.into()),
|
||||
};
|
||||
let mut captured_events = Vec::new();
|
||||
for line in contents.lines() {
|
||||
let payload: serde_json::Value = serde_json::from_str(line)?;
|
||||
let Some(events) = payload["events"].as_array() else {
|
||||
continue;
|
||||
};
|
||||
captured_events.extend(events.iter().cloned());
|
||||
}
|
||||
if captured_events.iter().any(|event| {
|
||||
event["event_type"] == "codex_onboarding_external_agent_import_complete"
|
||||
&& event["event_params"]["type"] == "COMMANDS"
|
||||
}) {
|
||||
return Ok::<Vec<serde_json::Value>, anyhow::Error>(captured_events);
|
||||
}
|
||||
tokio::time::sleep(Duration::from_millis(25)).await;
|
||||
}
|
||||
})
|
||||
.await??;
|
||||
let event = events
|
||||
.iter()
|
||||
.find(|event| {
|
||||
event["event_type"] == "codex_onboarding_external_agent_import_failure"
|
||||
&& event["event_params"]["type"] == "CONFIG"
|
||||
})
|
||||
.expect("config failure analytics event");
|
||||
let event_params = &event["event_params"];
|
||||
assert_eq!(event_params["import_id"], import_id);
|
||||
assert_eq!(event_params["source"], "test_import");
|
||||
assert_eq!(event_params["provider_id"], "test-provider-42");
|
||||
assert_eq!(event_params["type"], "CONFIG");
|
||||
assert_eq!(event_params["failure_stage"], "import_request_failed");
|
||||
assert_eq!(event_params["error_type"], "invalid_existing_config");
|
||||
assert!(event_params.get("raw_errors").is_none());
|
||||
assert!(event_params.get("message").is_none());
|
||||
assert!(!events.iter().any(|event| {
|
||||
event["event_type"] == "codex_onboarding_external_agent_import_failure"
|
||||
&& event["event_params"]["type"] == "COMMANDS"
|
||||
}));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn external_agent_config_import_completed_tracks_analytics_event() -> Result<()> {
|
||||
let analytics_server = start_analytics_events_server().await?;
|
||||
async fn external_agent_config_import_reports_missing_session_in_completion() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
write_analytics_config(codex_home.path(), &analytics_server.uri())?;
|
||||
std::fs::write(codex_home.path().join("config.toml"), "")?;
|
||||
write_chatgpt_auth(
|
||||
codex_home.path(),
|
||||
ChatGptAuthFixture::new("chatgpt-token")
|
||||
@@ -1518,46 +1457,13 @@ async fn external_agent_config_import_completed_tracks_analytics_event() -> Resu
|
||||
Some("session_not_detected")
|
||||
);
|
||||
|
||||
let event = wait_for_analytics_event(
|
||||
&analytics_server,
|
||||
DEFAULT_TIMEOUT,
|
||||
"codex_onboarding_external_agent_import_complete",
|
||||
)
|
||||
.await?;
|
||||
let event_params = &event["event_params"];
|
||||
assert_eq!(event_params["import_id"], serde_json::json!(import_id));
|
||||
assert_eq!(event_params["source"], "test_import");
|
||||
assert_eq!(event_params["provider_id"], "test-provider-42");
|
||||
assert_eq!(event_params["type"], "SESSIONS");
|
||||
assert_eq!(event_params["success_count"], 0);
|
||||
assert_eq!(event_params["failed_count"], 1);
|
||||
assert!(event_params.get("raw_errors").is_none());
|
||||
|
||||
let event = wait_for_analytics_event(
|
||||
&analytics_server,
|
||||
DEFAULT_TIMEOUT,
|
||||
"codex_onboarding_external_agent_import_failure",
|
||||
)
|
||||
.await?;
|
||||
let event_params = &event["event_params"];
|
||||
assert_eq!(event_params["import_id"], serde_json::json!(import_id));
|
||||
assert_eq!(event_params["source"], "test_import");
|
||||
assert_eq!(event_params["provider_id"], "test-provider-42");
|
||||
assert_eq!(event_params["type"], "SESSIONS");
|
||||
assert_eq!(event_params["failure_stage"], "session_missing");
|
||||
assert_eq!(event_params["error_type"], "session_missing");
|
||||
assert_eq!(event_params["sub_error_type"], "session_not_detected");
|
||||
assert!(event_params.get("raw_errors").is_none());
|
||||
assert!(event_params.get("message").is_none());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn external_agent_config_import_reports_session_config_error_subtype() -> Result<()> {
|
||||
let analytics_server = start_analytics_events_server().await?;
|
||||
let codex_home = TempDir::new()?;
|
||||
write_analytics_config(codex_home.path(), &analytics_server.uri())?;
|
||||
std::fs::write(codex_home.path().join("config.toml"), "")?;
|
||||
write_chatgpt_auth(
|
||||
codex_home.path(),
|
||||
ChatGptAuthFixture::new("chatgpt-token")
|
||||
@@ -1636,33 +1542,13 @@ async fn external_agent_config_import_reports_session_config_error_subtype() ->
|
||||
Some("failed_to_load_session_config_invalid_data")
|
||||
);
|
||||
|
||||
let event = wait_for_analytics_event(
|
||||
&analytics_server,
|
||||
DEFAULT_TIMEOUT,
|
||||
"codex_onboarding_external_agent_import_failure",
|
||||
)
|
||||
.await?;
|
||||
let event_params = &event["event_params"];
|
||||
assert_eq!(event_params["import_id"], serde_json::json!(import_id));
|
||||
assert_eq!(event_params["source"], "test_import");
|
||||
assert_eq!(event_params["provider_id"], "test-provider-42");
|
||||
assert_eq!(event_params["type"], "SESSIONS");
|
||||
assert_eq!(event_params["failure_stage"], "session_persist");
|
||||
assert_eq!(
|
||||
event_params["sub_error_type"],
|
||||
"failed_to_load_session_config_invalid_data"
|
||||
);
|
||||
assert!(event_params.get("raw_errors").is_none());
|
||||
assert!(event_params.get("message").is_none());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn external_agent_config_import_reinstalls_plugins_from_known_marketplaces() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
let analytics_server = start_analytics_events_server().await?;
|
||||
write_analytics_config(codex_home.path(), &analytics_server.uri())?;
|
||||
std::fs::write(codex_home.path().join("config.toml"), "")?;
|
||||
write_chatgpt_auth(
|
||||
codex_home.path(),
|
||||
ChatGptAuthFixture::new("chatgpt-token")
|
||||
@@ -1802,30 +1688,6 @@ async fn external_agent_config_import_reinstalls_plugins_from_known_marketplaces
|
||||
"plugin `missing` was not found in marketplace `debug`"
|
||||
);
|
||||
|
||||
let event = wait_for_analytics_event(
|
||||
&analytics_server,
|
||||
DEFAULT_TIMEOUT,
|
||||
"codex_plugin_install_failed",
|
||||
)
|
||||
.await?;
|
||||
let event_params = &event["event_params"];
|
||||
assert_eq!(event_params["plugin_id"], "missing@debug");
|
||||
assert_eq!(event_params["plugin_name"], "missing");
|
||||
assert_eq!(event_params["marketplace_name"], "debug");
|
||||
assert_eq!(event_params["source"], "external_agent_migration");
|
||||
assert_eq!(event_params["error_type"], "plugin_not_found");
|
||||
|
||||
let event = wait_for_analytics_event(
|
||||
&analytics_server,
|
||||
DEFAULT_TIMEOUT,
|
||||
"codex_onboarding_external_agent_import_failure",
|
||||
)
|
||||
.await?;
|
||||
let event_params = &event["event_params"];
|
||||
assert_eq!(event_params["type"], "PLUGINS");
|
||||
assert_eq!(event_params["failure_stage"], "plugin_import");
|
||||
assert_eq!(event_params["error_type"], "plugin_not_found");
|
||||
|
||||
let request_id = mcp
|
||||
.send_plugin_list_request(PluginListParams {
|
||||
cwds: None,
|
||||
@@ -2753,10 +2615,3 @@ async fn external_agent_config_import_compacts_huge_session_before_first_follow_
|
||||
assert!(second.contains("LOCAL_SUMMARY"));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn write_analytics_config(codex_home: &std::path::Path, base_url: &str) -> std::io::Result<()> {
|
||||
std::fs::write(
|
||||
codex_home.join("config.toml"),
|
||||
format!("chatgpt_base_url = \"{base_url}\"\n"),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user