Git telemetry (#26222)

Release Notes:

- git: Adds telemetry to git actions
This commit is contained in:
Conrad Irwin 2025-03-06 10:56:28 -07:00 committed by GitHub
parent 219d36f589
commit 9c054f207e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 25 additions and 0 deletions

1
Cargo.lock generated
View file

@ -5470,6 +5470,7 @@ dependencies = [
"settings", "settings",
"smallvec", "smallvec",
"strum", "strum",
"telemetry",
"theme", "theme",
"time", "time",
"ui", "ui",

View file

@ -418,6 +418,8 @@ impl Telemetry {
fn report_event(self: &Arc<Self>, event: Event) { fn report_event(self: &Arc<Self>, event: Event) {
let mut state = self.state.lock(); let mut state = self.state.lock();
// RUST_LOG=telemetry=trace to debug telemetry events
log::trace!(target: "telemetry", "{:?}", event);
if !state.settings.metrics { if !state.settings.metrics {
return; return;

View file

@ -48,6 +48,7 @@ serde_json.workspace = true
settings.workspace = true settings.workspace = true
smallvec.workspace = true smallvec.workspace = true
strum.workspace = true strum.workspace = true
telemetry.workspace = true
theme.workspace = true theme.workspace = true
time.workspace = true time.workspace = true
ui.workspace = true ui.workspace = true

View file

@ -301,6 +301,7 @@ impl CommitModal {
}) })
.disabled(!can_commit) .disabled(!can_commit)
.on_click(cx.listener(move |this, _: &ClickEvent, window, cx| { .on_click(cx.listener(move |this, _: &ClickEvent, window, cx| {
telemetry::event!("Git Committed", source = "Git Modal");
this.git_panel this.git_panel
.update(cx, |git_panel, cx| git_panel.commit_changes(window, cx)); .update(cx, |git_panel, cx| git_panel.commit_changes(window, cx));
cx.emit(DismissEvent); cx.emit(DismissEvent);
@ -334,6 +335,7 @@ impl CommitModal {
} }
fn commit(&mut self, _: &git::Commit, window: &mut Window, cx: &mut Context<Self>) { fn commit(&mut self, _: &git::Commit, window: &mut Window, cx: &mut Context<Self>) {
telemetry::event!("Git Committed", source = "Git Modal");
self.git_panel self.git_panel
.update(cx, |git_panel, cx| git_panel.commit_changes(window, cx)); .update(cx, |git_panel, cx| git_panel.commit_changes(window, cx));
cx.emit(DismissEvent); cx.emit(DismissEvent);

View file

@ -1177,6 +1177,7 @@ impl GitPanel {
.focus_handle(cx) .focus_handle(cx)
.contains_focused(window, cx) .contains_focused(window, cx)
{ {
telemetry::event!("Git Committed", source = "Git Panel");
self.commit_changes(window, cx) self.commit_changes(window, cx)
} else { } else {
cx.propagate(); cx.propagate();
@ -1275,6 +1276,7 @@ impl GitPanel {
let Some(repo) = self.active_repository.clone() else { let Some(repo) = self.active_repository.clone() else {
return; return;
}; };
telemetry::event!("Git Uncommitted");
let confirmation = self.check_for_pushed_commits(window, cx); let confirmation = self.check_for_pushed_commits(window, cx);
let prior_head = self.load_commit_details("HEAD", cx); let prior_head = self.load_commit_details("HEAD", cx);
@ -1477,6 +1479,7 @@ index 1234567..abcdef0 100644
let Some(repo) = self.active_repository.clone() else { let Some(repo) = self.active_repository.clone() else {
return; return;
}; };
telemetry::event!("Git Fetched");
let guard = self.start_remote_operation(); let guard = self.start_remote_operation();
let askpass = self.askpass_delegate("git fetch", window, cx); let askpass = self.askpass_delegate("git fetch", window, cx);
cx.spawn(|this, mut cx| async move { cx.spawn(|this, mut cx| async move {
@ -1512,6 +1515,7 @@ index 1234567..abcdef0 100644
let Some(branch) = repo.read(cx).current_branch() else { let Some(branch) = repo.read(cx).current_branch() else {
return; return;
}; };
telemetry::event!("Git Pulled");
let branch = branch.clone(); let branch = branch.clone();
let remote = self.get_current_remote(window, cx); let remote = self.get_current_remote(window, cx);
cx.spawn_in(window, move |this, mut cx| async move { cx.spawn_in(window, move |this, mut cx| async move {
@ -1566,6 +1570,7 @@ index 1234567..abcdef0 100644
let Some(branch) = repo.read(cx).current_branch() else { let Some(branch) = repo.read(cx).current_branch() else {
return; return;
}; };
telemetry::event!("Git Pushed");
let branch = branch.clone(); let branch = branch.clone();
let options = if force_push { let options = if force_push {
PushOptions::Force PushOptions::Force
@ -2276,6 +2281,10 @@ index 1234567..abcdef0 100644
.disabled(!can_commit || self.modal_open) .disabled(!can_commit || self.modal_open)
.on_click({ .on_click({
cx.listener(move |this, _: &ClickEvent, window, cx| { cx.listener(move |this, _: &ClickEvent, window, cx| {
telemetry::event!(
"Git Committed",
source = "Git Panel"
);
this.commit_changes(window, cx) this.commit_changes(window, cx)
}) })
}), }),

View file

@ -90,6 +90,14 @@ impl ProjectDiff {
window: &mut Window, window: &mut Window,
cx: &mut Context<Workspace>, 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) { let project_diff = if let Some(existing) = workspace.item_of_type::<Self>(cx) {
workspace.activate_item(&existing, true, true, window, cx); workspace.activate_item(&existing, true, true, window, cx);
existing existing

View file

@ -15,6 +15,8 @@ pub use telemetry_events::FlexibleEvent as Event;
/// telemetry::event!("Keymap Changed", version = "1.0.0"); /// telemetry::event!("Keymap Changed", version = "1.0.0");
/// telemetry::event!("Documentation Viewed", url, source = "Extension Upsell"); /// telemetry::event!("Documentation Viewed", url, source = "Extension Upsell");
/// ``` /// ```
///
/// If you want to debug logging in development, export `RUST_LOG=telemetry=trace`
#[macro_export] #[macro_export]
macro_rules! event { macro_rules! event {
($name:expr) => {{ ($name:expr) => {{