Restore temp file initialization in telemetry code (#4043)

Mikayla Maki created

Release Notes:

- Fix 'open telemetry log' command to actually show the telemetry log.

Change summary

crates/client/src/telemetry.rs | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

Detailed changes

crates/client/src/telemetry.rs 🔗

@@ -14,6 +14,8 @@ use sysinfo::{
 };
 use tempfile::NamedTempFile;
 use util::http::HttpClient;
+#[cfg(not(debug_assertions))]
+use util::ResultExt;
 use util::{channel::ReleaseChannel, TryFutureExt};
 
 use self::event_coalescer::EventCoalescer;
@@ -167,6 +169,20 @@ impl Telemetry {
             event_coalescer: EventCoalescer::new(),
         }));
 
+        #[cfg(not(debug_assertions))]
+        cx.background_executor()
+            .spawn({
+                let state = state.clone();
+                async move {
+                    if let Some(tempfile) =
+                        NamedTempFile::new_in(util::paths::CONFIG_DIR.as_path()).log_err()
+                    {
+                        state.lock().log_file = Some(tempfile);
+                    }
+                }
+            })
+            .detach();
+
         cx.observe_global::<SettingsStore>({
             let state = state.clone();