WIP

Antonio Scandurra created

Change summary

crates/client2/src/telemetry.rs | 24 ++++++++++++++++++------
crates/gpui2/src/app.rs         |  4 ++--
crates/gpui2/src/platform.rs    |  4 ++--
3 files changed, 22 insertions(+), 10 deletions(-)

Detailed changes

crates/client2/src/telemetry.rs 🔗

@@ -41,9 +41,9 @@ struct ClickhouseEventRequestBody {
     installation_id: Option<Arc<str>>,
     session_id: Option<Arc<str>>,
     is_staff: Option<bool>,
-    app_version: Option<Arc<str>>,
+    app_version: Option<String>,
     os_name: &'static str,
-    os_version: Option<Arc<str>>,
+    os_version: Option<String>,
     architecture: &'static str,
     release_channel: Option<&'static str>,
     events: Vec<ClickhouseEventWrapper>,
@@ -190,7 +190,13 @@ impl Telemetry {
                     core_count: system.cpus().len() as u32,
                 };
 
-                let telemetry_settings = cx.update(|cx| *settings2::get::<TelemetrySettings>(cx));
+                let telemetry_settings = if let Ok(telemetry_settings) =
+                    cx.update(|cx| *settings2::get::<TelemetrySettings>(cx))
+                {
+                    telemetry_settings
+                } else {
+                    break;
+                };
 
                 this.report_clickhouse_event(memory_event, telemetry_settings);
                 this.report_clickhouse_event(cpu_event, telemetry_settings);
@@ -287,9 +293,15 @@ impl Telemetry {
                             installation_id: state.installation_id.clone(),
                             session_id: state.session_id.clone(),
                             is_staff: state.is_staff.clone(),
-                            app_version: state.app_version.clone(),
-                            os_name: state.os_name,
-                            os_version: state.os_version.clone(),
+                            app_version: state
+                                .app_metadata
+                                .app_version
+                                .map(|version| version.to_string()),
+                            os_name: state.app_metadata.os_name,
+                            os_version: state
+                                .app_metadata
+                                .os_version
+                                .map(|version| version.to_string()),
                             architecture: state.architecture,
 
                             release_channel: state.release_channel,

crates/gpui2/src/app.rs 🔗

@@ -59,8 +59,8 @@ impl App {
         let unit_entity = entities.insert(entities.reserve(), ());
         let app_metadata = AppMetadata {
             os_name: platform.os_name(),
-            os_version: platform.os_version().unwrap_or_default(),
-            app_version: platform.app_version().unwrap_or_default(),
+            os_version: platform.os_version().ok(),
+            app_version: platform.app_version().ok(),
         };
         Self(Arc::new_cyclic(|this| {
             Mutex::new(AppContext {

crates/gpui2/src/platform.rs 🔗

@@ -184,8 +184,8 @@ pub trait PlatformTextSystem: Send + Sync {
 #[derive(Clone, Debug)]
 pub struct AppMetadata {
     pub os_name: &'static str,
-    pub os_version: SemanticVersion,
-    pub app_version: SemanticVersion,
+    pub os_version: Option<SemanticVersion>,
+    pub app_version: Option<SemanticVersion>,
 }
 
 #[derive(PartialEq, Eq, Hash, Clone)]