Add architecture to clickhouse event request body

This commit is contained in:
Joseph Lyons 2023-05-22 21:45:58 -04:00
parent 54c04a6618
commit 049b72e3ac

View File

@ -10,6 +10,7 @@ use parking_lot::Mutex;
use serde::Serialize; use serde::Serialize;
use serde_json::json; use serde_json::json;
use std::{ use std::{
env,
io::Write, io::Write,
mem, mem,
path::PathBuf, path::PathBuf,
@ -33,8 +34,9 @@ struct TelemetryState {
installation_id: Option<Arc<str>>, // Per app installation installation_id: Option<Arc<str>>, // Per app installation
app_version: Option<Arc<str>>, app_version: Option<Arc<str>>,
release_channel: Option<&'static str>, release_channel: Option<&'static str>,
os_version: Option<Arc<str>>,
os_name: &'static str, os_name: &'static str,
os_version: Option<Arc<str>>,
architecture: &'static str,
mixpanel_events_queue: Vec<MixpanelEvent>, mixpanel_events_queue: Vec<MixpanelEvent>,
clickhouse_events_queue: Vec<ClickhouseEventWrapper>, clickhouse_events_queue: Vec<ClickhouseEventWrapper>,
next_mixpanel_event_id: usize, next_mixpanel_event_id: usize,
@ -63,6 +65,7 @@ struct ClickhouseEventRequestBody {
app_version: Option<Arc<str>>, app_version: Option<Arc<str>>,
os_name: &'static str, os_name: &'static str,
os_version: Option<Arc<str>>, os_version: Option<Arc<str>>,
architecture: &'static str,
release_channel: Option<&'static str>, release_channel: Option<&'static str>,
events: Vec<ClickhouseEventWrapper>, events: Vec<ClickhouseEventWrapper>,
} }
@ -153,12 +156,14 @@ impl Telemetry {
} else { } else {
None None
}; };
// TODO: Replace all hardware stuff with nested SystemSpecs json
let this = Arc::new(Self { let this = Arc::new(Self {
http_client: client, http_client: client,
executor: cx.background().clone(), executor: cx.background().clone(),
state: Mutex::new(TelemetryState { state: Mutex::new(TelemetryState {
os_version: platform.os_version().ok().map(|v| v.to_string().into()),
os_name: platform.os_name().into(), os_name: platform.os_name().into(),
os_version: platform.os_version().ok().map(|v| v.to_string().into()),
architecture: env::consts::ARCH,
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, release_channel,
installation_id: None, installation_id: None,
@ -451,6 +456,8 @@ impl Telemetry {
app_version: state.app_version.clone(), app_version: state.app_version.clone(),
os_name: state.os_name, os_name: state.os_name,
os_version: state.os_version.clone(), os_version: state.os_version.clone(),
architecture: state.architecture,
release_channel: state.release_channel, release_channel: state.release_channel,
events, events,
}, },