Add more open events (#4061)

Adds open events for

- Welcome page
- Project search
- Project diagnostics

Release Notes:

- N/A
This commit is contained in:
Joseph T. Lyons 2024-01-15 16:36:24 -05:00 committed by GitHub
commit acf85db44e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 95 additions and 31 deletions

View file

@ -114,6 +114,8 @@ pub trait Item: FocusableView + EventEmitter<Self::Event> {
}
fn tab_content(&self, detail: Option<usize>, selected: bool, cx: &WindowContext) -> AnyElement;
fn telemetry_event_text(&self) -> Option<&'static str>;
/// (model id, Item)
fn for_each_project_item(
&self,
@ -225,6 +227,7 @@ pub trait ItemHandle: 'static + Send {
fn tab_tooltip_text(&self, cx: &AppContext) -> Option<SharedString>;
fn tab_description(&self, detail: usize, cx: &AppContext) -> Option<SharedString>;
fn tab_content(&self, detail: Option<usize>, selected: bool, cx: &WindowContext) -> AnyElement;
fn telemetry_event_text(&self, cx: &WindowContext) -> Option<&'static str>;
fn dragged_tab_content(&self, detail: Option<usize>, cx: &WindowContext) -> AnyElement;
fn project_path(&self, cx: &AppContext) -> Option<ProjectPath>;
fn project_entry_ids(&self, cx: &AppContext) -> SmallVec<[ProjectEntryId; 3]>;
@ -313,6 +316,10 @@ impl<T: Item> ItemHandle for View<T> {
self.read(cx).tab_tooltip_text(cx)
}
fn telemetry_event_text(&self, cx: &WindowContext) -> Option<&'static str> {
self.read(cx).telemetry_event_text()
}
fn tab_description(&self, detail: usize, cx: &AppContext) -> Option<SharedString> {
self.read(cx).tab_description(detail, cx)
}
@ -922,6 +929,10 @@ pub mod test {
})
}
fn telemetry_event_text(&self) -> Option<&'static str> {
None
}
fn tab_content(
&self,
detail: Option<usize>,

View file

@ -111,6 +111,10 @@ impl Item for SharedScreen {
.into_any()
}
fn telemetry_event_text(&self) -> Option<&'static str> {
None
}
fn set_nav_history(&mut self, history: ItemNavHistory, _: &mut ViewContext<Self>) {
self.nav_history = Some(history);
}

View file

@ -1271,7 +1271,9 @@ impl Workspace {
}
pub fn open(&mut self, _: &Open, cx: &mut ViewContext<Self>) {
self.client().telemetry().report_app_event("open project");
self.client()
.telemetry()
.report_app_event("open project".to_string());
let paths = cx.prompt_for_paths(PathPromptOptions {
files: true,
directories: true,
@ -1776,6 +1778,12 @@ impl Workspace {
}
pub fn add_item(&mut self, item: Box<dyn ItemHandle>, cx: &mut ViewContext<Self>) {
if let Some(text) = item.telemetry_event_text(cx) {
self.client()
.telemetry()
.report_app_event(format!("{}: open", text));
}
self.active_pane
.update(cx, |pane, cx| pane.add_item(item, true, true, None, cx));
}