From 15e738f2faaf7996fe5575f7735e2129a8721a2c Mon Sep 17 00:00:00 2001 From: Jake Cooper Date: Fri, 3 Apr 2026 18:45:07 +0900 Subject: [PATCH] Show telemetry notice on install instead of first run (#832) Move the telemetry opt-out notice from a runtime banner (shown on first CLI command) to the install script so users see it exactly once at install time. Remove the Notices JSON persistence that tracked whether the banner had been shown. Co-authored-by: Claude Opus 4.6 (1M context) --- install.sh | 9 ++++++--- src/main.rs | 2 -- src/telemetry.rs | 51 ------------------------------------------------ 3 files changed, 6 insertions(+), 56 deletions(-) diff --git a/install.sh b/install.sh index 8339335..eaeaec3 100755 --- a/install.sh +++ b/install.sh @@ -515,10 +515,13 @@ printf "$MAGENTA" /. ~~ ,\/I . Railway is now installed \\L__j^\/I o Run `railway help` for commands \/--v} I o . - | | I _________ - | | I c(` ')o + | | I _________ + | | I c(` ')o | l I \. ,/ -_/j L l\_! _//^---^\\_ +_/j L l\_! _//^---^\\_ EOF printf "$NO_COLOR" + +info "Railway collects anonymous CLI usage data to improve the developer experience." +info "You can opt out anytime: ${BOLD}railway telemetry disable${NO_COLOR} or ${BOLD}RAILWAY_NO_TELEMETRY=1${NO_COLOR}" diff --git a/src/main.rs b/src/main.rs index 21313af..f66604b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -105,8 +105,6 @@ async fn handle_update_task( async fn main() -> Result<()> { let args = build_args().try_get_matches(); let check_updates_handle = if std::io::stdout().is_terminal() { - telemetry::show_notice_if_needed(); - let update = UpdateCheck::read().unwrap_or_default(); if let Some(latest_version) = update.latest_version { diff --git a/src/telemetry.rs b/src/telemetry.rs index b934772..1b05b48 100644 --- a/src/telemetry.rs +++ b/src/telemetry.rs @@ -1,58 +1,7 @@ -use colored::Colorize; - use crate::client::{GQLClient, post_graphql}; use crate::config::Configs; use crate::gql::mutations::{self, cli_event_track}; -#[derive(serde::Serialize, serde::Deserialize, Default)] -#[serde(rename_all = "camelCase")] -struct Notices { - telemetry_notice_shown: bool, -} - -impl Notices { - fn path() -> Option { - dirs::home_dir().map(|h| h.join(".railway/notices.json")) - } - - fn read() -> Self { - Self::path() - .and_then(|p| std::fs::read_to_string(p).ok()) - .and_then(|s| serde_json::from_str(&s).ok()) - .unwrap_or_default() - } - - fn write(&self) { - if let Some(path) = Self::path() { - let _ = serde_json::to_string(self) - .ok() - .map(|contents| std::fs::write(path, contents)); - } - } -} - -pub fn show_notice_if_needed() { - if is_telemetry_disabled() { - return; - } - - let notices = Notices::read(); - if notices.telemetry_notice_shown { - return; - } - - eprintln!( - "{}\nYou can opt out by running `railway telemetry disable` or by setting RAILWAY_NO_TELEMETRY=1 in your environment.\n{}", - "Railway now collects CLI usage data to improve the developer experience.".bold(), - format!("Learn more: {}", "https://docs.railway.com/cli/telemetry").dimmed(), - ); - - Notices { - telemetry_notice_shown: true, - } - .write(); -} - pub struct CliTrackEvent { pub command: String, pub sub_command: Option,