Move telemetry settings check into telemetry module
This commit is contained in:
parent
c76fcb3ca5
commit
2972ee8ced
7 changed files with 41 additions and 77 deletions
|
@ -16,7 +16,7 @@ use ai::{
|
||||||
use ai::prompts::repository_context::PromptCodeSnippet;
|
use ai::prompts::repository_context::PromptCodeSnippet;
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use chrono::{DateTime, Local};
|
use chrono::{DateTime, Local};
|
||||||
use client::{telemetry::AssistantKind, TelemetrySettings};
|
use client::telemetry::AssistantKind;
|
||||||
use collections::{hash_map, HashMap, HashSet, VecDeque};
|
use collections::{hash_map, HashMap, HashSet, VecDeque};
|
||||||
use editor::{
|
use editor::{
|
||||||
display_map::{
|
display_map::{
|
||||||
|
@ -3527,12 +3527,5 @@ fn report_assistant_event(
|
||||||
.default_open_ai_model
|
.default_open_ai_model
|
||||||
.clone();
|
.clone();
|
||||||
|
|
||||||
let telemetry_settings = TelemetrySettings::get_global(cx).clone();
|
telemetry.report_assistant_event(conversation_id, assistant_kind, model.full_name(), cx)
|
||||||
|
|
||||||
telemetry.report_assistant_event(
|
|
||||||
telemetry_settings,
|
|
||||||
conversation_id,
|
|
||||||
assistant_kind,
|
|
||||||
model.full_name(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ pub mod room;
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use audio::Audio;
|
use audio::Audio;
|
||||||
use call_settings::CallSettings;
|
use call_settings::CallSettings;
|
||||||
use client::{proto, Client, TelemetrySettings, TypedEnvelope, User, UserStore, ZED_ALWAYS_ACTIVE};
|
use client::{proto, Client, TypedEnvelope, User, UserStore, ZED_ALWAYS_ACTIVE};
|
||||||
use collections::HashSet;
|
use collections::HashSet;
|
||||||
use futures::{channel::oneshot, future::Shared, Future, FutureExt};
|
use futures::{channel::oneshot, future::Shared, Future, FutureExt};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
|
@ -480,9 +480,8 @@ pub fn report_call_event_for_room(
|
||||||
cx: &mut AppContext,
|
cx: &mut AppContext,
|
||||||
) {
|
) {
|
||||||
let telemetry = client.telemetry();
|
let telemetry = client.telemetry();
|
||||||
let telemetry_settings = *TelemetrySettings::get_global(cx);
|
|
||||||
|
|
||||||
telemetry.report_call_event(telemetry_settings, operation, Some(room_id), channel_id)
|
telemetry.report_call_event(operation, Some(room_id), channel_id, cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn report_call_event_for_channel(
|
pub fn report_call_event_for_channel(
|
||||||
|
@ -495,13 +494,11 @@ pub fn report_call_event_for_channel(
|
||||||
|
|
||||||
let telemetry = client.telemetry();
|
let telemetry = client.telemetry();
|
||||||
|
|
||||||
let telemetry_settings = *TelemetrySettings::get_global(cx);
|
|
||||||
|
|
||||||
telemetry.report_call_event(
|
telemetry.report_call_event(
|
||||||
telemetry_settings,
|
|
||||||
operation,
|
operation,
|
||||||
room.map(|r| r.read(cx).id()),
|
room.map(|r| r.read(cx).id()),
|
||||||
Some(channel_id),
|
Some(channel_id),
|
||||||
|
cx,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -177,8 +177,7 @@ impl Telemetry {
|
||||||
// TestAppContext ends up calling this function on shutdown and it panics when trying to find the TelemetrySettings
|
// TestAppContext ends up calling this function on shutdown and it panics when trying to find the TelemetrySettings
|
||||||
#[cfg(not(any(test, feature = "test-support")))]
|
#[cfg(not(any(test, feature = "test-support")))]
|
||||||
fn shutdown_telemetry(self: &Arc<Self>, cx: &mut AppContext) -> impl Future<Output = ()> {
|
fn shutdown_telemetry(self: &Arc<Self>, cx: &mut AppContext) -> impl Future<Output = ()> {
|
||||||
let telemetry_settings = TelemetrySettings::get_global(cx).clone();
|
self.report_app_event("close", true, cx);
|
||||||
self.report_app_event(telemetry_settings, "close", true);
|
|
||||||
Task::ready(())
|
Task::ready(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,24 +226,11 @@ impl Telemetry {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let telemetry_settings = if let Ok(telemetry_settings) =
|
cx.update(|cx| {
|
||||||
cx.update(|cx| *TelemetrySettings::get_global(cx))
|
this.report_memory_event(process.memory(), process.virtual_memory(), cx);
|
||||||
{
|
this.report_cpu_event(process.cpu_usage(), system.cpus().len() as u32, cx);
|
||||||
telemetry_settings
|
})
|
||||||
} else {
|
.ok();
|
||||||
break;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.report_memory_event(
|
|
||||||
telemetry_settings,
|
|
||||||
process.memory(),
|
|
||||||
process.virtual_memory(),
|
|
||||||
);
|
|
||||||
this.report_cpu_event(
|
|
||||||
telemetry_settings,
|
|
||||||
process.cpu_usage(),
|
|
||||||
system.cpus().len() as u32,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
|
@ -269,12 +255,12 @@ impl Telemetry {
|
||||||
|
|
||||||
pub fn report_editor_event(
|
pub fn report_editor_event(
|
||||||
self: &Arc<Self>,
|
self: &Arc<Self>,
|
||||||
telemetry_settings: TelemetrySettings,
|
|
||||||
file_extension: Option<String>,
|
file_extension: Option<String>,
|
||||||
vim_mode: bool,
|
vim_mode: bool,
|
||||||
operation: &'static str,
|
operation: &'static str,
|
||||||
copilot_enabled: bool,
|
copilot_enabled: bool,
|
||||||
copilot_enabled_for_language: bool,
|
copilot_enabled_for_language: bool,
|
||||||
|
cx: &AppContext,
|
||||||
) {
|
) {
|
||||||
let event = ClickhouseEvent::Editor {
|
let event = ClickhouseEvent::Editor {
|
||||||
file_extension,
|
file_extension,
|
||||||
|
@ -285,15 +271,15 @@ impl Telemetry {
|
||||||
milliseconds_since_first_event: self.milliseconds_since_first_event(),
|
milliseconds_since_first_event: self.milliseconds_since_first_event(),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.report_clickhouse_event(event, telemetry_settings, false)
|
self.report_clickhouse_event(event, false, cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn report_copilot_event(
|
pub fn report_copilot_event(
|
||||||
self: &Arc<Self>,
|
self: &Arc<Self>,
|
||||||
telemetry_settings: TelemetrySettings,
|
|
||||||
suggestion_id: Option<String>,
|
suggestion_id: Option<String>,
|
||||||
suggestion_accepted: bool,
|
suggestion_accepted: bool,
|
||||||
file_extension: Option<String>,
|
file_extension: Option<String>,
|
||||||
|
cx: &AppContext,
|
||||||
) {
|
) {
|
||||||
let event = ClickhouseEvent::Copilot {
|
let event = ClickhouseEvent::Copilot {
|
||||||
suggestion_id,
|
suggestion_id,
|
||||||
|
@ -302,15 +288,15 @@ impl Telemetry {
|
||||||
milliseconds_since_first_event: self.milliseconds_since_first_event(),
|
milliseconds_since_first_event: self.milliseconds_since_first_event(),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.report_clickhouse_event(event, telemetry_settings, false)
|
self.report_clickhouse_event(event, false, cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn report_assistant_event(
|
pub fn report_assistant_event(
|
||||||
self: &Arc<Self>,
|
self: &Arc<Self>,
|
||||||
telemetry_settings: TelemetrySettings,
|
|
||||||
conversation_id: Option<String>,
|
conversation_id: Option<String>,
|
||||||
kind: AssistantKind,
|
kind: AssistantKind,
|
||||||
model: &'static str,
|
model: &'static str,
|
||||||
|
cx: &AppContext,
|
||||||
) {
|
) {
|
||||||
let event = ClickhouseEvent::Assistant {
|
let event = ClickhouseEvent::Assistant {
|
||||||
conversation_id,
|
conversation_id,
|
||||||
|
@ -319,15 +305,15 @@ impl Telemetry {
|
||||||
milliseconds_since_first_event: self.milliseconds_since_first_event(),
|
milliseconds_since_first_event: self.milliseconds_since_first_event(),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.report_clickhouse_event(event, telemetry_settings, false)
|
self.report_clickhouse_event(event, false, cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn report_call_event(
|
pub fn report_call_event(
|
||||||
self: &Arc<Self>,
|
self: &Arc<Self>,
|
||||||
telemetry_settings: TelemetrySettings,
|
|
||||||
operation: &'static str,
|
operation: &'static str,
|
||||||
room_id: Option<u64>,
|
room_id: Option<u64>,
|
||||||
channel_id: Option<u64>,
|
channel_id: Option<u64>,
|
||||||
|
cx: &AppContext,
|
||||||
) {
|
) {
|
||||||
let event = ClickhouseEvent::Call {
|
let event = ClickhouseEvent::Call {
|
||||||
operation,
|
operation,
|
||||||
|
@ -336,14 +322,14 @@ impl Telemetry {
|
||||||
milliseconds_since_first_event: self.milliseconds_since_first_event(),
|
milliseconds_since_first_event: self.milliseconds_since_first_event(),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.report_clickhouse_event(event, telemetry_settings, false)
|
self.report_clickhouse_event(event, false, cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn report_cpu_event(
|
pub fn report_cpu_event(
|
||||||
self: &Arc<Self>,
|
self: &Arc<Self>,
|
||||||
telemetry_settings: TelemetrySettings,
|
|
||||||
usage_as_percentage: f32,
|
usage_as_percentage: f32,
|
||||||
core_count: u32,
|
core_count: u32,
|
||||||
|
cx: &AppContext,
|
||||||
) {
|
) {
|
||||||
let event = ClickhouseEvent::Cpu {
|
let event = ClickhouseEvent::Cpu {
|
||||||
usage_as_percentage,
|
usage_as_percentage,
|
||||||
|
@ -351,14 +337,14 @@ impl Telemetry {
|
||||||
milliseconds_since_first_event: self.milliseconds_since_first_event(),
|
milliseconds_since_first_event: self.milliseconds_since_first_event(),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.report_clickhouse_event(event, telemetry_settings, false)
|
self.report_clickhouse_event(event, false, cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn report_memory_event(
|
pub fn report_memory_event(
|
||||||
self: &Arc<Self>,
|
self: &Arc<Self>,
|
||||||
telemetry_settings: TelemetrySettings,
|
|
||||||
memory_in_bytes: u64,
|
memory_in_bytes: u64,
|
||||||
virtual_memory_in_bytes: u64,
|
virtual_memory_in_bytes: u64,
|
||||||
|
cx: &AppContext,
|
||||||
) {
|
) {
|
||||||
let event = ClickhouseEvent::Memory {
|
let event = ClickhouseEvent::Memory {
|
||||||
memory_in_bytes,
|
memory_in_bytes,
|
||||||
|
@ -366,28 +352,28 @@ impl Telemetry {
|
||||||
milliseconds_since_first_event: self.milliseconds_since_first_event(),
|
milliseconds_since_first_event: self.milliseconds_since_first_event(),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.report_clickhouse_event(event, telemetry_settings, false)
|
self.report_clickhouse_event(event, false, cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn report_app_event(
|
pub fn report_app_event(
|
||||||
self: &Arc<Self>,
|
self: &Arc<Self>,
|
||||||
telemetry_settings: TelemetrySettings,
|
|
||||||
operation: &'static str,
|
operation: &'static str,
|
||||||
immediate_flush: bool,
|
immediate_flush: bool,
|
||||||
|
cx: &AppContext,
|
||||||
) {
|
) {
|
||||||
let event = ClickhouseEvent::App {
|
let event = ClickhouseEvent::App {
|
||||||
operation,
|
operation,
|
||||||
milliseconds_since_first_event: self.milliseconds_since_first_event(),
|
milliseconds_since_first_event: self.milliseconds_since_first_event(),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.report_clickhouse_event(event, telemetry_settings, immediate_flush)
|
self.report_clickhouse_event(event, immediate_flush, cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn report_setting_event(
|
pub fn report_setting_event(
|
||||||
self: &Arc<Self>,
|
self: &Arc<Self>,
|
||||||
telemetry_settings: TelemetrySettings,
|
|
||||||
setting: &'static str,
|
setting: &'static str,
|
||||||
value: String,
|
value: String,
|
||||||
|
cx: &AppContext,
|
||||||
) {
|
) {
|
||||||
let event = ClickhouseEvent::Setting {
|
let event = ClickhouseEvent::Setting {
|
||||||
setting,
|
setting,
|
||||||
|
@ -395,7 +381,7 @@ impl Telemetry {
|
||||||
milliseconds_since_first_event: self.milliseconds_since_first_event(),
|
milliseconds_since_first_event: self.milliseconds_since_first_event(),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.report_clickhouse_event(event, telemetry_settings, false)
|
self.report_clickhouse_event(event, false, cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn milliseconds_since_first_event(&self) -> i64 {
|
fn milliseconds_since_first_event(&self) -> i64 {
|
||||||
|
@ -415,10 +401,10 @@ impl Telemetry {
|
||||||
fn report_clickhouse_event(
|
fn report_clickhouse_event(
|
||||||
self: &Arc<Self>,
|
self: &Arc<Self>,
|
||||||
event: ClickhouseEvent,
|
event: ClickhouseEvent,
|
||||||
telemetry_settings: TelemetrySettings,
|
|
||||||
immediate_flush: bool,
|
immediate_flush: bool,
|
||||||
|
cx: &AppContext,
|
||||||
) {
|
) {
|
||||||
if !telemetry_settings.metrics {
|
if !TelemetrySettings::get_global(cx).metrics {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ use ::git::diff::DiffHunk;
|
||||||
use aho_corasick::AhoCorasick;
|
use aho_corasick::AhoCorasick;
|
||||||
use anyhow::{anyhow, Context as _, Result};
|
use anyhow::{anyhow, Context as _, Result};
|
||||||
use blink_manager::BlinkManager;
|
use blink_manager::BlinkManager;
|
||||||
use client::{Client, Collaborator, ParticipantIndex, TelemetrySettings};
|
use client::{Client, Collaborator, ParticipantIndex};
|
||||||
use clock::ReplicaId;
|
use clock::ReplicaId;
|
||||||
use collections::{BTreeMap, Bound, HashMap, HashSet, VecDeque};
|
use collections::{BTreeMap, Bound, HashMap, HashSet, VecDeque};
|
||||||
use convert_case::{Case, Casing};
|
use convert_case::{Case, Casing};
|
||||||
|
@ -8864,14 +8864,8 @@ impl Editor {
|
||||||
.map(|a| a.to_string());
|
.map(|a| a.to_string());
|
||||||
|
|
||||||
let telemetry = project.read(cx).client().telemetry().clone();
|
let telemetry = project.read(cx).client().telemetry().clone();
|
||||||
let telemetry_settings = *TelemetrySettings::get_global(cx);
|
|
||||||
|
|
||||||
telemetry.report_copilot_event(
|
telemetry.report_copilot_event(suggestion_id, suggestion_accepted, file_extension, cx)
|
||||||
telemetry_settings,
|
|
||||||
suggestion_id,
|
|
||||||
suggestion_accepted,
|
|
||||||
file_extension,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
|
@ -8909,7 +8903,6 @@ impl Editor {
|
||||||
.raw_user_settings()
|
.raw_user_settings()
|
||||||
.get("vim_mode")
|
.get("vim_mode")
|
||||||
== Some(&serde_json::Value::Bool(true));
|
== Some(&serde_json::Value::Bool(true));
|
||||||
let telemetry_settings = *TelemetrySettings::get_global(cx);
|
|
||||||
let copilot_enabled = all_language_settings(file, cx).copilot_enabled(None, None);
|
let copilot_enabled = all_language_settings(file, cx).copilot_enabled(None, None);
|
||||||
let copilot_enabled_for_language = self
|
let copilot_enabled_for_language = self
|
||||||
.buffer
|
.buffer
|
||||||
|
@ -8919,12 +8912,12 @@ impl Editor {
|
||||||
|
|
||||||
let telemetry = project.read(cx).client().telemetry().clone();
|
let telemetry = project.read(cx).client().telemetry().clone();
|
||||||
telemetry.report_editor_event(
|
telemetry.report_editor_event(
|
||||||
telemetry_settings,
|
|
||||||
file_extension,
|
file_extension,
|
||||||
vim_mode,
|
vim_mode,
|
||||||
operation,
|
operation,
|
||||||
copilot_enabled,
|
copilot_enabled,
|
||||||
copilot_enabled_for_language,
|
copilot_enabled_for_language,
|
||||||
|
cx,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use client::{telemetry::Telemetry, TelemetrySettings};
|
use client::telemetry::Telemetry;
|
||||||
use feature_flags::FeatureFlagAppExt;
|
use feature_flags::FeatureFlagAppExt;
|
||||||
use fs::Fs;
|
use fs::Fs;
|
||||||
use fuzzy::{match_strings, StringMatch, StringMatchCandidate};
|
use fuzzy::{match_strings, StringMatch, StringMatchCandidate};
|
||||||
|
@ -7,7 +7,7 @@ use gpui::{
|
||||||
VisualContext, WeakView,
|
VisualContext, WeakView,
|
||||||
};
|
};
|
||||||
use picker::{Picker, PickerDelegate};
|
use picker::{Picker, PickerDelegate};
|
||||||
use settings::{update_settings_file, Settings, SettingsStore};
|
use settings::{update_settings_file, SettingsStore};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use theme::{Theme, ThemeMeta, ThemeRegistry, ThemeSettings};
|
use theme::{Theme, ThemeMeta, ThemeRegistry, ThemeSettings};
|
||||||
use ui::{prelude::*, v_stack, ListItem, ListItemSpacing};
|
use ui::{prelude::*, v_stack, ListItem, ListItemSpacing};
|
||||||
|
@ -181,9 +181,8 @@ impl PickerDelegate for ThemeSelectorDelegate {
|
||||||
|
|
||||||
let theme_name = cx.theme().name.clone();
|
let theme_name = cx.theme().name.clone();
|
||||||
|
|
||||||
let telemetry_settings = TelemetrySettings::get_global(cx).clone();
|
|
||||||
self.telemetry
|
self.telemetry
|
||||||
.report_setting_event(telemetry_settings, "theme", theme_name.to_string());
|
.report_setting_event("theme", theme_name.to_string(), cx);
|
||||||
|
|
||||||
update_settings_file::<ThemeSettings>(self.fs.clone(), cx, move |settings| {
|
update_settings_file::<ThemeSettings>(self.fs.clone(), cx, move |settings| {
|
||||||
settings.theme = Some(theme_name.to_string());
|
settings.theme = Some(theme_name.to_string());
|
||||||
|
|
|
@ -15,7 +15,7 @@ use anyhow::{anyhow, Context as _, Result};
|
||||||
use call::ActiveCall;
|
use call::ActiveCall;
|
||||||
use client::{
|
use client::{
|
||||||
proto::{self, PeerId},
|
proto::{self, PeerId},
|
||||||
Client, Status, TelemetrySettings, TypedEnvelope, UserStore,
|
Client, Status, TypedEnvelope, UserStore,
|
||||||
};
|
};
|
||||||
use collections::{hash_map, HashMap, HashSet};
|
use collections::{hash_map, HashMap, HashSet};
|
||||||
use dock::{Dock, DockPosition, Panel, PanelButtons, PanelHandle};
|
use dock::{Dock, DockPosition, Panel, PanelButtons, PanelHandle};
|
||||||
|
@ -1250,10 +1250,9 @@ impl Workspace {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn open(&mut self, _: &Open, cx: &mut ViewContext<Self>) {
|
pub fn open(&mut self, _: &Open, cx: &mut ViewContext<Self>) {
|
||||||
let telemetry_settings = TelemetrySettings::get_global(cx).clone();
|
|
||||||
self.client()
|
self.client()
|
||||||
.telemetry()
|
.telemetry()
|
||||||
.report_app_event(telemetry_settings, "open project", false);
|
.report_app_event("open project", false, cx);
|
||||||
let paths = cx.prompt_for_paths(PathPromptOptions {
|
let paths = cx.prompt_for_paths(PathPromptOptions {
|
||||||
files: true,
|
files: true,
|
||||||
directories: true,
|
directories: true,
|
||||||
|
|
|
@ -172,19 +172,16 @@ fn main() {
|
||||||
.detach();
|
.detach();
|
||||||
|
|
||||||
client.telemetry().start(installation_id, session_id, cx);
|
client.telemetry().start(installation_id, session_id, cx);
|
||||||
let telemetry_settings = *client::TelemetrySettings::get_global(cx);
|
client
|
||||||
client.telemetry().report_setting_event(
|
.telemetry()
|
||||||
telemetry_settings,
|
.report_setting_event("theme", cx.theme().name.to_string(), cx);
|
||||||
"theme",
|
|
||||||
cx.theme().name.to_string(),
|
|
||||||
);
|
|
||||||
let event_operation = match existing_installation_id_found {
|
let event_operation = match existing_installation_id_found {
|
||||||
Some(false) => "first open",
|
Some(false) => "first open",
|
||||||
_ => "open",
|
_ => "open",
|
||||||
};
|
};
|
||||||
client
|
client
|
||||||
.telemetry()
|
.telemetry()
|
||||||
.report_app_event(telemetry_settings, event_operation, true);
|
.report_app_event(event_operation, true, cx);
|
||||||
|
|
||||||
let app_state = Arc::new(AppState {
|
let app_state = Arc::new(AppState {
|
||||||
languages: languages.clone(),
|
languages: languages.clone(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue