Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

nit: rename to analytics_enabled (#8978)

jif-oaied64804cb523
diff --git a/codex-rs/app-server/src/lib.rs b/codex-rs/app-server/src/lib.rs
index 68663a991d..a2d14bf7dc 100644
--- a/codex-rs/app-server/src/lib.rs
+++ b/codex-rs/app-server/src/lib.rs
@@ -92,8 +92,8 @@ pub async fn run_main(
let feedback = CodexFeedback::new();
- let otel =
- codex_core::otel_init::build_provider(&config, env!("CARGO_PKG_VERSION")).map_err(|e| {
+ let otel = codex_core::otel_init::build_provider(&config, env!("CARGO_PKG_VERSION"), false)
+ .map_err(|e| {
std::io::Error::new(
ErrorKind::InvalidData,
format!("error loading otel config: {e}"),
diff --git a/codex-rs/core/src/config/mod.rs b/codex-rs/core/src/config/mod.rs
index 668d205ccc..22fcbfd647 100644
--- a/codex-rs/core/src/config/mod.rs
+++ b/codex-rs/core/src/config/mod.rs
@@ -353,8 +353,8 @@ pub struct Config {
pub disable_paste_burst: bool,
/// When `false`, disables analytics across Codex product surfaces in this machine.
- /// Defaults to `true`.
- pub analytics: bool,
+ /// Voluntarily left as Optional because the default value might depend on the client.
+ pub analytics_enabled: Option<bool>,
/// When `false`, disables feedback collection across Codex product surfaces.
/// Defaults to `true`.
@@ -1405,12 +1405,11 @@ impl Config {
notices: cfg.notice.unwrap_or_default(),
check_for_update_on_startup,
disable_paste_burst: cfg.disable_paste_burst.unwrap_or(false),
- analytics: config_profile
+ analytics_enabled: config_profile
.analytics
.as_ref()
.and_then(|a| a.enabled)
- .or(cfg.analytics.as_ref().and_then(|a| a.enabled))
- .unwrap_or(true),
+ .or(cfg.analytics.as_ref().and_then(|a| a.enabled)),
feedback_enabled: cfg
.feedback
.as_ref()
@@ -3266,7 +3265,7 @@ model_verbosity = "high"
tui_notifications: Default::default(),
animations: true,
show_tooltips: true,
- analytics: true,
+ analytics_enabled: Some(true),
feedback_enabled: true,
tui_scroll_events_per_tick: None,
tui_scroll_wheel_lines: None,
@@ -3351,7 +3350,7 @@ model_verbosity = "high"
tui_notifications: Default::default(),
animations: true,
show_tooltips: true,
- analytics: true,
+ analytics_enabled: Some(true),
feedback_enabled: true,
tui_scroll_events_per_tick: None,
tui_scroll_wheel_lines: None,
@@ -3451,7 +3450,7 @@ model_verbosity = "high"
tui_notifications: Default::default(),
animations: true,
show_tooltips: true,
- analytics: false,
+ analytics_enabled: Some(false),
feedback_enabled: true,
tui_scroll_events_per_tick: None,
tui_scroll_wheel_lines: None,
@@ -3537,7 +3536,7 @@ model_verbosity = "high"
tui_notifications: Default::default(),
animations: true,
show_tooltips: true,
- analytics: true,
+ analytics_enabled: Some(true),
feedback_enabled: true,
tui_scroll_events_per_tick: None,
tui_scroll_wheel_lines: None,
diff --git a/codex-rs/core/src/otel_init.rs b/codex-rs/core/src/otel_init.rs
index 5ba714959c..9a05a29b95 100644
--- a/codex-rs/core/src/otel_init.rs
+++ b/codex-rs/core/src/otel_init.rs
@@ -15,6 +15,7 @@ use std::error::Error;
pub fn build_provider(
config: &Config,
service_version: &str,
+ default_analytics_enabled: bool,
) -> Result<Option<OtelProvider>, Box<dyn Error>> {
let to_otel_exporter = |kind: &Kind| match kind {
Kind::None => OtelExporter::None,
@@ -64,7 +65,10 @@ pub fn build_provider(
let exporter = to_otel_exporter(&config.otel.exporter);
let trace_exporter = to_otel_exporter(&config.otel.trace_exporter);
- let metrics_exporter = if config.analytics {
+ let metrics_exporter = if config
+ .analytics_enabled
+ .unwrap_or(default_analytics_enabled)
+ {
to_otel_exporter(&config.otel.metrics_exporter)
} else {
OtelExporter::None
diff --git a/codex-rs/exec/src/lib.rs b/codex-rs/exec/src/lib.rs
index 44ce1d6e2b..da3389c46a 100644
--- a/codex-rs/exec/src/lib.rs
+++ b/codex-rs/exec/src/lib.rs
@@ -223,7 +223,7 @@ pub async fn run_main(cli: Cli, codex_linux_sandbox_exe: Option<PathBuf>) -> any
std::process::exit(1);
}
- let otel = codex_core::otel_init::build_provider(&config, env!("CARGO_PKG_VERSION"));
+ let otel = codex_core::otel_init::build_provider(&config, env!("CARGO_PKG_VERSION"), false);
#[allow(clippy::print_stderr)]
let otel = match otel {
diff --git a/codex-rs/tui/src/lib.rs b/codex-rs/tui/src/lib.rs
index f4e5e771fc..5855cfb71d 100644
--- a/codex-rs/tui/src/lib.rs
+++ b/codex-rs/tui/src/lib.rs
@@ -298,7 +298,7 @@ pub async fn run_main(
ensure_oss_provider_ready(provider_id, &config).await?;
}
- let otel = codex_core::otel_init::build_provider(&config, env!("CARGO_PKG_VERSION"));
+ let otel = codex_core::otel_init::build_provider(&config, env!("CARGO_PKG_VERSION"), true);
#[allow(clippy::print_stderr)]
let otel = match otel {
diff --git a/codex-rs/tui2/src/lib.rs b/codex-rs/tui2/src/lib.rs
index ac062cf667..ee4d4d5d5e 100644
--- a/codex-rs/tui2/src/lib.rs
+++ b/codex-rs/tui2/src/lib.rs
@@ -313,7 +313,7 @@ pub async fn run_main(
ensure_oss_provider_ready(provider_id, &config).await?;
}
- let otel = codex_core::otel_init::build_provider(&config, env!("CARGO_PKG_VERSION"));
+ let otel = codex_core::otel_init::build_provider(&config, env!("CARGO_PKG_VERSION"), true);
#[allow(clippy::print_stderr)]
let otel = match otel {