Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Git telemetry (#26222)
Conrad Irwin9c054f207ec1
diff --git a/Cargo.lock b/Cargo.lockindex 17caa759afa..e85020e9bcc 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -5470,6 +5470,7 @@ dependencies = ["settings","smallvec","strum",+ "telemetry","theme","time","ui",diff --git a/crates/client/src/telemetry.rs b/crates/client/src/telemetry.rsindex 309779049e8..731412c8188 100644--- a/crates/client/src/telemetry.rs+++ b/crates/client/src/telemetry.rs@@ -418,6 +418,8 @@ impl Telemetry {fn report_event(self: &Arc<Self>, event: Event) {let mut state = self.state.lock();+ // RUST_LOG=telemetry=trace to debug telemetry events+ log::trace!(target: "telemetry", "{:?}", event);if !state.settings.metrics {return;diff --git a/crates/git_ui/Cargo.toml b/crates/git_ui/Cargo.tomlindex aa95e788797..56c3bdc9e4a 100644--- a/crates/git_ui/Cargo.toml+++ b/crates/git_ui/Cargo.toml@@ -48,6 +48,7 @@ serde_json.workspace = truesettings.workspace = truesmallvec.workspace = truestrum.workspace = true+telemetry.workspace = truetheme.workspace = truetime.workspace = trueui.workspace = truediff --git a/crates/git_ui/src/commit_modal.rs b/crates/git_ui/src/commit_modal.rsindex 37541a0c844..ea8583e689b 100644--- a/crates/git_ui/src/commit_modal.rs+++ b/crates/git_ui/src/commit_modal.rs@@ -301,6 +301,7 @@ impl CommitModal {}).disabled(!can_commit).on_click(cx.listener(move |this, _: &ClickEvent, window, cx| {+ telemetry::event!("Git Committed", source = "Git Modal");this.git_panel.update(cx, |git_panel, cx| git_panel.commit_changes(window, cx));cx.emit(DismissEvent);@@ -334,6 +335,7 @@ impl CommitModal {}fn commit(&mut self, _: &git::Commit, window: &mut Window, cx: &mut Context<Self>) {+ telemetry::event!("Git Committed", source = "Git Modal");self.git_panel.update(cx, |git_panel, cx| git_panel.commit_changes(window, cx));cx.emit(DismissEvent);diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rsindex 631ee643231..7512f2bdc0f 100644--- a/crates/git_ui/src/git_panel.rs+++ b/crates/git_ui/src/git_panel.rs@@ -1177,6 +1177,7 @@ impl GitPanel {.focus_handle(cx).contains_focused(window, cx){+ telemetry::event!("Git Committed", source = "Git Panel");self.commit_changes(window, cx)} else {cx.propagate();@@ -1275,6 +1276,7 @@ impl GitPanel {let Some(repo) = self.active_repository.clone() else {return;};+ telemetry::event!("Git Uncommitted");let confirmation = self.check_for_pushed_commits(window, cx);let prior_head = self.load_commit_details("HEAD", cx);@@ -1477,6 +1479,7 @@ index 1234567..abcdef0 100644let Some(repo) = self.active_repository.clone() else {return;};+ telemetry::event!("Git Fetched");let guard = self.start_remote_operation();let askpass = self.askpass_delegate("git fetch", window, cx);cx.spawn(|this, mut cx| async move {@@ -1512,6 +1515,7 @@ index 1234567..abcdef0 100644let Some(branch) = repo.read(cx).current_branch() else {return;};+ telemetry::event!("Git Pulled");let branch = branch.clone();let remote = self.get_current_remote(window, cx);cx.spawn_in(window, move |this, mut cx| async move {@@ -1566,6 +1570,7 @@ index 1234567..abcdef0 100644let Some(branch) = repo.read(cx).current_branch() else {return;};+ telemetry::event!("Git Pushed");let branch = branch.clone();let options = if force_push {PushOptions::Force@@ -2276,6 +2281,10 @@ index 1234567..abcdef0 100644.disabled(!can_commit || self.modal_open).on_click({cx.listener(move |this, _: &ClickEvent, window, cx| {+ telemetry::event!(+ "Git Committed",+ source = "Git Panel"+ );this.commit_changes(window, cx)})}),diff --git a/crates/git_ui/src/project_diff.rs b/crates/git_ui/src/project_diff.rsindex fa9e1c56322..81fb36321ba 100644--- a/crates/git_ui/src/project_diff.rs+++ b/crates/git_ui/src/project_diff.rs@@ -90,6 +90,14 @@ impl ProjectDiff {window: &mut Window,cx: &mut Context<Workspace>,) {+ telemetry::event!(+ "Git Diff Opened",+ source = if entry.is_some() {+ "Git Panel"+ } else {+ "Action"+ }+ );let project_diff = if let Some(existing) = workspace.item_of_type::<Self>(cx) {workspace.activate_item(&existing, true, true, window, cx);existingdiff --git a/crates/telemetry/src/telemetry.rs b/crates/telemetry/src/telemetry.rsindex 9fb05543a98..f8f7d5851e6 100644--- a/crates/telemetry/src/telemetry.rs+++ b/crates/telemetry/src/telemetry.rs@@ -15,6 +15,8 @@ pub use telemetry_events::FlexibleEvent as Event;/// telemetry::event!("Keymap Changed", version = "1.0.0");/// telemetry::event!("Documentation Viewed", url, source = "Extension Upsell");/// ```+///+/// If you want to debug logging in development, export `RUST_LOG=telemetry=trace`#[macro_export]macro_rules! event {($name:expr) => {{