Add sentry

Julia Ryan created

Change summary

Cargo.lock                    | 91 +++++++++++++++++++++++++++++++++++++
Cargo.toml                    |  1 
crates/zed/Cargo.toml         |  1 
crates/zed/src/main.rs        |  3 
crates/zed/src/reliability.rs | 11 ++++
crates/zed/src/zed.rs         |  2 
6 files changed, 107 insertions(+), 2 deletions(-)

Detailed changes

Cargo.lock 🔗

@@ -4476,6 +4476,16 @@ dependencies = [
  "zlog",
 ]
 
+[[package]]
+name = "debugid"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bef552e6f588e446098f6ba40d89ac146c8c7b64aade83c051ee00bb5d2bc18d"
+dependencies = [
+ "serde",
+ "uuid",
+]
+
 [[package]]
 name = "deepseek"
 version = "0.1.0"
@@ -7973,6 +7983,7 @@ dependencies = [
  "tokio",
  "tokio-rustls 0.26.2",
  "tower-service",
+ "webpki-roots",
 ]
 
 [[package]]
@@ -13551,6 +13562,7 @@ dependencies = [
  "http-body 1.0.1",
  "http-body-util",
  "hyper 1.6.0",
+ "hyper-rustls 0.27.5",
  "hyper-util",
  "ipnet",
  "js-sys",
@@ -13559,17 +13571,23 @@ dependencies = [
  "once_cell",
  "percent-encoding",
  "pin-project-lite",
+ "quinn",
+ "rustls 0.23.26",
+ "rustls-pemfile 2.2.0",
+ "rustls-pki-types",
  "serde",
  "serde_json",
  "serde_urlencoded",
  "sync_wrapper 1.0.2",
  "tokio",
+ "tokio-rustls 0.26.2",
  "tower 0.5.2",
  "tower-service",
  "url",
  "wasm-bindgen",
  "wasm-bindgen-futures",
  "web-sys",
+ "webpki-roots",
  "windows-registry 0.4.0",
 ]
 
@@ -14581,6 +14599,49 @@ dependencies = [
  "serde",
 ]
 
+[[package]]
+name = "sentry"
+version = "0.41.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "507ac2be9bf2da56c831da57faf1dadd81f434bd282935cdb06193d0c94e8811"
+dependencies = [
+ "httpdate",
+ "reqwest 0.12.15 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustls 0.23.26",
+ "sentry-core",
+ "tokio",
+ "ureq",
+]
+
+[[package]]
+name = "sentry-core"
+version = "0.41.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "00e9bd2cadaeda3af41e9fa5d14645127d6f6a4aec73da3ae38e477ecafd3682"
+dependencies = [
+ "rand 0.9.1",
+ "sentry-types",
+ "serde",
+ "serde_json",
+]
+
+[[package]]
+name = "sentry-types"
+version = "0.41.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a08e7154abe2cd557f26fd70038452810748aefdf39bc973f674421224b147c1"
+dependencies = [
+ "debugid",
+ "hex",
+ "rand 0.9.1",
+ "serde",
+ "serde_json",
+ "thiserror 2.0.12",
+ "time",
+ "url",
+ "uuid",
+]
+
 [[package]]
 name = "serde"
 version = "1.0.219"
@@ -17470,6 +17531,35 @@ version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
 
+[[package]]
+name = "ureq"
+version = "3.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9f0fde9bc91026e381155f8c67cb354bcd35260b2f4a29bcc84639f762760c39"
+dependencies = [
+ "base64 0.22.1",
+ "log",
+ "percent-encoding",
+ "rustls 0.23.26",
+ "rustls-pemfile 2.2.0",
+ "rustls-pki-types",
+ "ureq-proto",
+ "utf-8",
+ "webpki-roots",
+]
+
+[[package]]
+name = "ureq-proto"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "59db78ad1923f2b1be62b6da81fe80b173605ca0d57f85da2e005382adf693f7"
+dependencies = [
+ "base64 0.22.1",
+ "http 1.3.1",
+ "httparse",
+ "log",
+]
+
 [[package]]
 name = "url"
 version = "2.5.4"
@@ -20269,6 +20359,7 @@ dependencies = [
  "reqwest_client",
  "rope",
  "search",
+ "sentry",
  "serde",
  "serde_json",
  "session",

Cargo.toml 🔗

@@ -559,6 +559,7 @@ rustls-platform-verifier = "0.5.0"
 scap = { git = "https://github.com/zed-industries/scap", rev = "808aa5c45b41e8f44729d02e38fd00a2fe2722e7", default-features = false }
 schemars = { version = "1.0", features = ["indexmap2"] }
 semver = "1.0"
+sentry = { version = "0.41", default-features = false, features = ["reqwest", "rustls"] }
 serde = { version = "1.0", features = ["derive", "rc"] }
 serde_derive = { version = "1.0", features = ["deserialize_in_place"] }
 serde_json = { version = "1.0", features = ["preserve_order", "raw_value"] }

crates/zed/Cargo.toml 🔗

@@ -119,6 +119,7 @@ repl.workspace = true
 reqwest_client.workspace = true
 rope.workspace = true
 search.workspace = true
+sentry.workspace = true
 serde.workspace = true
 serde_json.workspace = true
 session.workspace = true

crates/zed/src/main.rs 🔗

@@ -374,7 +374,7 @@ pub fn main() {
 
         release_channel::init(app_version, cx);
         gpui_tokio::init(cx);
-        if let Some(app_commit_sha) = app_commit_sha {
+        if let Some(app_commit_sha) = app_commit_sha.clone() {
             AppCommitSha::set_global(app_commit_sha, cx);
         }
         settings::init(cx);
@@ -534,6 +534,7 @@ pub fn main() {
             session_id.clone(),
             cx,
         );
+        reliability::init_sentry(app_commit_sha, cx);
 
         SystemAppearance::init(cx);
         theme::init(theme::LoadThemes::All(Box::new(Assets)), cx);

crates/zed/src/reliability.rs 🔗

@@ -12,6 +12,7 @@ use release_channel::{AppCommitSha, RELEASE_CHANNEL, ReleaseChannel};
 use settings::Settings;
 use smol::stream::StreamExt;
 use std::{
+    borrow::Cow,
     env,
     ffi::{OsStr, c_void},
     sync::{Arc, atomic::Ordering},
@@ -22,6 +23,7 @@ use url::Url;
 use util::ResultExt;
 
 static PANIC_COUNT: AtomicU32 = AtomicU32::new(0);
+const SENTRY_DSN: &str = "https://63c6474f7e8152fe89b05795f1763e72@o4509715134283776.ingest.us.sentry.io/4509715135987712";
 
 pub fn init_panic_hook(
     app_version: SemanticVersion,
@@ -152,6 +154,15 @@ pub fn init_panic_hook(
     }));
 }
 
+pub fn init_sentry(app_commit_sha: Option<AppCommitSha>, cx: &mut App) {
+    let mut options = sentry::ClientOptions::default();
+    options.release = app_commit_sha.map(|sha| Cow::Owned(sha.short()));
+    if TelemetrySettings::get_global(cx).diagnostics {
+        std::mem::forget(sentry::init((SENTRY_DSN, options)));
+    }
+    panic!("another panic");
+}
+
 #[cfg(not(target_os = "windows"))]
 fn get_main_module_base_address() -> *mut c_void {
     let mut dl_info = libc::Dl_info {

crates/zed/src/zed.rs 🔗

@@ -125,7 +125,7 @@ pub fn init(cx: &mut App) {
 
     cx.on_action(|_: &RestoreBanner, cx| title_bar::restore_banner(cx));
     if ReleaseChannel::global(cx) == ReleaseChannel::Dev || cx.has_flag::<PanicFeatureFlag>() {
-        cx.on_action(|_: &TestPanic, _| panic!("Ran the TestPanic action"));
+        cx.on_action(|_: &TestPanic, _| panic!("You Ran the TestPanic action"));
     }
     cx.on_action(|_: &OpenLog, cx| {
         with_active_or_new_workspace(cx, |workspace, window, cx| {