From b1870af386a7d048cb89e6ecef8b5b29d83e1800 Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Fri, 22 Dec 2023 20:23:55 -0500 Subject: [PATCH] Add project open event Give the caller of report_app_event() the choice of whether to immediately flush the queue or not. --- crates/client/src/telemetry.rs | 4 ++-- crates/client2/src/telemetry.rs | 6 +++--- crates/workspace/src/workspace.rs | 6 +++++- crates/workspace2/src/workspace2.rs | 6 +++++- crates/zed/src/main.rs | 2 +- crates/zed2/src/main.rs | 2 +- 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/crates/client/src/telemetry.rs b/crates/client/src/telemetry.rs index 0118832fe03bdca1e4c08199fe369304b1ca879b..49cb9843f030df4379a2ac0936d100a6c3c2807e 100644 --- a/crates/client/src/telemetry.rs +++ b/crates/client/src/telemetry.rs @@ -340,18 +340,18 @@ impl Telemetry { self.report_clickhouse_event(event, telemetry_settings, false) } - // app_events are called at app open and app close, so flush is set to immediately send pub fn report_app_event( self: &Arc, telemetry_settings: TelemetrySettings, operation: &'static str, + immediate_flush: bool, ) { let event = ClickhouseEvent::App { operation, milliseconds_since_first_event: self.milliseconds_since_first_event(), }; - self.report_clickhouse_event(event, telemetry_settings, true) + self.report_clickhouse_event(event, telemetry_settings, immediate_flush) } fn milliseconds_since_first_event(&self) -> i64 { diff --git a/crates/client2/src/telemetry.rs b/crates/client2/src/telemetry.rs index e27bc3a49808946bc3027d64bcaab53e588df32f..f02ff937e4b992058f80e46d5fb4335281f40a35 100644 --- a/crates/client2/src/telemetry.rs +++ b/crates/client2/src/telemetry.rs @@ -173,7 +173,7 @@ impl Telemetry { #[cfg(not(any(test, feature = "test-support")))] fn shutdown_telemetry(self: &Arc, cx: &mut AppContext) -> impl Future { let telemetry_settings = TelemetrySettings::get_global(cx).clone(); - self.report_app_event(telemetry_settings, "close"); + self.report_app_event(telemetry_settings, "close", true); Task::ready(()) } @@ -364,18 +364,18 @@ impl Telemetry { self.report_clickhouse_event(event, telemetry_settings, false) } - // app_events are called at app open and app close, so flush is set to immediately send pub fn report_app_event( self: &Arc, telemetry_settings: TelemetrySettings, operation: &'static str, + immediate_flush: bool, ) { let event = ClickhouseEvent::App { operation, milliseconds_since_first_event: self.milliseconds_since_first_event(), }; - self.report_clickhouse_event(event, telemetry_settings, true) + self.report_clickhouse_event(event, telemetry_settings, immediate_flush) } fn milliseconds_since_first_event(&self) -> i64 { diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 455c27a57e1821f233a35a6eb6f9f3e223fa1bb0..ee2a8ab104a1bfdd7281b345e5fdb854f50507ab 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -14,7 +14,7 @@ use anyhow::{anyhow, Context, Result}; use call::ActiveCall; use client::{ proto::{self, PeerId}, - Client, Status, TypedEnvelope, UserStore, + Client, Status, TelemetrySettings, TypedEnvelope, UserStore, }; use collections::{hash_map, HashMap, HashSet}; use drag_and_drop::DragAndDrop; @@ -1462,6 +1462,10 @@ impl Workspace { } pub fn open(&mut self, _: &Open, cx: &mut ViewContext) -> Option>> { + let telemetry_settings = *settings::get::(cx); + self.client() + .telemetry() + .report_app_event(telemetry_settings, "open project", false); let mut paths = cx.prompt_for_paths(PathPromptOptions { files: true, directories: true, diff --git a/crates/workspace2/src/workspace2.rs b/crates/workspace2/src/workspace2.rs index 61083ad2698d99f421c890f8440c8f88806d3ad6..0eb6425287f0ee6da9ceaf617078bc55392d32bf 100644 --- a/crates/workspace2/src/workspace2.rs +++ b/crates/workspace2/src/workspace2.rs @@ -15,7 +15,7 @@ use anyhow::{anyhow, Context as _, Result}; use call::ActiveCall; use client::{ proto::{self, PeerId}, - Client, Status, TypedEnvelope, UserStore, + Client, Status, TelemetrySettings, TypedEnvelope, UserStore, }; use collections::{hash_map, HashMap, HashSet}; use dock::{Dock, DockPosition, Panel, PanelButtons, PanelHandle}; @@ -1250,6 +1250,10 @@ impl Workspace { } pub fn open(&mut self, _: &Open, cx: &mut ViewContext) { + let telemetry_settings = TelemetrySettings::get_global(cx).clone(); + self.client() + .telemetry() + .report_app_event(telemetry_settings, "open project", false); let paths = cx.prompt_for_paths(PathPromptOptions { files: true, directories: true, diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index 20b93ae6bb4f3ddf0368748fd949ddb5c6b83e63..04f468eb2f03a2ea9661005116a2d9796af6c5c9 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -174,7 +174,7 @@ fn main() { }; client .telemetry() - .report_app_event(telemetry_settings, event_operation); + .report_app_event(telemetry_settings, event_operation, true); let app_state = Arc::new(AppState { languages, diff --git a/crates/zed2/src/main.rs b/crates/zed2/src/main.rs index 93643648b8c78b13556d97e6de2f491b99642a67..a885a81f79e7e4c3fc02e1dfe2e13a5072dac668 100644 --- a/crates/zed2/src/main.rs +++ b/crates/zed2/src/main.rs @@ -184,7 +184,7 @@ fn main() { }; client .telemetry() - .report_app_event(telemetry_settings, event_operation); + .report_app_event(telemetry_settings, event_operation, true); let app_state = Arc::new(AppState { languages: languages.clone(),