Merge pull request #1829 from zed-industries/add-release-channel-information-to-telemetry-events
Add release channel information to telemetry events
This commit is contained in:
parent
8e7f711371
commit
bf4331e8cf
6 changed files with 32 additions and 15 deletions
|
@ -29,11 +29,7 @@ impl View for UpdateNotification {
|
||||||
let theme = cx.global::<Settings>().theme.clone();
|
let theme = cx.global::<Settings>().theme.clone();
|
||||||
let theme = &theme.update_notification;
|
let theme = &theme.update_notification;
|
||||||
|
|
||||||
let app_name = match *cx.global::<ReleaseChannel>() {
|
let app_name = cx.global::<ReleaseChannel>().name();
|
||||||
ReleaseChannel::Dev => "Zed Dev",
|
|
||||||
ReleaseChannel::Preview => "Zed Preview",
|
|
||||||
ReleaseChannel::Stable => "Zed",
|
|
||||||
};
|
|
||||||
|
|
||||||
MouseEventHandler::<ViewReleaseNotes>::new(0, cx, |state, cx| {
|
MouseEventHandler::<ViewReleaseNotes>::new(0, cx, |state, cx| {
|
||||||
Flex::column()
|
Flex::column()
|
||||||
|
|
|
@ -10,6 +10,7 @@ use lazy_static::lazy_static;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
use settings::ReleaseChannel;
|
||||||
use std::{
|
use std::{
|
||||||
io::Write,
|
io::Write,
|
||||||
mem,
|
mem,
|
||||||
|
@ -32,6 +33,7 @@ struct TelemetryState {
|
||||||
metrics_id: Option<Arc<str>>,
|
metrics_id: Option<Arc<str>>,
|
||||||
device_id: Option<Arc<str>>,
|
device_id: Option<Arc<str>>,
|
||||||
app_version: Option<Arc<str>>,
|
app_version: Option<Arc<str>>,
|
||||||
|
release_channel: Option<&'static str>,
|
||||||
os_version: Option<Arc<str>>,
|
os_version: Option<Arc<str>>,
|
||||||
os_name: &'static str,
|
os_name: &'static str,
|
||||||
queue: Vec<MixpanelEvent>,
|
queue: Vec<MixpanelEvent>,
|
||||||
|
@ -67,9 +69,15 @@ struct MixpanelEventProperties {
|
||||||
// Custom fields
|
// Custom fields
|
||||||
#[serde(skip_serializing_if = "Option::is_none", flatten)]
|
#[serde(skip_serializing_if = "Option::is_none", flatten)]
|
||||||
event_properties: Option<Map<String, Value>>,
|
event_properties: Option<Map<String, Value>>,
|
||||||
|
#[serde(rename = "OS Name")]
|
||||||
os_name: &'static str,
|
os_name: &'static str,
|
||||||
|
#[serde(rename = "OS Version")]
|
||||||
os_version: Option<Arc<str>>,
|
os_version: Option<Arc<str>>,
|
||||||
|
#[serde(rename = "Release Channel")]
|
||||||
|
release_channel: Option<&'static str>,
|
||||||
|
#[serde(rename = "App Version")]
|
||||||
app_version: Option<Arc<str>>,
|
app_version: Option<Arc<str>>,
|
||||||
|
#[serde(rename = "Signed In")]
|
||||||
signed_in: bool,
|
signed_in: bool,
|
||||||
platform: &'static str,
|
platform: &'static str,
|
||||||
}
|
}
|
||||||
|
@ -99,6 +107,11 @@ const DEBOUNCE_INTERVAL: Duration = Duration::from_secs(30);
|
||||||
impl Telemetry {
|
impl Telemetry {
|
||||||
pub fn new(client: Arc<dyn HttpClient>, cx: &AppContext) -> Arc<Self> {
|
pub fn new(client: Arc<dyn HttpClient>, cx: &AppContext) -> Arc<Self> {
|
||||||
let platform = cx.platform();
|
let platform = cx.platform();
|
||||||
|
let release_channel = if cx.has_global::<ReleaseChannel>() {
|
||||||
|
Some(cx.global::<ReleaseChannel>().name())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
let this = Arc::new(Self {
|
let this = Arc::new(Self {
|
||||||
http_client: client,
|
http_client: client,
|
||||||
executor: cx.background().clone(),
|
executor: cx.background().clone(),
|
||||||
|
@ -106,6 +119,7 @@ impl Telemetry {
|
||||||
os_version: platform.os_version().ok().map(|v| v.to_string().into()),
|
os_version: platform.os_version().ok().map(|v| v.to_string().into()),
|
||||||
os_name: platform.os_name().into(),
|
os_name: platform.os_name().into(),
|
||||||
app_version: platform.app_version().ok().map(|v| v.to_string().into()),
|
app_version: platform.app_version().ok().map(|v| v.to_string().into()),
|
||||||
|
release_channel,
|
||||||
device_id: None,
|
device_id: None,
|
||||||
metrics_id: None,
|
metrics_id: None,
|
||||||
queue: Default::default(),
|
queue: Default::default(),
|
||||||
|
@ -188,7 +202,7 @@ impl Telemetry {
|
||||||
let json_bytes = serde_json::to_vec(&[MixpanelEngageRequest {
|
let json_bytes = serde_json::to_vec(&[MixpanelEngageRequest {
|
||||||
token,
|
token,
|
||||||
distinct_id: device_id,
|
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)
|
let request = Request::post(MIXPANEL_ENGAGE_URL)
|
||||||
.header("Content-Type", "application/json")
|
.header("Content-Type", "application/json")
|
||||||
|
@ -221,6 +235,7 @@ impl Telemetry {
|
||||||
},
|
},
|
||||||
os_name: state.os_name,
|
os_name: state.os_name,
|
||||||
os_version: state.os_version.clone(),
|
os_version: state.os_version.clone(),
|
||||||
|
release_channel: state.release_channel,
|
||||||
app_version: state.app_version.clone(),
|
app_version: state.app_version.clone(),
|
||||||
signed_in: state.metrics_id.is_some(),
|
signed_in: state.metrics_id.is_some(),
|
||||||
platform: "Zed",
|
platform: "Zed",
|
||||||
|
|
|
@ -6396,7 +6396,7 @@ impl Editor {
|
||||||
project.read(cx).client().report_event(
|
project.read(cx).client().report_event(
|
||||||
name,
|
name,
|
||||||
json!({
|
json!({
|
||||||
"file_extension": file
|
"File Extension": file
|
||||||
.path()
|
.path()
|
||||||
.extension()
|
.extension()
|
||||||
.and_then(|e| e.to_str())
|
.and_then(|e| e.to_str())
|
||||||
|
|
|
@ -62,6 +62,16 @@ pub enum ReleaseChannel {
|
||||||
Stable,
|
Stable,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ReleaseChannel {
|
||||||
|
pub fn name(&self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
ReleaseChannel::Dev => "Zed Dev",
|
||||||
|
ReleaseChannel::Preview => "Zed Preview",
|
||||||
|
ReleaseChannel::Stable => "Zed",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl FeatureFlags {
|
impl FeatureFlags {
|
||||||
pub fn keymap_files(&self) -> Vec<&'static str> {
|
pub fn keymap_files(&self) -> Vec<&'static str> {
|
||||||
vec![]
|
vec![]
|
||||||
|
|
|
@ -90,6 +90,9 @@ fn main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
app.run(move |cx| {
|
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 client = client::Client::new(http.clone(), cx);
|
||||||
let mut languages = LanguageRegistry::new(login_shell_env_loaded);
|
let mut languages = LanguageRegistry::new(login_shell_env_loaded);
|
||||||
languages.set_language_server_download_dir(zed::paths::LANGUAGES_DIR.clone());
|
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();
|
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
|
//Setup settings global before binding actions
|
||||||
cx.set_global(SettingsFile::new(
|
cx.set_global(SettingsFile::new(
|
||||||
&*zed::paths::SETTINGS,
|
&*zed::paths::SETTINGS,
|
||||||
|
|
|
@ -389,11 +389,7 @@ fn quit(_: &Quit, cx: &mut gpui::MutableAppContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn about(_: &mut Workspace, _: &About, cx: &mut gpui::ViewContext<Workspace>) {
|
fn about(_: &mut Workspace, _: &About, cx: &mut gpui::ViewContext<Workspace>) {
|
||||||
let app_name = match *cx.global::<ReleaseChannel>() {
|
let app_name = cx.global::<ReleaseChannel>().name();
|
||||||
ReleaseChannel::Dev => "Zed Dev",
|
|
||||||
ReleaseChannel::Preview => "Zed Preview",
|
|
||||||
ReleaseChannel::Stable => "Zed",
|
|
||||||
};
|
|
||||||
let version = env!("CARGO_PKG_VERSION");
|
let version = env!("CARGO_PKG_VERSION");
|
||||||
cx.prompt(
|
cx.prompt(
|
||||||
gpui::PromptLevel::Info,
|
gpui::PromptLevel::Info,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue