diff --git a/Cargo.lock b/Cargo.lock index 7fedec699d8ddf0f78077511dbabab7796468a70..15f43d362c0ede1f43c55550a4bbbf3a43f45f24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5462,6 +5462,7 @@ dependencies = [ "settings", "smallvec", "strum", + "telemetry", "theme", "time", "ui", diff --git a/crates/client/src/telemetry.rs b/crates/client/src/telemetry.rs index 309779049e82f8b03fff9e9c91b96d8da1c061d6..731412c8188827f2c87373a1dcc312069bdd4610 100644 --- a/crates/client/src/telemetry.rs +++ b/crates/client/src/telemetry.rs @@ -418,6 +418,8 @@ impl Telemetry { fn report_event(self: &Arc, 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.toml index a6a20b907fd255fa20bce4e087370b269d613f73..9cb2421828fa69f82c8b3efa292075890b8914b8 100644 --- a/crates/git_ui/Cargo.toml +++ b/crates/git_ui/Cargo.toml @@ -47,6 +47,7 @@ serde_json.workspace = true settings.workspace = true smallvec.workspace = true strum.workspace = true +telemetry.workspace = true theme.workspace = true time.workspace = true ui.workspace = true diff --git a/crates/git_ui/src/commit_modal.rs b/crates/git_ui/src/commit_modal.rs index 37541a0c844464d619bfb4ca1a762c722a2a42db..ea8583e689b5221db8bca3b1b19f0c069e2be851 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) { + 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.rs index 1a961e8cfb6b25cd79ed70b44c6b4449a4d14dc6..1ae9b6f0e39dbf6c197824fbc92e9b3e1f0a4c78 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -1171,6 +1171,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(); @@ -1269,6 +1270,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); @@ -1406,6 +1408,7 @@ impl GitPanel { let 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 { @@ -1441,6 +1444,7 @@ impl GitPanel { let 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 { @@ -1495,6 +1499,7 @@ impl GitPanel { let Some(branch) = repo.read(cx).current_branch() else { return; }; + telemetry::event!("Git Pushed"); let branch = branch.clone(); let options = if force_push { PushOptions::Force @@ -2193,6 +2198,10 @@ impl GitPanel { .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.rs index 490c499ccbcf69a437a835e04b4840474e84933b..614c3cb41f5e4aa16a0258f31116c2b70677254a 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, ) { + 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::(cx) { workspace.activate_item(&existing, true, true, window, cx); existing diff --git a/crates/telemetry/src/telemetry.rs b/crates/telemetry/src/telemetry.rs index 9fb05543a984ebe613946fef790df9aa6aba6d40..f8f7d5851e66a94452cf3461487fbc1718735e44 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) => {{