Skip to content

Commit

Permalink
action event too
Browse files Browse the repository at this point in the history
  • Loading branch information
ConradIrwin committed Dec 17, 2024
1 parent ebc5945 commit 21d36e7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 33 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 2 additions & 12 deletions crates/client/src/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ use std::io::Write;
use std::time::Instant;
use std::{env, mem, path::PathBuf, sync::Arc, time::Duration};
use telemetry_events::{
ActionEvent, AppEvent, AssistantEvent, CallEvent, EditEvent, Event, EventRequestBody,
EventWrapper, InlineCompletionEvent, InlineCompletionRating, InlineCompletionRatingEvent,
SettingEvent,
AppEvent, AssistantEvent, CallEvent, EditEvent, Event, EventRequestBody, EventWrapper,
InlineCompletionEvent, InlineCompletionRating, InlineCompletionRatingEvent, SettingEvent,
};
use util::{ResultExt, TryFutureExt};
use worktree::{UpdatedEntriesSet, WorktreeId};
Expand Down Expand Up @@ -423,15 +422,6 @@ impl Telemetry {
}
}

pub fn report_action_event(self: &Arc<Self>, source: &'static str, action: String) {
let event = Event::Action(ActionEvent {
source: source.to_string(),
action,
});

self.report_event(event)
}

pub fn report_discovered_project_events(
self: &Arc<Self>,
worktree_id: WorktreeId,
Expand Down
1 change: 1 addition & 0 deletions crates/command_palette/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
31 changes: 10 additions & 21 deletions crates/command_palette/src/command_palette.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -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<()>,
Expand Down Expand Up @@ -167,7 +156,6 @@ impl CommandPaletteDelegate {
fn new(
command_palette: WeakView<CommandPalette>,
commands: Vec<Command>,
telemetry: Arc<Telemetry>,
previous_focus_handle: FocusHandle,
) -> Self {
Self {
Expand All @@ -176,7 +164,6 @@ impl CommandPaletteDelegate {
matches: vec![],
commands,
selected_ix: 0,
telemetry,
previous_focus_handle,
updating_matches: None,
}
Expand Down Expand Up @@ -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| {
Expand Down

0 comments on commit 21d36e7

Please sign in to comment.