From c3fddcd59312dba3acde46341171a658317ba48a Mon Sep 17 00:00:00 2001 From: tidely <43219534+tidely@users.noreply.github.com> Date: Wed, 28 Jan 2026 18:52:34 +0200 Subject: [PATCH] client: Store `ReleaseChannel` instead of `&'static str` (#47868) Closes #ISSUE Store `ReleaseChannel` instead of `&'static str`. This allows displaying other aspects about the channel than just the display name. Makes it more concrete what is stored within the field, as it has limited variants, as opposed to something like `session_id` Release Notes: - N/A *or* Added/Fixed/Improved ... --- crates/client/src/telemetry.rs | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/crates/client/src/telemetry.rs b/crates/client/src/telemetry.rs index 14038766bc2f8ee63e15992802a3db0e4340d4ea..70056f19653b097173f6af9c80dc74f67b3d49f9 100644 --- a/crates/client/src/telemetry.rs +++ b/crates/client/src/telemetry.rs @@ -49,7 +49,7 @@ struct TelemetryState { installation_id: Option>, // Per app installation (different for dev, nightly, preview, and stable) session_id: Option, // Per app launch metrics_id: Option>, // Per logged-in user - release_channel: Option<&'static str>, + release_channel: Option, architecture: &'static str, events_queue: Vec, flush_events_task: Option>, @@ -191,13 +191,10 @@ impl Telemetry { client: Arc, cx: &mut App, ) -> Arc { - let release_channel = - ReleaseChannel::try_global(cx).map(|release_channel| release_channel.display_name()); - let state = Arc::new(Mutex::new(TelemetryState { settings: *TelemetrySettings::get_global(cx), architecture: env::consts::ARCH, - release_channel, + release_channel: ReleaseChannel::try_global(cx), system_id: None, installation_id: None, session_id: None, @@ -490,16 +487,12 @@ impl Telemetry { continue; }; - let project_type = if file_name == "pnpm-lock.yaml" { - Some("pnpm") - } else if file_name == "yarn.lock" { - Some("yarn") - } else if file_name == "package.json" { - Some("node") - } else if DOTNET_PROJECT_FILES_REGEX.is_match(file_name) { - Some("dotnet") - } else { - None + let project_type = match file_name { + "pnpm-lock.yaml" => Some("pnpm"), + "yarn.lock" => Some("yarn"), + "package.json" => Some("node"), + _ if DOTNET_PROJECT_FILES_REGEX.is_match(file_name) => Some("dotnet"), + _ => None, }; if let Some(project_type) = project_type { @@ -646,7 +639,9 @@ impl Telemetry { os_version: state.os_version.clone(), architecture: state.architecture.to_string(), - release_channel: state.release_channel.map(Into::into), + release_channel: state + .release_channel + .map(|channel| channel.display_name().to_owned()), events, }, ) @@ -670,9 +665,7 @@ impl Telemetry { } pub fn calculate_json_checksum(json: &impl AsRef<[u8]>) -> Option { - let Some(checksum_seed) = &*ZED_CLIENT_CHECKSUM_SEED else { - return None; - }; + let checksum_seed = ZED_CLIENT_CHECKSUM_SEED.as_ref()?; let mut summer = Sha256::new(); summer.update(checksum_seed);