Make release_channel optional to fix tests

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
Joseph T Lyons 2022-10-27 18:06:34 -04:00
parent 309f401015
commit 8a926c4a23
2 changed files with 14 additions and 6 deletions

View File

@ -34,7 +34,7 @@ struct AmplitudeTelemetryState {
metrics_id: Option<Arc<str>>,
device_id: Option<Arc<str>>,
app_version: Option<Arc<str>>,
release_channel: &'static str,
release_channel: Option<&'static str>,
os_version: Option<Arc<str>>,
os_name: &'static str,
queue: Vec<AmplitudeEvent>,
@ -72,7 +72,7 @@ struct AmplitudeEvent {
app_version: Option<Arc<str>>,
#[serde(rename = "App")]
app: &'static str,
release_channel: &'static str,
release_channel: Option<&'static str>,
event_id: usize,
session_id: u128,
time: u128,
@ -93,7 +93,11 @@ const DEBOUNCE_INTERVAL: Duration = Duration::from_secs(30);
impl AmplitudeTelemetry {
pub fn new(client: Arc<dyn HttpClient>, cx: &AppContext) -> Arc<Self> {
let platform = cx.platform();
let release_channel = cx.global::<ReleaseChannel>().name();
let release_channel = if cx.has_global::<ReleaseChannel>() {
Some(cx.global::<ReleaseChannel>().name())
} else {
None
};
let this = Arc::new(Self {
http_client: client,
executor: cx.background().clone(),

View File

@ -33,7 +33,7 @@ struct TelemetryState {
metrics_id: Option<Arc<str>>,
device_id: Option<Arc<str>>,
app_version: Option<Arc<str>>,
release_channel: &'static str,
release_channel: Option<&'static str>,
os_version: Option<Arc<str>>,
os_name: &'static str,
queue: Vec<MixpanelEvent>,
@ -74,7 +74,7 @@ struct MixpanelEventProperties {
#[serde(rename = "OS Version")]
os_version: Option<Arc<str>>,
#[serde(rename = "Release Channel")]
release_channel: &'static str,
release_channel: Option<&'static str>,
#[serde(rename = "App Version")]
app_version: Option<Arc<str>>,
#[serde(rename = "Signed In")]
@ -108,7 +108,11 @@ const DEBOUNCE_INTERVAL: Duration = Duration::from_secs(30);
impl Telemetry {
pub fn new(client: Arc<dyn HttpClient>, cx: &AppContext) -> Arc<Self> {
let platform = cx.platform();
let release_channel = cx.global::<ReleaseChannel>().name();
let release_channel = if cx.has_global::<ReleaseChannel>() {
Some(cx.global::<ReleaseChannel>().name())
} else {
None
};
let this = Arc::new(Self {
http_client: client,
executor: cx.background().clone(),