From 77bf2ad0f14b33c2be817b1094321578edbcdccf Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Tue, 8 Oct 2024 13:13:40 -0400 Subject: [PATCH] Add is_via_ssh field to edit events (#18867) Release Notes: - N/A --- crates/client/src/telemetry.rs | 3 ++- crates/collab/src/api/events.rs | 2 ++ crates/editor/src/editor.rs | 9 +++++++-- crates/telemetry_events/src/telemetry_events.rs | 4 +++- crates/terminal_view/src/terminal_element.rs | 6 +++--- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/crates/client/src/telemetry.rs b/crates/client/src/telemetry.rs index 24d448aa02..5a752bc05f 100644 --- a/crates/client/src/telemetry.rs +++ b/crates/client/src/telemetry.rs @@ -458,7 +458,7 @@ impl Telemetry { })) } - pub fn log_edit_event(self: &Arc, environment: &'static str) { + pub fn log_edit_event(self: &Arc, environment: &'static str, is_via_ssh: bool) { let mut state = self.state.lock(); let period_data = state.event_coalescer.log_event(environment); drop(state); @@ -467,6 +467,7 @@ impl Telemetry { let event = Event::Edit(EditEvent { duration: end.timestamp_millis() - start.timestamp_millis(), environment: environment.to_string(), + is_via_ssh, }); self.report_event(event); diff --git a/crates/collab/src/api/events.rs b/crates/collab/src/api/events.rs index 5d40c59daf..715f374494 100644 --- a/crates/collab/src/api/events.rs +++ b/crates/collab/src/api/events.rs @@ -1263,6 +1263,7 @@ pub struct EditEventRow { period_start: i64, period_end: i64, environment: String, + is_via_ssh: bool, } impl EditEventRow { @@ -1296,6 +1297,7 @@ impl EditEventRow { period_start: period_start.timestamp_millis(), period_end: period_end.timestamp_millis(), environment: event.environment, + is_via_ssh: event.is_via_ssh, } } } diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 39bc2f45e5..2f7c8ce5d7 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -12146,9 +12146,14 @@ impl Editor { } let Some(project) = &self.project else { return }; - let telemetry = project.read(cx).client().telemetry().clone(); + let (telemetry, is_via_ssh) = { + let project = project.read(cx); + let telemetry = project.client().telemetry().clone(); + let is_via_ssh = project.is_via_ssh(); + (telemetry, is_via_ssh) + }; refresh_linked_ranges(self, cx); - telemetry.log_edit_event("editor"); + telemetry.log_edit_event("editor", is_via_ssh); } multi_buffer::Event::ExcerptsAdded { buffer, diff --git a/crates/telemetry_events/src/telemetry_events.rs b/crates/telemetry_events/src/telemetry_events.rs index 32cb377ed6..32d2bde5c6 100644 --- a/crates/telemetry_events/src/telemetry_events.rs +++ b/crates/telemetry_events/src/telemetry_events.rs @@ -116,7 +116,7 @@ pub struct EditorEvent { pub copilot_enabled: bool, /// Whether the user has copilot enabled for the language of the file opened or saved pub copilot_enabled_for_language: bool, - /// Whether the client is editing a local file or a remote file via SSH + /// Whether the client is opening/saving a local file or a remote file via SSH pub is_via_ssh: bool, } @@ -174,6 +174,8 @@ pub struct ActionEvent { pub struct EditEvent { pub duration: i64, pub environment: String, + /// Whether the edits occurred locally or remotely via SSH + pub is_via_ssh: bool, } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] diff --git a/crates/terminal_view/src/terminal_element.rs b/crates/terminal_view/src/terminal_element.rs index ce4be0e679..db87fd8dc2 100644 --- a/crates/terminal_view/src/terminal_element.rs +++ b/crates/terminal_view/src/terminal_element.rs @@ -1019,9 +1019,9 @@ impl InputHandler for TerminalInputHandler { self.workspace .update(cx, |this, cx| { cx.invalidate_character_coordinates(); - - let telemetry = this.project().read(cx).client().telemetry().clone(); - telemetry.log_edit_event("terminal"); + let project = this.project().read(cx); + let telemetry = project.client().telemetry().clone(); + telemetry.log_edit_event("terminal", project.is_via_ssh()); }) .ok(); }