diff --git a/crates/auto_update/src/update_notification.rs b/crates/auto_update/src/update_notification.rs index 19faca24a071867746ce09a6d91d1df29adaad20..13e5f0517d5917aa474f17e431bc55579101db7d 100644 --- a/crates/auto_update/src/update_notification.rs +++ b/crates/auto_update/src/update_notification.rs @@ -29,11 +29,7 @@ impl View for UpdateNotification { let theme = cx.global::().theme.clone(); let theme = &theme.update_notification; - let app_name = match *cx.global::() { - ReleaseChannel::Dev => "Zed Dev", - ReleaseChannel::Preview => "Zed Preview", - ReleaseChannel::Stable => "Zed", - }; + let app_name = cx.global::().name(); MouseEventHandler::::new(0, cx, |state, cx| { Flex::column() diff --git a/crates/client/src/amplitude_telemetry.rs b/crates/client/src/amplitude_telemetry.rs index f463dbf078c3601124cc0c8d1a248c123df5617a..4883124d28a79fbefc0243b160766d7767634f61 100644 --- a/crates/client/src/amplitude_telemetry.rs +++ b/crates/client/src/amplitude_telemetry.rs @@ -10,6 +10,7 @@ use lazy_static::lazy_static; use parking_lot::Mutex; use serde::Serialize; use serde_json::json; +use settings::ReleaseChannel; use std::{ io::Write, mem, @@ -33,6 +34,7 @@ struct AmplitudeTelemetryState { metrics_id: Option>, device_id: Option>, app_version: Option>, + release_channel: Option<&'static str>, os_version: Option>, os_name: &'static str, queue: Vec, @@ -70,6 +72,7 @@ struct AmplitudeEvent { app_version: Option>, #[serde(rename = "App")] app: &'static str, + release_channel: Option<&'static str>, event_id: usize, session_id: u128, time: u128, @@ -90,6 +93,11 @@ const DEBOUNCE_INTERVAL: Duration = Duration::from_secs(30); impl AmplitudeTelemetry { pub fn new(client: Arc, cx: &AppContext) -> Arc { let platform = cx.platform(); + let release_channel = if cx.has_global::() { + Some(cx.global::().name()) + } else { + None + }; let this = Arc::new(Self { http_client: client, executor: cx.background().clone(), @@ -101,6 +109,7 @@ impl AmplitudeTelemetry { os_version: platform.os_version().ok().map(|v| v.to_string().into()), os_name: platform.os_name().into(), app_version: platform.app_version().ok().map(|v| v.to_string().into()), + release_channel, device_id: None, queue: Default::default(), flush_task: Default::default(), @@ -215,6 +224,7 @@ impl AmplitudeTelemetry { app: "Zed", os_version: state.os_version.clone(), app_version: state.app_version.clone(), + release_channel: state.release_channel, event_id: post_inc(&mut state.next_event_id), }; state.queue.push(event); diff --git a/crates/client/src/telemetry.rs b/crates/client/src/telemetry.rs index d95460a15f726db2598d17893323686645681b19..01adeccb50218d48d0dbb4836b6c15c41b12ba9a 100644 --- a/crates/client/src/telemetry.rs +++ b/crates/client/src/telemetry.rs @@ -10,6 +10,7 @@ use lazy_static::lazy_static; use parking_lot::Mutex; use serde::Serialize; use serde_json::json; +use settings::ReleaseChannel; use std::{ io::Write, mem, @@ -32,6 +33,7 @@ struct TelemetryState { metrics_id: Option>, device_id: Option>, app_version: Option>, + release_channel: Option<&'static str>, os_version: Option>, os_name: &'static str, queue: Vec, @@ -67,9 +69,15 @@ struct MixpanelEventProperties { // Custom fields #[serde(skip_serializing_if = "Option::is_none", flatten)] event_properties: Option>, + #[serde(rename = "OS Name")] os_name: &'static str, + #[serde(rename = "OS Version")] os_version: Option>, + #[serde(rename = "Release Channel")] + release_channel: Option<&'static str>, + #[serde(rename = "App Version")] app_version: Option>, + #[serde(rename = "Signed In")] signed_in: bool, #[serde(rename = "App")] app: &'static str, @@ -100,6 +108,11 @@ const DEBOUNCE_INTERVAL: Duration = Duration::from_secs(30); impl Telemetry { pub fn new(client: Arc, cx: &AppContext) -> Arc { let platform = cx.platform(); + let release_channel = if cx.has_global::() { + Some(cx.global::().name()) + } else { + None + }; let this = Arc::new(Self { http_client: client, executor: cx.background().clone(), @@ -107,6 +120,7 @@ impl Telemetry { os_version: platform.os_version().ok().map(|v| v.to_string().into()), os_name: platform.os_name().into(), app_version: platform.app_version().ok().map(|v| v.to_string().into()), + release_channel, device_id: None, metrics_id: None, queue: Default::default(), @@ -189,7 +203,7 @@ impl Telemetry { let json_bytes = serde_json::to_vec(&[MixpanelEngageRequest { token, distinct_id: device_id, - set: json!({ "staff": is_staff, "id": metrics_id }), + set: json!({ "Staff": is_staff, "ID": metrics_id }), }])?; let request = Request::post(MIXPANEL_ENGAGE_URL) .header("Content-Type", "application/json") @@ -222,6 +236,7 @@ impl Telemetry { }, os_name: state.os_name, os_version: state.os_version.clone(), + release_channel: state.release_channel, app_version: state.app_version.clone(), signed_in: state.metrics_id.is_some(), app: "Zed", diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index d1bd1622b42f6a6cbe9a83bd6b04b80cb43a7af4..12790df442467bb75c6b0938b8e1244643784bc7 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -6470,7 +6470,7 @@ impl Editor { project.read(cx).client().report_event( name, json!({ - "file_extension": file + "File Extension": file .path() .extension() .and_then(|e| e.to_str()) diff --git a/crates/settings/src/settings.rs b/crates/settings/src/settings.rs index bad35c3271c901e3580cb4dcbe2a556c29d8a0a2..e801e00757a7bfd4bb5ad2a1487f180cbaf80459 100644 --- a/crates/settings/src/settings.rs +++ b/crates/settings/src/settings.rs @@ -62,6 +62,16 @@ pub enum ReleaseChannel { Stable, } +impl ReleaseChannel { + pub fn name(&self) -> &'static str { + match self { + ReleaseChannel::Dev => "Zed Dev", + ReleaseChannel::Preview => "Zed Preview", + ReleaseChannel::Stable => "Zed", + } + } +} + impl FeatureFlags { pub fn keymap_files(&self) -> Vec<&'static str> { vec![] diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index c515d89a2800bab31353aa0d64abafd6cef769c7..74a38599ece2fc139328c893a2af1ec4927f5487 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -90,6 +90,9 @@ fn main() { }); app.run(move |cx| { + cx.set_global(*RELEASE_CHANNEL); + cx.set_global(HomeDir(zed::paths::HOME.to_path_buf())); + let client = client::Client::new(http.clone(), cx); let mut languages = LanguageRegistry::new(login_shell_env_loaded); languages.set_language_server_download_dir(zed::paths::LANGUAGES_DIR.clone()); @@ -101,9 +104,6 @@ fn main() { let (settings_file_content, keymap_file) = cx.background().block(config_files).unwrap(); - cx.set_global(*RELEASE_CHANNEL); - cx.set_global(HomeDir(zed::paths::HOME.to_path_buf())); - //Setup settings global before binding actions cx.set_global(SettingsFile::new( &*zed::paths::SETTINGS, diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 0d497afd529e8ed5f9bdf4f62da1b51c22ffe2e6..f54114891c929c86863893279022ac3318851112 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -389,11 +389,7 @@ fn quit(_: &Quit, cx: &mut gpui::MutableAppContext) { } fn about(_: &mut Workspace, _: &About, cx: &mut gpui::ViewContext) { - let app_name = match *cx.global::() { - ReleaseChannel::Dev => "Zed Dev", - ReleaseChannel::Preview => "Zed Preview", - ReleaseChannel::Stable => "Zed", - }; + let app_name = cx.global::().name(); let version = env!("CARGO_PKG_VERSION"); cx.prompt( gpui::PromptLevel::Info,