aKode fase 1 (parziale): niente Statsig, analytics, upload Sentry, update check e announcement remoti
This commit is contained in:
@@ -398,12 +398,16 @@ impl AnalyticsEventsClient {
|
||||
!= codex_http_client::OpenAiDestination::Other
|
||||
}
|
||||
});
|
||||
let destination = AnalyticsEventsDestination::from_base_url(base_url, api_key_headers);
|
||||
Self {
|
||||
queue: (analytics_enabled != Some(false)).then(|| {
|
||||
AnalyticsEventsQueue::new(Arc::clone(&auth_manager), destination, runtime_auth)
|
||||
}),
|
||||
}
|
||||
// aKode: analytics are never uploaded. The upstream client posted
|
||||
// events to `{chatgpt_base_url}/codex/analytics-events/events`; the
|
||||
// queue is never created, so every `track_*` call is a no-op.
|
||||
let _ = (
|
||||
analytics_enabled,
|
||||
auth_manager,
|
||||
runtime_auth,
|
||||
AnalyticsEventsDestination::from_base_url(base_url, api_key_headers),
|
||||
);
|
||||
Self { queue: None }
|
||||
}
|
||||
|
||||
/// Give a resumed actor its own queue while preserving the caller's analytics setting.
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// aKode: event upload is disabled (see `client.rs`); the upstream sending
|
||||
// machinery is kept only until it is pruned, so dead-code warnings are expected.
|
||||
#![allow(dead_code)]
|
||||
mod accepted_lines;
|
||||
#[cfg(debug_assertions)]
|
||||
mod analytics_capture;
|
||||
|
||||
@@ -698,7 +698,7 @@ impl Default for OtelConfig {
|
||||
environment: DEFAULT_OTEL_ENVIRONMENT.to_owned(),
|
||||
exporter: OtelExporterKind::None,
|
||||
trace_exporter: OtelExporterKind::None,
|
||||
metrics_exporter: OtelExporterKind::Statsig,
|
||||
metrics_exporter: OtelExporterKind::None,
|
||||
span_attributes: HashMap::new(),
|
||||
tracestate: BTreeMap::new(),
|
||||
}
|
||||
|
||||
@@ -10512,7 +10512,7 @@ async fn metrics_exporter_defaults_to_statsig_when_missing() -> std::io::Result<
|
||||
)
|
||||
.await?;
|
||||
|
||||
assert_eq!(config.otel.metrics_exporter, OtelExporterKind::Statsig);
|
||||
assert_eq!(config.otel.metrics_exporter, OtelExporterKind::None);
|
||||
assert!(config.otel.log_sse_deltas);
|
||||
assert!(!config.otel.agent_response_logging_enabled());
|
||||
assert!(!config.otel.guardian_assessment_logging_enabled());
|
||||
|
||||
@@ -19,7 +19,7 @@ pub(crate) fn resolve_config(
|
||||
// OTLP HTTP endpoints are signal-specific in our config, so enabling log
|
||||
// export must not implicitly send spans to a /v1/logs endpoint.
|
||||
let trace_exporter = config.trace_exporter.unwrap_or(OtelExporterKind::None);
|
||||
let metrics_exporter = config.metrics_exporter.unwrap_or(OtelExporterKind::Statsig);
|
||||
let metrics_exporter = config.metrics_exporter.unwrap_or(OtelExporterKind::None);
|
||||
// Provider initialization installs process-global OTEL state. Sanitize
|
||||
// user-editable trace metadata here so malformed config is reported as a
|
||||
// startup warning instead of making startup fail.
|
||||
|
||||
@@ -59,8 +59,9 @@ pub const CODEX_APP_DIRECTORY_CACHE_ATTACHMENT_FILENAME: &str = "codex-app-direc
|
||||
/// Filename used for the Windows sandbox log feedback attachment.
|
||||
pub const WINDOWS_SANDBOX_LOG_ATTACHMENT_FILENAME: &str = "windows-sandbox.log";
|
||||
const DEFAULT_MAX_BYTES: usize = 4 * 1024 * 1024; // 4 MiB
|
||||
const SENTRY_DSN: &str =
|
||||
"https://ae32ed50620d7a7792c1ce5df38b3e3e@o33249.ingest.us.sentry.io/4510195390611458";
|
||||
// aKode: the upstream Sentry DSN has been removed. This placeholder only keeps
|
||||
// DSN parsing valid; `upload::send_envelope` refuses to send anything.
|
||||
const SENTRY_DSN: &str = "https://disabled@127.0.0.1/0";
|
||||
const UPLOAD_TIMEOUT: Duration = Duration::from_secs(/*secs*/ 300);
|
||||
// Raw collection budgets used by the report API, not the interactive upload.
|
||||
pub const MAX_ATTACHMENT_BYTES: usize = 64 * 1024 * 1024;
|
||||
|
||||
@@ -4,7 +4,6 @@ use std::time::Duration;
|
||||
use std::time::Instant;
|
||||
use std::time::SystemTime;
|
||||
|
||||
use anyhow::Context;
|
||||
use anyhow::Result;
|
||||
use bytes::Bytes;
|
||||
use codex_http_client::RequestBuilder;
|
||||
@@ -51,79 +50,18 @@ pub(super) fn envelope_request(
|
||||
}
|
||||
|
||||
/// Send an already-serialized envelope within the report's shared deadline.
|
||||
///
|
||||
/// aKode: feedback is never uploaded to a remote service (upstream sent it to
|
||||
/// Sentry). The signature is kept so callers compile; it always fails.
|
||||
pub(super) async fn send_envelope(
|
||||
client_pool: &RouteAwareClientPool,
|
||||
dsn: &Dsn,
|
||||
body: Vec<u8>,
|
||||
kind: EnvelopeKind,
|
||||
deadline: Instant,
|
||||
rate_limited: &mut bool,
|
||||
_client_pool: &RouteAwareClientPool,
|
||||
_dsn: &Dsn,
|
||||
_body: Vec<u8>,
|
||||
_kind: EnvelopeKind,
|
||||
_deadline: Instant,
|
||||
_rate_limited: &mut bool,
|
||||
) -> Result<StatusCode> {
|
||||
let body = Bytes::from(body);
|
||||
// Retain the exact request bytes for at most two diagnostic retries. Never replay the core.
|
||||
let mut retry_delays = [250, 500].map(Duration::from_millis).into_iter();
|
||||
let response = loop {
|
||||
let timeout = deadline.saturating_duration_since(Instant::now());
|
||||
anyhow::ensure!(!timeout.is_zero(), "feedback upload deadline exceeded");
|
||||
let response = envelope_request(client_pool, dsn, body.clone(), timeout)
|
||||
.send()
|
||||
.await;
|
||||
if response.as_ref().is_ok_and(|response| {
|
||||
sentry_rate_limit_delay(response.headers()).is_some_and(|delay| !delay.is_zero())
|
||||
|| (response.status().is_success()
|
||||
&& response.headers().get("Retry-After").is_some_and(|value| {
|
||||
parse_retry_after(value.to_str().unwrap_or_default())
|
||||
.is_none_or(|delay| !delay.is_zero())
|
||||
}))
|
||||
}) {
|
||||
// Even accepted requests can impose a quota on events or attachments.
|
||||
// https://develop.sentry.dev/sdk/foundations/transport/rate-limiting/
|
||||
*rate_limited = true;
|
||||
break response;
|
||||
}
|
||||
let retryable = match &response {
|
||||
Ok(response) => matches!(response.status().as_u16(), 408 | 429 | 500..=599),
|
||||
Err(error) => {
|
||||
error.is_timeout()
|
||||
|| (error.failure_class().is_none()
|
||||
&& (error.is_connect() || error.is_request() || error.is_body()))
|
||||
}
|
||||
};
|
||||
if matches!(kind, EnvelopeKind::Event) || !retryable {
|
||||
break response;
|
||||
}
|
||||
let retry_delay = retry_delays.next();
|
||||
if response.as_ref().is_ok_and(|response| {
|
||||
response.status() == StatusCode::TOO_MANY_REQUESTS
|
||||
&& (retry_delay.is_none() || !response.headers().contains_key("Retry-After"))
|
||||
}) {
|
||||
// Never let later files bypass an exhausted rate limit.
|
||||
*rate_limited = true;
|
||||
break response;
|
||||
}
|
||||
let Some(retry_delay) = retry_delay else {
|
||||
break response;
|
||||
};
|
||||
let retry_after = response
|
||||
.as_ref()
|
||||
.ok()
|
||||
.and_then(|response| response.headers().get("Retry-After"))
|
||||
.map(|value| {
|
||||
// An invalid cooldown is not permission to send immediately.
|
||||
parse_retry_after(value.to_str().unwrap_or_default())
|
||||
.unwrap_or_else(|| deadline.saturating_duration_since(Instant::now()))
|
||||
});
|
||||
let delay = retry_delay.max(retry_after.unwrap_or_default());
|
||||
if delay >= deadline.saturating_duration_since(Instant::now()) {
|
||||
// Leave long cooldowns for a later submission, including its remaining files.
|
||||
*rate_limited = true;
|
||||
break response;
|
||||
}
|
||||
tokio::time::sleep(delay).await;
|
||||
};
|
||||
response
|
||||
.map(|response| response.status())
|
||||
.context("failed to upload feedback to Sentry")
|
||||
anyhow::bail!("feedback upload is disabled in aKode; use the local save option instead")
|
||||
}
|
||||
|
||||
pub(super) fn sentry_rate_limit_delay(headers: &HeaderMap) -> Option<Duration> {
|
||||
|
||||
@@ -6,31 +6,13 @@ use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
pub(crate) const STATSIG_OTLP_HTTP_ENDPOINT: &str = "https://ab.chatgpt.com/otlp/v1/metrics";
|
||||
pub(crate) const STATSIG_API_KEY_HEADER: &str = "statsig-api-key";
|
||||
pub(crate) const STATSIG_API_KEY: &str = "client-MkRuleRQBd6qakfnDYqJVR9JuXcY57Ljly3vi5JVUIO";
|
||||
|
||||
/// aKode: the upstream built-in Statsig exporter (ab.chatgpt.com with an
|
||||
/// embedded API key) has been removed. The `Statsig` variant is kept only so
|
||||
/// old configuration files still parse; it always resolves to `None`, so no
|
||||
/// telemetry is ever sent unless the user configures an explicit exporter.
|
||||
pub(crate) fn resolve_exporter(exporter: &OtelExporter) -> OtelExporter {
|
||||
match exporter {
|
||||
OtelExporter::Statsig => {
|
||||
// Keep the built-in Statsig default off in debug builds so
|
||||
// incremental local development and test runs do not emit
|
||||
// best-effort OTEL traffic unless a test or binary opts into an
|
||||
// explicit exporter configuration.
|
||||
if cfg!(debug_assertions) {
|
||||
return OtelExporter::None;
|
||||
}
|
||||
|
||||
OtelExporter::OtlpHttp {
|
||||
endpoint: STATSIG_OTLP_HTTP_ENDPOINT.to_string(),
|
||||
headers: HashMap::from([(
|
||||
STATSIG_API_KEY_HEADER.to_string(),
|
||||
STATSIG_API_KEY.to_string(),
|
||||
)]),
|
||||
protocol: OtelHttpProtocol::Json,
|
||||
tls: None,
|
||||
}
|
||||
}
|
||||
OtelExporter::Statsig => OtelExporter::None,
|
||||
_ => exporter.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,13 +100,8 @@ fn linux_app_tooltip(session: LinuxDesktopSession) -> Option<&'static str> {
|
||||
}
|
||||
|
||||
fn app_tooltip() -> Option<&'static str> {
|
||||
if IS_MACOS {
|
||||
Some(MACOS_APP_TOOLTIP)
|
||||
} else if IS_WINDOWS {
|
||||
Some(WINDOWS_APP_TOOLTIP)
|
||||
} else {
|
||||
linux_app_tooltip(LinuxDesktopSession::current())
|
||||
}
|
||||
// aKode: no desktop-app promotion.
|
||||
None
|
||||
}
|
||||
|
||||
fn pick_tooltip<R: Rng + ?Sized>(rng: &mut R, keymap: &TuiKeymap) -> Option<String> {
|
||||
@@ -179,15 +174,9 @@ pub(crate) mod announcement {
|
||||
|
||||
/// Prewarm the cache of the announcement tip.
|
||||
pub(crate) fn prewarm(http_client_factory: HttpClientFactory) {
|
||||
if ANNOUNCEMENT_TIP.get().is_some() {
|
||||
return;
|
||||
}
|
||||
tokio::spawn(async move {
|
||||
let announcement_tip = fetch_announcement_tip_text(http_client_factory)
|
||||
.await
|
||||
.and_then(|raw| AnnouncementTips::parse(&raw));
|
||||
let _ = ANNOUNCEMENT_TIP.set(announcement_tip);
|
||||
});
|
||||
// aKode: announcement tips are never fetched from the network.
|
||||
let _ = http_client_factory;
|
||||
let _ = ANNOUNCEMENT_TIP.set(None);
|
||||
}
|
||||
|
||||
/// Fetch the announcement tip, return None if the prewarm is not done yet.
|
||||
|
||||
@@ -25,36 +25,9 @@ use crate::version::CODEX_CLI_VERSION;
|
||||
pub(crate) use crate::updates_cache::dismiss_version;
|
||||
|
||||
pub fn get_upgrade_version(config: &Config) -> Option<String> {
|
||||
if !config.check_for_update_on_startup || is_source_build_version(CODEX_CLI_VERSION) {
|
||||
return None;
|
||||
}
|
||||
|
||||
let action = update_action::get_update_action();
|
||||
let version_file = version_filepath(config);
|
||||
let info = read_version_info(&version_file).ok();
|
||||
|
||||
if match &info {
|
||||
None => true,
|
||||
Some(info) => info.last_checked_at < Utc::now() - Duration::hours(20),
|
||||
} {
|
||||
let http_client_factory = config.http_client_factory();
|
||||
// Refresh the cached latest version in the background so TUI startup
|
||||
// isn’t blocked by a network call. The UI reads the previously cached
|
||||
// value (if any) for this run; the next run shows the banner if needed.
|
||||
tokio::spawn(async move {
|
||||
check_for_update(&version_file, action, http_client_factory)
|
||||
.await
|
||||
.inspect_err(|e| tracing::error!("Failed to update version: {e}"))
|
||||
});
|
||||
}
|
||||
|
||||
info.and_then(|info| {
|
||||
if is_newer(&info.latest_version, CODEX_CLI_VERSION).unwrap_or(false) {
|
||||
Some(info.latest_version)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
// aKode: no remote update checks (upstream queried GitHub, npm and Homebrew).
|
||||
let _ = config;
|
||||
None
|
||||
}
|
||||
|
||||
// We use the latest version from the cask if installation is via homebrew - homebrew does not immediately pick up the latest release and can lag behind.
|
||||
@@ -150,17 +123,7 @@ async fn fetch_latest_github_release_version(
|
||||
/// Returns the latest version to show in a popup, if it should be shown.
|
||||
/// This respects the user's dismissal choice for the current latest version.
|
||||
pub fn get_upgrade_version_for_popup(config: &Config) -> Option<String> {
|
||||
if !config.check_for_update_on_startup || is_source_build_version(CODEX_CLI_VERSION) {
|
||||
return None;
|
||||
}
|
||||
|
||||
let version_file = version_filepath(config);
|
||||
let latest = get_upgrade_version(config)?;
|
||||
// If the user dismissed this exact version previously, do not show the popup.
|
||||
if let Ok(info) = read_version_info(&version_file)
|
||||
&& info.dismissed_version.as_deref() == Some(latest.as_str())
|
||||
{
|
||||
return None;
|
||||
}
|
||||
Some(latest)
|
||||
// aKode: no remote update checks.
|
||||
let _ = config;
|
||||
None
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user