From e5f096513827686561fa3b44853028bdfbb6112d Mon Sep 17 00:00:00 2001 From: Joseph T Lyons Date: Tue, 1 Nov 2022 20:36:18 -0400 Subject: [PATCH] Differentiate between first time app starts and subsequent ones --- crates/client/src/telemetry.rs | 24 +++++++++++++++++------- crates/zed/src/main.rs | 1 - 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/crates/client/src/telemetry.rs b/crates/client/src/telemetry.rs index 1a0238cd0f..3aff42d335 100644 --- a/crates/client/src/telemetry.rs +++ b/crates/client/src/telemetry.rs @@ -157,13 +157,16 @@ impl Telemetry { self.executor .spawn( async move { - let device_id = if let Ok(Some(device_id)) = db.read_kvp("device_id") { - device_id - } else { - let device_id = Uuid::new_v4().to_string(); - db.write_kvp("device_id", &device_id)?; - device_id - }; + let (device_id, is_first_time_start) = + if let Ok(Some(device_id)) = db.read_kvp("device_id") { + (device_id, false) + } else { + let device_id = Uuid::new_v4().to_string(); + db.write_kvp("device_id", &device_id)?; + (device_id, true) + }; + + this.report_start_app(is_first_time_start); let device_id: Arc = device_id.into(); let mut state = this.state.lock(); @@ -260,6 +263,13 @@ impl Telemetry { } } + pub fn report_start_app(self: &Arc, is_first_time_start: bool) { + self.report_event( + "Start App", + json!({ "is_first_time_start": is_first_time_start }), + ) + } + fn flush(self: &Arc) { let mut state = self.state.lock(); let mut events = mem::take(&mut state.queue); diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index 74a38599ec..168152efac 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -150,7 +150,6 @@ fn main() { let project_store = cx.add_model(|_| ProjectStore::new()); let db = cx.background().block(db); client.start_telemetry(db.clone()); - client.report_event("start app", Default::default()); let app_state = Arc::new(AppState { languages,