More telemetry events (#22171)

- **Convert more events to telemetry::event**
- **And call events**

Closes #ISSUE

Release Notes:

- N/A
This commit is contained in:
Conrad Irwin 2024-12-17 22:16:59 -07:00 committed by GitHub
parent 1b83020dc8
commit 94bfb93d35
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 97 additions and 159 deletions

8
Cargo.lock generated
View file

@ -2115,6 +2115,7 @@ dependencies = [
"serde", "serde",
"serde_derive", "serde_derive",
"settings", "settings",
"telemetry",
"util", "util",
] ]
@ -2782,6 +2783,7 @@ dependencies = [
"settings", "settings",
"smallvec", "smallvec",
"story", "story",
"telemetry",
"theme", "theme",
"time", "time",
"time_format", "time_format",
@ -12875,7 +12877,6 @@ dependencies = [
name = "theme_selector" name = "theme_selector"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"client",
"fs", "fs",
"fuzzy", "fuzzy",
"gpui", "gpui",
@ -12883,6 +12884,7 @@ dependencies = [
"picker", "picker",
"serde", "serde",
"settings", "settings",
"telemetry",
"theme", "theme",
"ui", "ui",
"util", "util",
@ -13112,6 +13114,7 @@ dependencies = [
"settings", "settings",
"smallvec", "smallvec",
"story", "story",
"telemetry",
"theme", "theme",
"tree-sitter-md", "tree-sitter-md",
"ui", "ui",
@ -14890,6 +14893,7 @@ dependencies = [
"schemars", "schemars",
"serde", "serde",
"settings", "settings",
"telemetry",
"ui", "ui",
"util", "util",
"vim_mode_setting", "vim_mode_setting",
@ -16093,6 +16097,7 @@ dependencies = [
"tab_switcher", "tab_switcher",
"task", "task",
"tasks_ui", "tasks_ui",
"telemetry",
"telemetry_events", "telemetry_events",
"terminal_view", "terminal_view",
"theme", "theme",
@ -16465,6 +16470,7 @@ dependencies = [
"serde_json", "serde_json",
"settings", "settings",
"similar", "similar",
"telemetry",
"telemetry_events", "telemetry_events",
"theme", "theme",
"tree-sitter-go", "tree-sitter-go",

View file

@ -40,6 +40,7 @@ schemars.workspace = true
serde.workspace = true serde.workspace = true
serde_derive.workspace = true serde_derive.workspace = true
settings.workspace = true settings.workspace = true
telemetry.workspace = true
util.workspace = true util.workspace = true
[target.'cfg(target_os = "macos")'.dependencies] [target.'cfg(target_os = "macos")'.dependencies]

View file

@ -250,7 +250,9 @@ impl ActiveCall {
cx.spawn(move |this, mut cx| async move { cx.spawn(move |this, mut cx| async move {
let result = invite.await; let result = invite.await;
if result.is_ok() { if result.is_ok() {
this.update(&mut cx, |this, cx| this.report_call_event("invite", cx))?; this.update(&mut cx, |this, cx| {
this.report_call_event("Participant Invited", cx)
})?;
} else { } else {
//TODO: report collaboration error //TODO: report collaboration error
log::error!("invite failed: {:?}", result); log::error!("invite failed: {:?}", result);
@ -318,7 +320,7 @@ impl ActiveCall {
this.update(&mut cx, |this, cx| this.set_room(room.clone(), cx))? this.update(&mut cx, |this, cx| this.set_room(room.clone(), cx))?
.await?; .await?;
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
this.report_call_event("accept incoming", cx) this.report_call_event("Incoming Call Accepted", cx)
})?; })?;
Ok(()) Ok(())
}) })
@ -331,7 +333,7 @@ impl ActiveCall {
.borrow_mut() .borrow_mut()
.take() .take()
.ok_or_else(|| anyhow!("no incoming call"))?; .ok_or_else(|| anyhow!("no incoming call"))?;
report_call_event_for_room("decline incoming", call.room_id, None, &self.client); telemetry::event!("Incoming Call Declined", room_id = call.room_id);
self.client.send(proto::DeclineCall { self.client.send(proto::DeclineCall {
room_id: call.room_id, room_id: call.room_id,
})?; })?;
@ -366,7 +368,7 @@ impl ActiveCall {
this.update(&mut cx, |this, cx| this.set_room(room.clone(), cx))? this.update(&mut cx, |this, cx| this.set_room(room.clone(), cx))?
.await?; .await?;
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
this.report_call_event("join channel", cx) this.report_call_event("Channel Joined", cx)
})?; })?;
Ok(room) Ok(room)
}) })
@ -374,7 +376,7 @@ impl ActiveCall {
pub fn hang_up(&mut self, cx: &mut ModelContext<Self>) -> Task<Result<()>> { pub fn hang_up(&mut self, cx: &mut ModelContext<Self>) -> Task<Result<()>> {
cx.notify(); cx.notify();
self.report_call_event("hang up", cx); self.report_call_event("Call Ended", cx);
Audio::end_call(cx); Audio::end_call(cx);
@ -393,7 +395,7 @@ impl ActiveCall {
cx: &mut ModelContext<Self>, cx: &mut ModelContext<Self>,
) -> Task<Result<u64>> { ) -> Task<Result<u64>> {
if let Some((room, _)) = self.room.as_ref() { if let Some((room, _)) = self.room.as_ref() {
self.report_call_event("share project", cx); self.report_call_event("Project Shared", cx);
room.update(cx, |room, cx| room.share_project(project, cx)) room.update(cx, |room, cx| room.share_project(project, cx))
} else { } else {
Task::ready(Err(anyhow!("no active call"))) Task::ready(Err(anyhow!("no active call")))
@ -406,7 +408,7 @@ impl ActiveCall {
cx: &mut ModelContext<Self>, cx: &mut ModelContext<Self>,
) -> Result<()> { ) -> Result<()> {
if let Some((room, _)) = self.room.as_ref() { if let Some((room, _)) = self.room.as_ref() {
self.report_call_event("unshare project", cx); self.report_call_event("Project Unshared", cx);
room.update(cx, |room, cx| room.unshare_project(project, cx)) room.update(cx, |room, cx| room.unshare_project(project, cx))
} else { } else {
Err(anyhow!("no active call")) Err(anyhow!("no active call"))
@ -486,35 +488,15 @@ impl ActiveCall {
pub fn report_call_event(&self, operation: &'static str, cx: &mut AppContext) { pub fn report_call_event(&self, operation: &'static str, cx: &mut AppContext) {
if let Some(room) = self.room() { if let Some(room) = self.room() {
let room = room.read(cx); let room = room.read(cx);
report_call_event_for_room(operation, room.id(), room.channel_id(), &self.client); telemetry::event!(
operation,
room_id = room.id(),
channel_id = room.channel_id()
)
} }
} }
} }
pub fn report_call_event_for_room(
operation: &'static str,
room_id: u64,
channel_id: Option<ChannelId>,
client: &Arc<Client>,
) {
let telemetry = client.telemetry();
telemetry.report_call_event(operation, Some(room_id), channel_id)
}
pub fn report_call_event_for_channel(
operation: &'static str,
channel_id: ChannelId,
client: &Arc<Client>,
cx: &AppContext,
) {
let room = ActiveCall::global(cx).read(cx).room();
let telemetry = client.telemetry();
telemetry.report_call_event(operation, room.map(|r| r.read(cx).id()), Some(channel_id))
}
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use gpui::TestAppContext; use gpui::TestAppContext;

View file

@ -243,7 +243,9 @@ impl ActiveCall {
cx.spawn(move |this, mut cx| async move { cx.spawn(move |this, mut cx| async move {
let result = invite.await; let result = invite.await;
if result.is_ok() { if result.is_ok() {
this.update(&mut cx, |this, cx| this.report_call_event("invite", cx))?; this.update(&mut cx, |this, cx| {
this.report_call_event("Participant Invited", cx)
})?;
} else { } else {
//TODO: report collaboration error //TODO: report collaboration error
log::error!("invite failed: {:?}", result); log::error!("invite failed: {:?}", result);
@ -311,7 +313,7 @@ impl ActiveCall {
this.update(&mut cx, |this, cx| this.set_room(room.clone(), cx))? this.update(&mut cx, |this, cx| this.set_room(room.clone(), cx))?
.await?; .await?;
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
this.report_call_event("accept incoming", cx) this.report_call_event("Incoming Call Accepted", cx)
})?; })?;
Ok(()) Ok(())
}) })
@ -324,7 +326,7 @@ impl ActiveCall {
.borrow_mut() .borrow_mut()
.take() .take()
.ok_or_else(|| anyhow!("no incoming call"))?; .ok_or_else(|| anyhow!("no incoming call"))?;
report_call_event_for_room("decline incoming", call.room_id, None, &self.client); telemetry::event!("Incoming Call Declined", room_id = call.room_id);
self.client.send(proto::DeclineCall { self.client.send(proto::DeclineCall {
room_id: call.room_id, room_id: call.room_id,
})?; })?;
@ -359,7 +361,7 @@ impl ActiveCall {
this.update(&mut cx, |this, cx| this.set_room(room.clone(), cx))? this.update(&mut cx, |this, cx| this.set_room(room.clone(), cx))?
.await?; .await?;
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
this.report_call_event("join channel", cx) this.report_call_event("Channel Joined", cx)
})?; })?;
Ok(room) Ok(room)
}) })
@ -367,7 +369,7 @@ impl ActiveCall {
pub fn hang_up(&mut self, cx: &mut ModelContext<Self>) -> Task<Result<()>> { pub fn hang_up(&mut self, cx: &mut ModelContext<Self>) -> Task<Result<()>> {
cx.notify(); cx.notify();
self.report_call_event("hang up", cx); self.report_call_event("Call Ended", cx);
Audio::end_call(cx); Audio::end_call(cx);
@ -386,7 +388,7 @@ impl ActiveCall {
cx: &mut ModelContext<Self>, cx: &mut ModelContext<Self>,
) -> Task<Result<u64>> { ) -> Task<Result<u64>> {
if let Some((room, _)) = self.room.as_ref() { if let Some((room, _)) = self.room.as_ref() {
self.report_call_event("share project", cx); self.report_call_event("Project Shared", cx);
room.update(cx, |room, cx| room.share_project(project, cx)) room.update(cx, |room, cx| room.share_project(project, cx))
} else { } else {
Task::ready(Err(anyhow!("no active call"))) Task::ready(Err(anyhow!("no active call")))
@ -399,7 +401,7 @@ impl ActiveCall {
cx: &mut ModelContext<Self>, cx: &mut ModelContext<Self>,
) -> Result<()> { ) -> Result<()> {
if let Some((room, _)) = self.room.as_ref() { if let Some((room, _)) = self.room.as_ref() {
self.report_call_event("unshare project", cx); self.report_call_event("Project Unshared", cx);
room.update(cx, |room, cx| room.unshare_project(project, cx)) room.update(cx, |room, cx| room.unshare_project(project, cx))
} else { } else {
Err(anyhow!("no active call")) Err(anyhow!("no active call"))
@ -479,35 +481,15 @@ impl ActiveCall {
pub fn report_call_event(&self, operation: &'static str, cx: &mut AppContext) { pub fn report_call_event(&self, operation: &'static str, cx: &mut AppContext) {
if let Some(room) = self.room() { if let Some(room) = self.room() {
let room = room.read(cx); let room = room.read(cx);
report_call_event_for_room(operation, room.id(), room.channel_id(), &self.client); telemetry::event!(
operation,
room_id = room.id(),
channel_id = room.channel_id()
);
} }
} }
} }
pub fn report_call_event_for_room(
operation: &'static str,
room_id: u64,
channel_id: Option<ChannelId>,
client: &Arc<Client>,
) {
let telemetry = client.telemetry();
telemetry.report_call_event(operation, Some(room_id), channel_id)
}
pub fn report_call_event_for_channel(
operation: &'static str,
channel_id: ChannelId,
client: &Arc<Client>,
cx: &AppContext,
) {
let room = ActiveCall::global(cx).read(cx).room();
let telemetry = client.telemetry();
telemetry.report_call_event(operation, room.map(|r| r.read(cx).id()), Some(channel_id))
}
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use gpui::TestAppContext; use gpui::TestAppContext;

View file

@ -19,7 +19,7 @@ use std::time::Instant;
use std::{env, mem, path::PathBuf, sync::Arc, time::Duration}; use std::{env, mem, path::PathBuf, sync::Arc, time::Duration};
use telemetry_events::{ use telemetry_events::{
AppEvent, AssistantEvent, CallEvent, EditEvent, Event, EventRequestBody, EventWrapper, AppEvent, AssistantEvent, CallEvent, EditEvent, Event, EventRequestBody, EventWrapper,
InlineCompletionEvent, InlineCompletionRating, InlineCompletionRatingEvent, SettingEvent, InlineCompletionEvent,
}; };
use util::{ResultExt, TryFutureExt}; use util::{ResultExt, TryFutureExt};
use worktree::{UpdatedEntriesSet, WorktreeId}; use worktree::{UpdatedEntriesSet, WorktreeId};
@ -349,24 +349,6 @@ impl Telemetry {
self.report_event(event) self.report_event(event)
} }
pub fn report_inline_completion_rating_event(
self: &Arc<Self>,
rating: InlineCompletionRating,
input_events: Arc<str>,
input_excerpt: Arc<str>,
output_excerpt: Arc<str>,
feedback: String,
) {
let event = Event::InlineCompletionRating(InlineCompletionRatingEvent {
rating,
input_events,
input_excerpt,
output_excerpt,
feedback,
});
self.report_event(event);
}
pub fn report_assistant_event(self: &Arc<Self>, event: AssistantEvent) { pub fn report_assistant_event(self: &Arc<Self>, event: AssistantEvent) {
self.report_event(Event::Assistant(event)); self.report_event(Event::Assistant(event));
} }
@ -394,15 +376,6 @@ impl Telemetry {
event event
} }
pub fn report_setting_event(self: &Arc<Self>, setting: &'static str, value: String) {
let event = Event::Setting(SettingEvent {
setting: setting.to_string(),
value,
});
self.report_event(event)
}
pub fn log_edit_event(self: &Arc<Self>, environment: &'static str, is_via_ssh: bool) { pub fn log_edit_event(self: &Arc<Self>, environment: &'static str, is_via_ssh: bool) {
let mut state = self.state.lock(); let mut state = self.state.lock();
let period_data = state.event_coalescer.log_event(environment); let period_data = state.event_coalescer.log_event(environment);

View file

@ -16,7 +16,9 @@ use util::TryFutureExt as _;
pub type UserId = u64; pub type UserId = u64;
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)] #[derive(
Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, serde::Serialize, serde::Deserialize,
)]
pub struct ChannelId(pub u64); pub struct ChannelId(pub u64);
impl std::fmt::Display for ChannelId { impl std::fmt::Display for ChannelId {

View file

@ -56,6 +56,7 @@ serde_json.workspace = true
settings.workspace = true settings.workspace = true
smallvec.workspace = true smallvec.workspace = true
story = { workspace = true, optional = true } story = { workspace = true, optional = true }
telemetry.workspace = true
theme.workspace = true theme.workspace = true
time.workspace = true time.workspace = true
time_format.workspace = true time_format.workspace = true

View file

@ -1,5 +1,5 @@
use anyhow::Result; use anyhow::Result;
use call::report_call_event_for_channel; use call::ActiveCall;
use channel::{Channel, ChannelBuffer, ChannelBufferEvent, ChannelStore}; use channel::{Channel, ChannelBuffer, ChannelBufferEvent, ChannelStore};
use client::{ use client::{
proto::{self, PeerId}, proto::{self, PeerId},
@ -66,11 +66,13 @@ impl ChannelView {
cx.spawn(|mut cx| async move { cx.spawn(|mut cx| async move {
let channel_view = channel_view.await?; let channel_view = channel_view.await?;
pane.update(&mut cx, |pane, cx| { pane.update(&mut cx, |pane, cx| {
report_call_event_for_channel( telemetry::event!(
"open channel notes", "Channel Notes Opened",
channel_id, channel_id,
&workspace.read(cx).app_state().client, room_id = ActiveCall::global(cx)
cx, .read(cx)
.room()
.map(|r| r.read(cx).id())
); );
pane.add_item(Box::new(channel_view.clone()), true, true, None, cx); pane.add_item(Box::new(channel_view.clone()), true, true, None, cx);
})?; })?;

View file

@ -13,7 +13,6 @@ path = "src/theme_selector.rs"
doctest = false doctest = false
[dependencies] [dependencies]
client.workspace = true
fs.workspace = true fs.workspace = true
fuzzy.workspace = true fuzzy.workspace = true
gpui.workspace = true gpui.workspace = true
@ -21,6 +20,7 @@ log.workspace = true
picker.workspace = true picker.workspace = true
serde.workspace = true serde.workspace = true
settings.workspace = true settings.workspace = true
telemetry.workspace = true
theme.workspace = true theme.workspace = true
ui.workspace = true ui.workspace = true
util.workspace = true util.workspace = true

View file

@ -1,4 +1,3 @@
use client::telemetry::Telemetry;
use fs::Fs; use fs::Fs;
use fuzzy::{match_strings, StringMatch, StringMatchCandidate}; use fuzzy::{match_strings, StringMatch, StringMatchCandidate};
use gpui::{ use gpui::{
@ -27,12 +26,10 @@ pub fn init(cx: &mut AppContext) {
pub fn toggle(workspace: &mut Workspace, toggle: &Toggle, cx: &mut ViewContext<Workspace>) { pub fn toggle(workspace: &mut Workspace, toggle: &Toggle, cx: &mut ViewContext<Workspace>) {
let fs = workspace.app_state().fs.clone(); let fs = workspace.app_state().fs.clone();
let telemetry = workspace.client().telemetry().clone();
workspace.toggle_modal(cx, |cx| { workspace.toggle_modal(cx, |cx| {
let delegate = ThemeSelectorDelegate::new( let delegate = ThemeSelectorDelegate::new(
cx.view().downgrade(), cx.view().downgrade(),
fs, fs,
telemetry,
toggle.themes_filter.as_ref(), toggle.themes_filter.as_ref(),
cx, cx,
); );
@ -74,7 +71,6 @@ pub struct ThemeSelectorDelegate {
original_theme: Arc<Theme>, original_theme: Arc<Theme>,
selection_completed: bool, selection_completed: bool,
selected_index: usize, selected_index: usize,
telemetry: Arc<Telemetry>,
view: WeakView<ThemeSelector>, view: WeakView<ThemeSelector>,
} }
@ -82,7 +78,6 @@ impl ThemeSelectorDelegate {
fn new( fn new(
weak_view: WeakView<ThemeSelector>, weak_view: WeakView<ThemeSelector>,
fs: Arc<dyn Fs>, fs: Arc<dyn Fs>,
telemetry: Arc<Telemetry>,
themes_filter: Option<&Vec<String>>, themes_filter: Option<&Vec<String>>,
cx: &mut ViewContext<ThemeSelector>, cx: &mut ViewContext<ThemeSelector>,
) -> Self { ) -> Self {
@ -123,7 +118,6 @@ impl ThemeSelectorDelegate {
original_theme: original_theme.clone(), original_theme: original_theme.clone(),
selected_index: 0, selected_index: 0,
selection_completed: false, selection_completed: false,
telemetry,
view: weak_view, view: weak_view,
}; };
@ -180,8 +174,7 @@ impl PickerDelegate for ThemeSelectorDelegate {
let theme_name = cx.theme().name.clone(); let theme_name = cx.theme().name.clone();
self.telemetry telemetry::event!("Settings Changed", setting = "theme", value = theme_name);
.report_setting_event("theme", theme_name.to_string());
let appearance = Appearance::from(cx.appearance()); let appearance = Appearance::from(cx.appearance());

View file

@ -43,6 +43,7 @@ story = { workspace = true, optional = true }
theme.workspace = true theme.workspace = true
ui.workspace = true ui.workspace = true
util.workspace = true util.workspace = true
telemetry.workspace = true
workspace.workspace = true workspace.workspace = true
zed_actions.workspace = true zed_actions.workspace = true

View file

@ -1,6 +1,6 @@
use std::sync::Arc; use std::sync::Arc;
use call::{report_call_event_for_room, ActiveCall, ParticipantLocation, Room}; use call::{ActiveCall, ParticipantLocation, Room};
use client::{proto::PeerId, User}; use client::{proto::PeerId, User};
use gpui::{actions, AppContext, Task, WindowContext}; use gpui::{actions, AppContext, Task, WindowContext};
use gpui::{canvas, point, AnyElement, Hsla, IntoElement, MouseButton, Path, Styled}; use gpui::{canvas, point, AnyElement, Hsla, IntoElement, MouseButton, Path, Styled};
@ -19,22 +19,19 @@ actions!(
fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut WindowContext) { fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut WindowContext) {
let call = ActiveCall::global(cx).read(cx); let call = ActiveCall::global(cx).read(cx);
if let Some(room) = call.room().cloned() { if let Some(room) = call.room().cloned() {
let client = call.client();
let toggle_screen_sharing = room.update(cx, |room, cx| { let toggle_screen_sharing = room.update(cx, |room, cx| {
if room.is_screen_sharing() { if room.is_screen_sharing() {
report_call_event_for_room( telemetry::event!(
"disable screen share", "Screen Share Disabled",
room.id(), room_id = room.id(),
room.channel_id(), channel_id = room.channel_id(),
&client,
); );
Task::ready(room.unshare_screen(cx)) Task::ready(room.unshare_screen(cx))
} else { } else {
report_call_event_for_room( telemetry::event!(
"enable screen share", "Screen Share Enabled",
room.id(), room_id = room.id(),
room.channel_id(), channel_id = room.channel_id(),
&client,
); );
room.share_screen(cx) room.share_screen(cx)
} }
@ -46,14 +43,17 @@ fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut WindowContext) {
fn toggle_mute(_: &ToggleMute, cx: &mut AppContext) { fn toggle_mute(_: &ToggleMute, cx: &mut AppContext) {
let call = ActiveCall::global(cx).read(cx); let call = ActiveCall::global(cx).read(cx);
if let Some(room) = call.room().cloned() { if let Some(room) = call.room().cloned() {
let client = call.client();
room.update(cx, |room, cx| { room.update(cx, |room, cx| {
let operation = if room.is_muted() { let operation = if room.is_muted() {
"enable microphone" "Microphone Enabled"
} else { } else {
"disable microphone" "Microphone Disabled"
}; };
report_call_event_for_room(operation, room.id(), room.channel_id(), &client); telemetry::event!(
operation,
room_id = room.id(),
channel_id = room.channel_id(),
);
room.toggle_mute(cx) room.toggle_mute(cx)
}); });

View file

@ -28,6 +28,7 @@ schemars.workspace = true
serde.workspace = true serde.workspace = true
settings.workspace = true settings.workspace = true
ui.workspace = true ui.workspace = true
telemetry.workspace = true
util.workspace = true util.workspace = true
vim_mode_setting.workspace = true vim_mode_setting.workspace = true
workspace.workspace = true workspace.workspace = true

View file

@ -1,5 +1,4 @@
use super::base_keymap_setting::BaseKeymap; use super::base_keymap_setting::BaseKeymap;
use client::telemetry::Telemetry;
use fuzzy::{match_strings, StringMatch, StringMatchCandidate}; use fuzzy::{match_strings, StringMatch, StringMatchCandidate};
use gpui::{ use gpui::{
actions, AppContext, DismissEvent, EventEmitter, FocusableView, Render, Task, View, actions, AppContext, DismissEvent, EventEmitter, FocusableView, Render, Task, View,
@ -28,10 +27,9 @@ pub fn toggle(
cx: &mut ViewContext<Workspace>, cx: &mut ViewContext<Workspace>,
) { ) {
let fs = workspace.app_state().fs.clone(); let fs = workspace.app_state().fs.clone();
let telemetry = workspace.client().telemetry().clone();
workspace.toggle_modal(cx, |cx| { workspace.toggle_modal(cx, |cx| {
BaseKeymapSelector::new( BaseKeymapSelector::new(
BaseKeymapSelectorDelegate::new(cx.view().downgrade(), fs, telemetry, cx), BaseKeymapSelectorDelegate::new(cx.view().downgrade(), fs, cx),
cx, cx,
) )
}); });
@ -70,7 +68,6 @@ pub struct BaseKeymapSelectorDelegate {
view: WeakView<BaseKeymapSelector>, view: WeakView<BaseKeymapSelector>,
matches: Vec<StringMatch>, matches: Vec<StringMatch>,
selected_index: usize, selected_index: usize,
telemetry: Arc<Telemetry>,
fs: Arc<dyn Fs>, fs: Arc<dyn Fs>,
} }
@ -78,7 +75,6 @@ impl BaseKeymapSelectorDelegate {
fn new( fn new(
weak_view: WeakView<BaseKeymapSelector>, weak_view: WeakView<BaseKeymapSelector>,
fs: Arc<dyn Fs>, fs: Arc<dyn Fs>,
telemetry: Arc<Telemetry>,
cx: &mut ViewContext<BaseKeymapSelector>, cx: &mut ViewContext<BaseKeymapSelector>,
) -> Self { ) -> Self {
let base = BaseKeymap::get(None, cx); let base = BaseKeymap::get(None, cx);
@ -90,7 +86,6 @@ impl BaseKeymapSelectorDelegate {
view: weak_view, view: weak_view,
matches: Vec::new(), matches: Vec::new(),
selected_index, selected_index,
telemetry,
fs, fs,
} }
} }
@ -169,8 +164,11 @@ impl PickerDelegate for BaseKeymapSelectorDelegate {
if let Some(selection) = self.matches.get(self.selected_index) { if let Some(selection) = self.matches.get(self.selected_index) {
let base_keymap = BaseKeymap::from_names(&selection.string); let base_keymap = BaseKeymap::from_names(&selection.string);
self.telemetry telemetry::event!(
.report_setting_event("keymap", base_keymap.to_string()); "Settings Changed",
setting = "keymap",
value = base_keymap.to_string()
);
update_settings_file::<BaseKeymap>(self.fs.clone(), cx, move |setting, _| { update_settings_file::<BaseKeymap>(self.fs.clone(), cx, move |setting, _| {
*setting = Some(base_keymap) *setting = Some(base_keymap)

View file

@ -307,15 +307,10 @@ impl Render for WelcomePage {
"welcome page: toggle diagnostic telemetry".to_string(), "welcome page: toggle diagnostic telemetry".to_string(),
); );
this.update_settings::<TelemetrySettings>(selection, cx, { this.update_settings::<TelemetrySettings>(selection, cx, {
let telemetry = this.telemetry.clone();
move |settings, value| { move |settings, value| {
settings.diagnostics = Some(value); settings.diagnostics = Some(value);
telemetry.report_setting_event( telemetry::event!("Settings Changed", setting = "diagnostic telemetry", value);
"diagnostic telemetry",
value.to_string(),
);
} }
}); });
}), }),
@ -333,15 +328,9 @@ impl Render for WelcomePage {
"welcome page: toggle metric telemetry".to_string(), "welcome page: toggle metric telemetry".to_string(),
); );
this.update_settings::<TelemetrySettings>(selection, cx, { this.update_settings::<TelemetrySettings>(selection, cx, {
let telemetry = this.telemetry.clone();
move |settings, value| { move |settings, value| {
settings.metrics = Some(value); settings.metrics = Some(value);
telemetry::event!("Settings Changed", setting = "metric telemetry", value);
telemetry.report_setting_event(
"metric telemetry",
value.to_string(),
);
} }
}); });
}), }),

View file

@ -109,6 +109,7 @@ sysinfo.workspace = true
tab_switcher.workspace = true tab_switcher.workspace = true
task.workspace = true task.workspace = true
tasks_ui.workspace = true tasks_ui.workspace = true
telemetry.workspace = true
telemetry_events.workspace = true telemetry_events.workspace = true
terminal_view.workspace = true terminal_view.workspace = true
theme.workspace = true theme.workspace = true

View file

@ -493,9 +493,16 @@ fn main() {
} }
}) })
.detach(); .detach();
let telemetry = app_state.client.telemetry(); telemetry::event!(
telemetry.report_setting_event("theme", cx.theme().name.to_string()); "Settings Changed",
telemetry.report_setting_event("keymap", BaseKeymap::get_global(cx).to_string()); setting = "theme",
value = cx.theme().name.to_string()
);
telemetry::event!(
"Settings Changed",
setting = "keymap",
value = BaseKeymap::get_global(cx).to_string()
);
telemetry.flush_events(); telemetry.flush_events();
let fs = app_state.fs.clone(); let fs = app_state.fs.clone();

View file

@ -35,6 +35,7 @@ rpc.workspace = true
serde_json.workspace = true serde_json.workspace = true
settings.workspace = true settings.workspace = true
similar.workspace = true similar.workspace = true
telemetry.workspace = true
telemetry_events.workspace = true telemetry_events.workspace = true
theme.workspace = true theme.workspace = true
ui.workspace = true ui.workspace = true

View file

@ -688,16 +688,14 @@ and then another
feedback: String, feedback: String,
cx: &mut ModelContext<Self>, cx: &mut ModelContext<Self>,
) { ) {
self.rated_completions.insert(completion.id); telemetry::event!(
self.client "Inline Completion Rated",
.telemetry() rating,
.report_inline_completion_rating_event( input_events = completion.input_events,
rating, input_excerpt = completion.input_excerpt,
completion.input_events.clone(), output_excerpt = completion.output_excerpt,
completion.input_excerpt.clone(), feedback
completion.output_excerpt.clone(), );
feedback,
);
self.client.telemetry().flush_events(); self.client.telemetry().flush_events();
cx.notify(); cx.notify();
} }

View file

@ -3,7 +3,7 @@ index 9ba10e56ba..bb69440691 100644
--- a/crates/call/Cargo.toml --- a/crates/call/Cargo.toml
+++ b/crates/call/Cargo.toml +++ b/crates/call/Cargo.toml
@@ -41,10 +41,10 @@ serde_derive.workspace = true @@ -41,10 +41,10 @@ serde_derive.workspace = true
settings.workspace = true telemetry.workspace = true
util.workspace = true util.workspace = true
-[target.'cfg(target_os = "macos")'.dependencies] -[target.'cfg(target_os = "macos")'.dependencies]