Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Only install crash handler when a minidump endpoint is configured (#61384)

Jakub Konkae8bfce7614b8
diff --git a/crates/client/src/telemetry.rs b/crates/client/src/telemetry.rs
index 771a0f56052..a08dfb44bd6 100644
--- a/crates/client/src/telemetry.rs
+++ b/crates/client/src/telemetry.rs
@@ -95,6 +95,13 @@ pub static MINIDUMP_ENDPOINT: LazyLock<Option<String>> = LazyLock::new(|| {
.or_else(|| env::var("ZED_MINIDUMP_ENDPOINT").ok())
});
+pub fn should_install_crash_handler(channel: ReleaseChannel) -> bool {
+ matches!(
+ env::var("ZED_GENERATE_MINIDUMPS").as_deref(),
+ Ok("true" | "1")
+ ) || (channel != ReleaseChannel::Dev && MINIDUMP_ENDPOINT.is_some())
+}
+
static DOTNET_PROJECT_FILES_REGEX: LazyLock<Regex> = LazyLock::new(|| {
Regex::new(r"^(global\.json|Directory\.Build\.props|.*\.(csproj|fsproj|vbproj|sln))$").unwrap()
});
diff --git a/crates/remote_server/src/server.rs b/crates/remote_server/src/server.rs
index e00c9173bbf..ffbea71cfe1 100644
--- a/crates/remote_server/src/server.rs
+++ b/crates/remote_server/src/server.rs
@@ -47,7 +47,6 @@ use smol::{
stream::StreamExt as _,
};
use std::{
- env,
ffi::OsStr,
fs::File,
io::Write,
@@ -571,10 +570,8 @@ pub fn execute_run(
let app = gpui_platform::headless();
let pid = std::process::id();
let id = pid.to_string();
- let should_install_crash_handler = matches!(
- env::var("ZED_GENERATE_MINIDUMPS").as_deref(),
- Ok("true" | "1")
- ) || *RELEASE_CHANNEL != ReleaseChannel::Dev;
+ let should_install_crash_handler =
+ client::telemetry::should_install_crash_handler(*RELEASE_CHANNEL);
let crash_handler = if should_install_crash_handler {
Some(app.background_executor().spawn(crashes::init(
@@ -851,10 +848,8 @@ pub(crate) fn execute_proxy(
let server_paths = ServerPaths::new(&identifier)?;
let id = std::process::id().to_string();
- let should_install_crash_handler = matches!(
- env::var("ZED_GENERATE_MINIDUMPS").as_deref(),
- Ok("true" | "1")
- ) || *RELEASE_CHANNEL != ReleaseChannel::Dev;
+ let should_install_crash_handler =
+ client::telemetry::should_install_crash_handler(*RELEASE_CHANNEL);
if should_install_crash_handler {
smol::spawn(crashes::init(
diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs
index f640d204a65..0c161e2e562 100644
--- a/crates/zed/src/main.rs
+++ b/crates/zed/src/main.rs
@@ -382,11 +382,8 @@ fn main() {
return;
}
- let should_install_crash_handler = matches!(
- env::var("ZED_GENERATE_MINIDUMPS").as_deref(),
- Ok("true" | "1")
- ) || *release_channel::RELEASE_CHANNEL
- != ReleaseChannel::Dev;
+ let should_install_crash_handler =
+ client::telemetry::should_install_crash_handler(*release_channel::RELEASE_CHANNEL);
let crash_handler = if should_install_crash_handler {
Some(