From 8a926c4a23d6973c6ba30b24ed3ff64c58ac8530 Mon Sep 17 00:00:00 2001 From: Joseph T Lyons Date: Thu, 27 Oct 2022 18:06:34 -0400 Subject: [PATCH] Make `release_channel` optional to fix tests Co-Authored-By: Max Brunsfeld --- crates/client/src/amplitude_telemetry.rs | 10 +++++++--- crates/client/src/telemetry.rs | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/crates/client/src/amplitude_telemetry.rs b/crates/client/src/amplitude_telemetry.rs index ab5f7a42c5..4883124d28 100644 --- a/crates/client/src/amplitude_telemetry.rs +++ b/crates/client/src/amplitude_telemetry.rs @@ -34,7 +34,7 @@ struct AmplitudeTelemetryState { metrics_id: Option>, device_id: Option>, app_version: Option>, - release_channel: &'static str, + release_channel: Option<&'static str>, os_version: Option>, os_name: &'static str, queue: Vec, @@ -72,7 +72,7 @@ struct AmplitudeEvent { app_version: Option>, #[serde(rename = "App")] app: &'static str, - release_channel: &'static str, + release_channel: Option<&'static str>, event_id: usize, session_id: u128, time: u128, @@ -93,7 +93,11 @@ const DEBOUNCE_INTERVAL: Duration = Duration::from_secs(30); impl AmplitudeTelemetry { pub fn new(client: Arc, cx: &AppContext) -> Arc { let platform = cx.platform(); - let release_channel = cx.global::().name(); + let release_channel = if cx.has_global::() { + Some(cx.global::().name()) + } else { + None + }; let this = Arc::new(Self { http_client: client, executor: cx.background().clone(), diff --git a/crates/client/src/telemetry.rs b/crates/client/src/telemetry.rs index e09400757c..01adeccb50 100644 --- a/crates/client/src/telemetry.rs +++ b/crates/client/src/telemetry.rs @@ -33,7 +33,7 @@ struct TelemetryState { metrics_id: Option>, device_id: Option>, app_version: Option>, - release_channel: &'static str, + release_channel: Option<&'static str>, os_version: Option>, os_name: &'static str, queue: Vec, @@ -74,7 +74,7 @@ struct MixpanelEventProperties { #[serde(rename = "OS Version")] os_version: Option>, #[serde(rename = "Release Channel")] - release_channel: &'static str, + release_channel: Option<&'static str>, #[serde(rename = "App Version")] app_version: Option>, #[serde(rename = "Signed In")] @@ -108,7 +108,11 @@ const DEBOUNCE_INTERVAL: Duration = Duration::from_secs(30); impl Telemetry { pub fn new(client: Arc, cx: &AppContext) -> Arc { let platform = cx.platform(); - let release_channel = cx.global::().name(); + let release_channel = if cx.has_global::() { + Some(cx.global::().name()) + } else { + None + }; let this = Arc::new(Self { http_client: client, executor: cx.background().clone(),