telemetry: Push OS name and version to sentry in minidump

Jakub Konka created

Change summary

crates/client/src/telemetry.rs | 8 ++++++++
crates/zed/src/reliability.rs  | 7 +++++++
2 files changed, 15 insertions(+)

Detailed changes

crates/client/src/telemetry.rs 🔗

@@ -582,6 +582,14 @@ impl Telemetry {
         self.state.lock().is_staff
     }
 
+    pub fn os_name(self: &Arc<Self>) -> String {
+        self.state.lock().os_name.clone()
+    }
+
+    pub fn os_version(self: &Arc<Self>) -> Option<String> {
+        self.state.lock().os_version.clone()
+    }
+
     fn build_request(
         self: &Arc<Self>,
         // We take in the JSON bytes buffer so we can reuse the existing allocation.

crates/zed/src/reliability.rs 🔗

@@ -364,6 +364,13 @@ async fn upload_minidump(
             );
     }
 
+    form = form
+        .text("sentry[contexts][os][type]", "os")
+        .text("sentry[contexts][os][name]", client.telemetry().os_name());
+    if let Some(os_version) = client.telemetry().os_version() {
+        form = form.text("sentry[contexts][os][version]", os_version);
+    }
+
     // TODO: feature-flag-context, and more of device-context like screen resolution, available ram, device model, etc
 
     let content_type = format!("multipart/form-data; boundary={}", form.boundary());