Detailed changes
@@ -2115,6 +2115,7 @@ dependencies = [
"serde",
"serde_derive",
"settings",
+ "telemetry",
"util",
]
@@ -2782,6 +2783,7 @@ dependencies = [
"settings",
"smallvec",
"story",
+ "telemetry",
"theme",
"time",
"time_format",
@@ -12875,7 +12877,6 @@ dependencies = [
name = "theme_selector"
version = "0.1.0"
dependencies = [
- "client",
"fs",
"fuzzy",
"gpui",
@@ -12883,6 +12884,7 @@ dependencies = [
"picker",
"serde",
"settings",
+ "telemetry",
"theme",
"ui",
"util",
@@ -13112,6 +13114,7 @@ dependencies = [
"settings",
"smallvec",
"story",
+ "telemetry",
"theme",
"tree-sitter-md",
"ui",
@@ -14890,6 +14893,7 @@ dependencies = [
"schemars",
"serde",
"settings",
+ "telemetry",
"ui",
"util",
"vim_mode_setting",
@@ -16093,6 +16097,7 @@ dependencies = [
"tab_switcher",
"task",
"tasks_ui",
+ "telemetry",
"telemetry_events",
"terminal_view",
"theme",
@@ -16465,6 +16470,7 @@ dependencies = [
"serde_json",
"settings",
"similar",
+ "telemetry",
"telemetry_events",
"theme",
"tree-sitter-go",
@@ -40,6 +40,7 @@ schemars.workspace = true
serde.workspace = true
serde_derive.workspace = true
settings.workspace = true
+telemetry.workspace = true
util.workspace = true
[target.'cfg(target_os = "macos")'.dependencies]
@@ -250,7 +250,9 @@ impl ActiveCall {
cx.spawn(move |this, mut cx| async move {
let result = invite.await;
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 {
//TODO: report collaboration error
log::error!("invite failed: {:?}", result);
@@ -318,7 +320,7 @@ impl ActiveCall {
this.update(&mut cx, |this, cx| this.set_room(room.clone(), cx))?
.await?;
this.update(&mut cx, |this, cx| {
- this.report_call_event("accept incoming", cx)
+ this.report_call_event("Incoming Call Accepted", cx)
})?;
Ok(())
})
@@ -331,7 +333,7 @@ impl ActiveCall {
.borrow_mut()
.take()
.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 {
room_id: call.room_id,
})?;
@@ -366,7 +368,7 @@ impl ActiveCall {
this.update(&mut cx, |this, cx| this.set_room(room.clone(), cx))?
.await?;
this.update(&mut cx, |this, cx| {
- this.report_call_event("join channel", cx)
+ this.report_call_event("Channel Joined", cx)
})?;
Ok(room)
})
@@ -374,7 +376,7 @@ impl ActiveCall {
pub fn hang_up(&mut self, cx: &mut ModelContext<Self>) -> Task<Result<()>> {
cx.notify();
- self.report_call_event("hang up", cx);
+ self.report_call_event("Call Ended", cx);
Audio::end_call(cx);
@@ -393,7 +395,7 @@ impl ActiveCall {
cx: &mut ModelContext<Self>,
) -> Task<Result<u64>> {
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))
} else {
Task::ready(Err(anyhow!("no active call")))
@@ -406,7 +408,7 @@ impl ActiveCall {
cx: &mut ModelContext<Self>,
) -> Result<()> {
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))
} else {
Err(anyhow!("no active call"))
@@ -486,35 +488,15 @@ impl ActiveCall {
pub fn report_call_event(&self, operation: &'static str, cx: &mut AppContext) {
if let Some(room) = self.room() {
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)]
mod test {
use gpui::TestAppContext;
@@ -243,7 +243,9 @@ impl ActiveCall {
cx.spawn(move |this, mut cx| async move {
let result = invite.await;
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 {
//TODO: report collaboration error
log::error!("invite failed: {:?}", result);
@@ -311,7 +313,7 @@ impl ActiveCall {
this.update(&mut cx, |this, cx| this.set_room(room.clone(), cx))?
.await?;
this.update(&mut cx, |this, cx| {
- this.report_call_event("accept incoming", cx)
+ this.report_call_event("Incoming Call Accepted", cx)
})?;
Ok(())
})
@@ -324,7 +326,7 @@ impl ActiveCall {
.borrow_mut()
.take()
.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 {
room_id: call.room_id,
})?;
@@ -359,7 +361,7 @@ impl ActiveCall {
this.update(&mut cx, |this, cx| this.set_room(room.clone(), cx))?
.await?;
this.update(&mut cx, |this, cx| {
- this.report_call_event("join channel", cx)
+ this.report_call_event("Channel Joined", cx)
})?;
Ok(room)
})
@@ -367,7 +369,7 @@ impl ActiveCall {
pub fn hang_up(&mut self, cx: &mut ModelContext<Self>) -> Task<Result<()>> {
cx.notify();
- self.report_call_event("hang up", cx);
+ self.report_call_event("Call Ended", cx);
Audio::end_call(cx);
@@ -386,7 +388,7 @@ impl ActiveCall {
cx: &mut ModelContext<Self>,
) -> Task<Result<u64>> {
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))
} else {
Task::ready(Err(anyhow!("no active call")))
@@ -399,7 +401,7 @@ impl ActiveCall {
cx: &mut ModelContext<Self>,
) -> Result<()> {
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))
} else {
Err(anyhow!("no active call"))
@@ -479,35 +481,15 @@ impl ActiveCall {
pub fn report_call_event(&self, operation: &'static str, cx: &mut AppContext) {
if let Some(room) = self.room() {
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)]
mod test {
use gpui::TestAppContext;
@@ -19,7 +19,7 @@ use std::time::Instant;
use std::{env, mem, path::PathBuf, sync::Arc, time::Duration};
use telemetry_events::{
AppEvent, AssistantEvent, CallEvent, EditEvent, Event, EventRequestBody, EventWrapper,
- InlineCompletionEvent, InlineCompletionRating, InlineCompletionRatingEvent, SettingEvent,
+ InlineCompletionEvent,
};
use util::{ResultExt, TryFutureExt};
use worktree::{UpdatedEntriesSet, WorktreeId};
@@ -349,24 +349,6 @@ impl Telemetry {
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) {
self.report_event(Event::Assistant(event));
}
@@ -394,15 +376,6 @@ impl Telemetry {
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) {
let mut state = self.state.lock();
let period_data = state.event_coalescer.log_event(environment);
@@ -16,7 +16,9 @@ use util::TryFutureExt as _;
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);
impl std::fmt::Display for ChannelId {
@@ -56,6 +56,7 @@ serde_json.workspace = true
settings.workspace = true
smallvec.workspace = true
story = { workspace = true, optional = true }
+telemetry.workspace = true
theme.workspace = true
time.workspace = true
time_format.workspace = true
@@ -1,5 +1,5 @@
use anyhow::Result;
-use call::report_call_event_for_channel;
+use call::ActiveCall;
use channel::{Channel, ChannelBuffer, ChannelBufferEvent, ChannelStore};
use client::{
proto::{self, PeerId},
@@ -66,11 +66,13 @@ impl ChannelView {
cx.spawn(|mut cx| async move {
let channel_view = channel_view.await?;
pane.update(&mut cx, |pane, cx| {
- report_call_event_for_channel(
- "open channel notes",
+ telemetry::event!(
+ "Channel Notes Opened",
channel_id,
- &workspace.read(cx).app_state().client,
- cx,
+ room_id = ActiveCall::global(cx)
+ .read(cx)
+ .room()
+ .map(|r| r.read(cx).id())
);
pane.add_item(Box::new(channel_view.clone()), true, true, None, cx);
})?;
@@ -13,7 +13,6 @@ path = "src/theme_selector.rs"
doctest = false
[dependencies]
-client.workspace = true
fs.workspace = true
fuzzy.workspace = true
gpui.workspace = true
@@ -21,6 +20,7 @@ log.workspace = true
picker.workspace = true
serde.workspace = true
settings.workspace = true
+telemetry.workspace = true
theme.workspace = true
ui.workspace = true
util.workspace = true
@@ -1,4 +1,3 @@
-use client::telemetry::Telemetry;
use fs::Fs;
use fuzzy::{match_strings, StringMatch, StringMatchCandidate};
use gpui::{
@@ -27,12 +26,10 @@ pub fn init(cx: &mut AppContext) {
pub fn toggle(workspace: &mut Workspace, toggle: &Toggle, cx: &mut ViewContext<Workspace>) {
let fs = workspace.app_state().fs.clone();
- let telemetry = workspace.client().telemetry().clone();
workspace.toggle_modal(cx, |cx| {
let delegate = ThemeSelectorDelegate::new(
cx.view().downgrade(),
fs,
- telemetry,
toggle.themes_filter.as_ref(),
cx,
);
@@ -74,7 +71,6 @@ pub struct ThemeSelectorDelegate {
original_theme: Arc<Theme>,
selection_completed: bool,
selected_index: usize,
- telemetry: Arc<Telemetry>,
view: WeakView<ThemeSelector>,
}
@@ -82,7 +78,6 @@ impl ThemeSelectorDelegate {
fn new(
weak_view: WeakView<ThemeSelector>,
fs: Arc<dyn Fs>,
- telemetry: Arc<Telemetry>,
themes_filter: Option<&Vec<String>>,
cx: &mut ViewContext<ThemeSelector>,
) -> Self {
@@ -123,7 +118,6 @@ impl ThemeSelectorDelegate {
original_theme: original_theme.clone(),
selected_index: 0,
selection_completed: false,
- telemetry,
view: weak_view,
};
@@ -180,8 +174,7 @@ impl PickerDelegate for ThemeSelectorDelegate {
let theme_name = cx.theme().name.clone();
- self.telemetry
- .report_setting_event("theme", theme_name.to_string());
+ telemetry::event!("Settings Changed", setting = "theme", value = theme_name);
let appearance = Appearance::from(cx.appearance());
@@ -43,6 +43,7 @@ story = { workspace = true, optional = true }
theme.workspace = true
ui.workspace = true
util.workspace = true
+telemetry.workspace = true
workspace.workspace = true
zed_actions.workspace = true
@@ -1,6 +1,6 @@
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 gpui::{actions, AppContext, Task, WindowContext};
use gpui::{canvas, point, AnyElement, Hsla, IntoElement, MouseButton, Path, Styled};
@@ -19,22 +19,19 @@ actions!(
fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut WindowContext) {
let call = ActiveCall::global(cx).read(cx);
if let Some(room) = call.room().cloned() {
- let client = call.client();
let toggle_screen_sharing = room.update(cx, |room, cx| {
if room.is_screen_sharing() {
- report_call_event_for_room(
- "disable screen share",
- room.id(),
- room.channel_id(),
- &client,
+ telemetry::event!(
+ "Screen Share Disabled",
+ room_id = room.id(),
+ channel_id = room.channel_id(),
);
Task::ready(room.unshare_screen(cx))
} else {
- report_call_event_for_room(
- "enable screen share",
- room.id(),
- room.channel_id(),
- &client,
+ telemetry::event!(
+ "Screen Share Enabled",
+ room_id = room.id(),
+ channel_id = room.channel_id(),
);
room.share_screen(cx)
}
@@ -46,14 +43,17 @@ fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut WindowContext) {
fn toggle_mute(_: &ToggleMute, cx: &mut AppContext) {
let call = ActiveCall::global(cx).read(cx);
if let Some(room) = call.room().cloned() {
- let client = call.client();
room.update(cx, |room, cx| {
let operation = if room.is_muted() {
- "enable microphone"
+ "Microphone Enabled"
} 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)
});
@@ -28,6 +28,7 @@ schemars.workspace = true
serde.workspace = true
settings.workspace = true
ui.workspace = true
+telemetry.workspace = true
util.workspace = true
vim_mode_setting.workspace = true
workspace.workspace = true
@@ -1,5 +1,4 @@
use super::base_keymap_setting::BaseKeymap;
-use client::telemetry::Telemetry;
use fuzzy::{match_strings, StringMatch, StringMatchCandidate};
use gpui::{
actions, AppContext, DismissEvent, EventEmitter, FocusableView, Render, Task, View,
@@ -28,10 +27,9 @@ pub fn toggle(
cx: &mut ViewContext<Workspace>,
) {
let fs = workspace.app_state().fs.clone();
- let telemetry = workspace.client().telemetry().clone();
workspace.toggle_modal(cx, |cx| {
BaseKeymapSelector::new(
- BaseKeymapSelectorDelegate::new(cx.view().downgrade(), fs, telemetry, cx),
+ BaseKeymapSelectorDelegate::new(cx.view().downgrade(), fs, cx),
cx,
)
});
@@ -70,7 +68,6 @@ pub struct BaseKeymapSelectorDelegate {
view: WeakView<BaseKeymapSelector>,
matches: Vec<StringMatch>,
selected_index: usize,
- telemetry: Arc<Telemetry>,
fs: Arc<dyn Fs>,
}
@@ -78,7 +75,6 @@ impl BaseKeymapSelectorDelegate {
fn new(
weak_view: WeakView<BaseKeymapSelector>,
fs: Arc<dyn Fs>,
- telemetry: Arc<Telemetry>,
cx: &mut ViewContext<BaseKeymapSelector>,
) -> Self {
let base = BaseKeymap::get(None, cx);
@@ -90,7 +86,6 @@ impl BaseKeymapSelectorDelegate {
view: weak_view,
matches: Vec::new(),
selected_index,
- telemetry,
fs,
}
}
@@ -169,8 +164,11 @@ impl PickerDelegate for BaseKeymapSelectorDelegate {
if let Some(selection) = self.matches.get(self.selected_index) {
let base_keymap = BaseKeymap::from_names(&selection.string);
- self.telemetry
- .report_setting_event("keymap", base_keymap.to_string());
+ telemetry::event!(
+ "Settings Changed",
+ setting = "keymap",
+ value = base_keymap.to_string()
+ );
update_settings_file::<BaseKeymap>(self.fs.clone(), cx, move |setting, _| {
*setting = Some(base_keymap)
@@ -307,15 +307,10 @@ impl Render for WelcomePage {
"welcome page: toggle diagnostic telemetry".to_string(),
);
this.update_settings::<TelemetrySettings>(selection, cx, {
- let telemetry = this.telemetry.clone();
-
move |settings, value| {
settings.diagnostics = Some(value);
- telemetry.report_setting_event(
- "diagnostic telemetry",
- value.to_string(),
- );
+ telemetry::event!("Settings Changed", setting = "diagnostic telemetry", value);
}
});
}),
@@ -333,15 +328,9 @@ impl Render for WelcomePage {
"welcome page: toggle metric telemetry".to_string(),
);
this.update_settings::<TelemetrySettings>(selection, cx, {
- let telemetry = this.telemetry.clone();
-
move |settings, value| {
settings.metrics = Some(value);
-
- telemetry.report_setting_event(
- "metric telemetry",
- value.to_string(),
- );
+ telemetry::event!("Settings Changed", setting = "metric telemetry", value);
}
});
}),
@@ -109,6 +109,7 @@ sysinfo.workspace = true
tab_switcher.workspace = true
task.workspace = true
tasks_ui.workspace = true
+telemetry.workspace = true
telemetry_events.workspace = true
terminal_view.workspace = true
theme.workspace = true
@@ -493,9 +493,16 @@ fn main() {
}
})
.detach();
- let telemetry = app_state.client.telemetry();
- telemetry.report_setting_event("theme", cx.theme().name.to_string());
- telemetry.report_setting_event("keymap", BaseKeymap::get_global(cx).to_string());
+ telemetry::event!(
+ "Settings Changed",
+ setting = "theme",
+ value = cx.theme().name.to_string()
+ );
+ telemetry::event!(
+ "Settings Changed",
+ setting = "keymap",
+ value = BaseKeymap::get_global(cx).to_string()
+ );
telemetry.flush_events();
let fs = app_state.fs.clone();
@@ -35,6 +35,7 @@ rpc.workspace = true
serde_json.workspace = true
settings.workspace = true
similar.workspace = true
+telemetry.workspace = true
telemetry_events.workspace = true
theme.workspace = true
ui.workspace = true
@@ -688,16 +688,14 @@ and then another
feedback: String,
cx: &mut ModelContext<Self>,
) {
- self.rated_completions.insert(completion.id);
- self.client
- .telemetry()
- .report_inline_completion_rating_event(
- rating,
- completion.input_events.clone(),
- completion.input_excerpt.clone(),
- completion.output_excerpt.clone(),
- feedback,
- );
+ telemetry::event!(
+ "Inline Completion Rated",
+ rating,
+ input_events = completion.input_events,
+ input_excerpt = completion.input_excerpt,
+ output_excerpt = completion.output_excerpt,
+ feedback
+ );
self.client.telemetry().flush_events();
cx.notify();
}
@@ -3,7 +3,7 @@ index 9ba10e56ba..bb69440691 100644
--- a/crates/call/Cargo.toml
+++ b/crates/call/Cargo.toml
@@ -41,10 +41,10 @@ serde_derive.workspace = true
- settings.workspace = true
+ telemetry.workspace = true
util.workspace = true
-[target.'cfg(target_os = "macos")'.dependencies]