Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
onboarding: Add telemetry to Basics page (#37502)
Anthony Eid9eeeda1330e8
diff --git a/crates/onboarding/src/basics_page.rs b/crates/onboarding/src/basics_page.rsindex 991386cb389..d98db03be8a 100644--- a/crates/onboarding/src/basics_page.rs+++ b/crates/onboarding/src/basics_page.rs@@ -68,6 +68,12 @@ fn render_theme_section(tab_index: &mut isize, cx: &mut App) -> impl IntoElementMODE_NAMES[mode as usize].clone(),move |_, _, cx| {write_mode_change(mode, cx);++ telemetry::event!(+ "Welcome Theme mode Changed",+ from = theme_mode,+ to = mode+ );},)}),@@ -105,7 +111,7 @@ fn render_theme_section(tab_index: &mut isize, cx: &mut App) -> impl IntoElementThemeMode::Dark => Appearance::Dark,ThemeMode::System => *system_appearance,};- let current_theme_name = theme_selection.theme(appearance);+ let current_theme_name = SharedString::new(theme_selection.theme(appearance));let theme_names = match appearance {Appearance::Light => LIGHT_THEMES,@@ -149,8 +155,15 @@ fn render_theme_section(tab_index: &mut isize, cx: &mut App) -> impl IntoElement}).on_click({let theme_name = theme.name.clone();+ let current_theme_name = current_theme_name.clone();+move |_, _, cx| {write_theme_change(theme_name.clone(), theme_mode, cx);+ telemetry::event!(+ "Welcome Theme Changed",+ from = current_theme_name,+ to = theme_name+ );}}).map(|this| {@@ -239,6 +252,17 @@ fn render_telemetry_section(tab_index: &mut isize, cx: &App) -> impl IntoElementcx,move |setting, _| setting.metrics = Some(enabled),);++ // This telemetry event shouldn't fire when it's off. If it does we're be alerted+ // and can fix it in a timely manner to respect a user's choice.+ telemetry::event!("Welcome Page Telemetry Metrics Toggled",+ options = if enabled {+ "on"+ } else {+ "off"+ }+ );+}},).tab_index({*tab_index += 1;@@ -267,6 +291,16 @@ fn render_telemetry_section(tab_index: &mut isize, cx: &App) -> impl IntoElementcx,move |setting, _| setting.diagnostics = Some(enabled),);++ // This telemetry event shouldn't fire when it's off. If it does we're be alerted+ // and can fix it in a timely manner to respect a user's choice.+ telemetry::event!("Welcome Page Telemetry Diagnostics Toggled",+ options = if enabled {+ "on"+ } else {+ "off"+ }+ );}}).tab_index({@@ -327,6 +361,8 @@ fn render_base_keymap_section(tab_index: &mut isize, cx: &mut App) -> impl IntoEupdate_settings_file::<BaseKeymap>(fs, cx, move |setting, _| {setting.base_keymap = Some(keymap_base);});++ telemetry::event!("Welcome Keymap Changed", keymap = keymap_base);}}@@ -344,13 +380,21 @@ fn render_vim_mode_switch(tab_index: &mut isize, cx: &mut App) -> impl IntoEleme{let fs = <dyn Fs>::global(cx);move |&selection, _, cx| {- update_settings_file::<VimModeSetting>(fs.clone(), cx, move |setting, _| {- *setting = match selection {- ToggleState::Selected => Some(true),- ToggleState::Unselected => Some(false),- ToggleState::Indeterminate => None,+ let vim_mode = match selection {+ ToggleState::Selected => true,+ ToggleState::Unselected => false,+ ToggleState::Indeterminate => {+ return;}+ };+ update_settings_file::<VimModeSetting>(fs.clone(), cx, move |setting, _| {+ *setting = Some(vim_mode);});++ telemetry::event!(+ "Welcome Vim Mode Toggled",+ options = if vim_mode { "on" } else { "off" },+ );}},)diff --git a/crates/onboarding/src/onboarding.rs b/crates/onboarding/src/onboarding.rsindex 873dd632014..7f1bb81d4d7 100644--- a/crates/onboarding/src/onboarding.rs+++ b/crates/onboarding/src/onboarding.rs@@ -476,6 +476,7 @@ impl Onboarding {.map(|kb| kb.size(rems_from_px(12.))),).on_click(|_, window, cx| {+ telemetry::event!("Welcome Sign In Clicked");window.dispatch_action(SignIn.boxed_clone(), cx);}).into_any_element()diff --git a/crates/sum_tree/src/tree_map.rs b/crates/sum_tree/src/tree_map.rsindex fc93d40ae50..818214e4024 100644--- a/crates/sum_tree/src/tree_map.rs+++ b/crates/sum_tree/src/tree_map.rs@@ -2,7 +2,7 @@ use std::{cmp::Ordering, fmt::Debug};use crate::{Bias, Dimension, Edit, Item, KeyedItem, SeekTarget, SumTree, Summary};-/// A cheaply-clonable ordered map based on a [SumTree](crate::SumTree).+/// A cheaply-cloneable ordered map based on a [SumTree](crate::SumTree).#[derive(Clone, PartialEq, Eq)]pub struct TreeMap<K, V>(SumTree<MapEntry<K, V>>)where