Add telemetry::event! (#22146)

CC @JosephTLyons

Release Notes:

- N/A
This commit is contained in:
Conrad Irwin 2024-12-17 11:39:18 -07:00 committed by GitHub
parent b17f2089a2
commit 7425d242bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 179 additions and 140 deletions

View file

@ -25,6 +25,7 @@ settings.workspace = true
theme.workspace = true
ui.workspace = true
util.workspace = true
telemetry.workspace = true
workspace.workspace = true
zed_actions.workspace = true

View file

@ -4,7 +4,7 @@ use std::{
time::Duration,
};
use client::{parse_zed_link, telemetry::Telemetry};
use client::parse_zed_link;
use collections::HashMap;
use command_palette_hooks::{
CommandInterceptResult, CommandPaletteFilter, CommandPaletteInterceptor,
@ -63,18 +63,12 @@ impl CommandPalette {
let Some(previous_focus_handle) = cx.focused() else {
return;
};
let telemetry = workspace.client().telemetry().clone();
workspace.toggle_modal(cx, move |cx| {
CommandPalette::new(previous_focus_handle, telemetry, query, cx)
CommandPalette::new(previous_focus_handle, query, cx)
});
}
fn new(
previous_focus_handle: FocusHandle,
telemetry: Arc<Telemetry>,
query: &str,
cx: &mut ViewContext<Self>,
) -> Self {
fn new(previous_focus_handle: FocusHandle, query: &str, cx: &mut ViewContext<Self>) -> Self {
let filter = CommandPaletteFilter::try_global(cx);
let commands = cx
@ -92,12 +86,8 @@ impl CommandPalette {
})
.collect();
let delegate = CommandPaletteDelegate::new(
cx.view().downgrade(),
commands,
telemetry,
previous_focus_handle,
);
let delegate =
CommandPaletteDelegate::new(cx.view().downgrade(), commands, previous_focus_handle);
let picker = cx.new_view(|cx| {
let picker = Picker::uniform_list(delegate, cx);
@ -133,7 +123,6 @@ pub struct CommandPaletteDelegate {
commands: Vec<Command>,
matches: Vec<StringMatch>,
selected_ix: usize,
telemetry: Arc<Telemetry>,
previous_focus_handle: FocusHandle,
updating_matches: Option<(
Task<()>,
@ -167,7 +156,6 @@ impl CommandPaletteDelegate {
fn new(
command_palette: WeakView<CommandPalette>,
commands: Vec<Command>,
telemetry: Arc<Telemetry>,
previous_focus_handle: FocusHandle,
) -> Self {
Self {
@ -176,7 +164,6 @@ impl CommandPaletteDelegate {
matches: vec![],
commands,
selected_ix: 0,
telemetry,
previous_focus_handle,
updating_matches: None,
}
@ -367,9 +354,11 @@ impl PickerDelegate for CommandPaletteDelegate {
let action_ix = self.matches[self.selected_ix].candidate_id;
let command = self.commands.swap_remove(action_ix);
self.telemetry
.report_action_event("command palette", command.name.clone());
telemetry::event!(
"Action Invoked",
source = "command palette",
action = command.name
);
self.matches.clear();
self.commands.clear();
HitCounts::update_global(cx, |hit_counts, _cx| {