diff --git a/rust/gui-client/src-tauri/src/bin/firezone-gui-client.rs b/rust/gui-client/src-tauri/src/bin/firezone-gui-client.rs index 31db4c1aa..c07897a9c 100644 --- a/rust/gui-client/src-tauri/src/bin/firezone-gui-client.rs +++ b/rust/gui-client/src-tauri/src/bin/firezone-gui-client.rs @@ -81,12 +81,14 @@ fn try_main( // Technically this means we can fail to get the device ID on a newly-installed system, since the Tunnel service may not have fully started up when the GUI process reaches this point, but in practice it's unlikely. let id = firezone_bin_shared::device_id::get().context("Failed to get device ID")?; - rt.block_on(telemetry.start( - &api_url, - firezone_gui_client::RELEASE, - firezone_telemetry::GUI_DSN, - id.id, - )); + if cli.is_telemetry_allowed() { + rt.block_on(telemetry.start( + &api_url, + firezone_gui_client::RELEASE, + firezone_telemetry::GUI_DSN, + id.id, + )); + } // Don't fix the log filter for smoke tests because we can't show a dialog there. if !config.smoke_test { @@ -277,6 +279,15 @@ struct Cli { /// For headless CI, disable the elevation check. #[arg(long, hide = true)] no_elevation_check: bool, + + /// Disable sentry.io crash-reporting agent. + #[arg( + long, + env = "FIREZONE_NO_TELEMETRY", + default_value_t = false, + hide = true + )] + no_telemetry: bool, } impl Cli { @@ -295,6 +306,10 @@ impl Cli { fn check_elevation(&self) -> bool { !self.no_elevation_check } + + fn is_telemetry_allowed(&self) -> bool { + !self.no_telemetry + } } #[derive(clap::Subcommand)] diff --git a/rust/gui-client/src-tauri/src/service.rs b/rust/gui-client/src-tauri/src/service.rs index 032c35e07..7914a3d18 100644 --- a/rust/gui-client/src-tauri/src/service.rs +++ b/rust/gui-client/src-tauri/src/service.rs @@ -576,14 +576,25 @@ impl<'a> Handler<'a> { release, account_slug, } => { - self.telemetry - .start( - &environment, - &release, - firezone_telemetry::GUI_DSN, - self.device_id.id.clone(), - ) - .await; + // This is a bit hacky. + // It would be cleaner to pass it down from the `Cli` struct. + // However, the service can be run in many different ways and adapting all of those + // is cumbersome. + // Disabling telemetry for the service is mostly useful for our own testing and therefore + // doesn't need to be exposed publicly anyway. + let no_telemetry = + std::env::var("FIREZONE_NO_TELEMETRY").is_ok_and(|s| s == "true"); + + if !no_telemetry { + self.telemetry + .start( + &environment, + &release, + firezone_telemetry::GUI_DSN, + self.device_id.id.clone(), + ) + .await + } if let Some(account_slug) = account_slug { Telemetry::set_account_slug(account_slug.clone());