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

View file

@ -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;

View file

@ -48,6 +48,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

View file

@ -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);

View file

@ -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 100644
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 {
@ -1512,6 +1515,7 @@ index 1234567..abcdef0 100644
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 {
@ -1566,6 +1570,7 @@ index 1234567..abcdef0 100644
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
@ -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)
})
}),

View file

@ -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);
existing

View file

@ -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) => {{