Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
debugger: Add telemetry for new session experience (#31171)
Piotr Osiewicz28ec7fbb81b4
diff --git a/Cargo.lock b/Cargo.lockindex 06ae1acc93d..53b1c7254ef 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -4030,6 +4030,7 @@ dependencies = ["smallvec","smol","task",+ "telemetry","util","workspace-hack",]@@ -4678,6 +4679,7 @@ dependencies = ["command_palette_hooks","convert_case 0.8.0","ctor",+ "dap","db","emojis","env_logger 0.11.8",diff --git a/crates/dap/Cargo.toml b/crates/dap/Cargo.tomlindex 531276e7088..67f2e4e4ec1 100644--- a/crates/dap/Cargo.toml+++ b/crates/dap/Cargo.toml@@ -47,6 +47,7 @@ settings.workspace = truesmallvec.workspace = truesmol.workspace = truetask.workspace = true+telemetry.workspace = trueutil.workspace = trueworkspace-hack.workspace = truediff --git a/crates/dap/src/dap.rs b/crates/dap/src/dap.rsindex e38487ae522..2363fc2242f 100644--- a/crates/dap/src/dap.rs+++ b/crates/dap/src/dap.rs@@ -9,7 +9,11 @@ pub mod transport;use std::net::Ipv4Addr;pub use dap_types::*;+use debugger_settings::DebuggerSettings;+use gpui::App;pub use registry::{DapLocator, DapRegistry};+use serde::Serialize;+use settings::Settings;pub use task::DebugRequest;pub type ScopeId = u64;@@ -18,7 +22,7 @@ pub type StackFrameId = u64;#[cfg(any(test, feature = "test-support"))]pub use adapters::FakeAdapter;-use task::TcpArgumentsTemplate;+use task::{DebugScenario, TcpArgumentsTemplate};pub async fn configure_tcp_connection(tcp_connection: TcpArgumentsTemplate,@@ -34,3 +38,31 @@ pub async fn configure_tcp_connection(Ok((host, port, timeout))}++#[derive(Clone, Copy, Serialize)]+#[serde(rename_all = "snake_case")]+pub enum TelemetrySpawnLocation {+ Gutter,+ ScenarioList,+ Custom,+}++pub fn send_telemetry(scenario: &DebugScenario, location: TelemetrySpawnLocation, cx: &App) {+ let Some(adapter) = cx.global::<DapRegistry>().adapter(&scenario.adapter) else {+ return;+ };+ let kind = adapter+ .validate_config(&scenario.config)+ .ok()+ .map(serde_json::to_value)+ .and_then(Result::ok);+ let dock = DebuggerSettings::get_global(cx).dock;+ telemetry::event!(+ "Debugger Session Started",+ spawn_location = location,+ with_build_task = scenario.build.is_some(),+ kind = kind,+ adapter = scenario.adapter.as_ref(),+ dock_position = dock,+ );+}diff --git a/crates/debugger_ui/src/new_session_modal.rs b/crates/debugger_ui/src/new_session_modal.rsindex ab3cf2c1977..de0ccce2c32 100644--- a/crates/debugger_ui/src/new_session_modal.rs+++ b/crates/debugger_ui/src/new_session_modal.rs@@ -9,7 +9,9 @@ use std::{usize,};-use dap::{DapRegistry, DebugRequest, adapters::DebugAdapterName};+use dap::{+ DapRegistry, DebugRequest, TelemetrySpawnLocation, adapters::DebugAdapterName, send_telemetry,+};use editor::{Editor, EditorElement, EditorStyle};use fuzzy::{StringMatch, StringMatchCandidate};use gpui::{@@ -240,6 +242,7 @@ impl NewSessionModal {let Some(task_contexts) = self.task_contexts(cx) else {return;};+ send_telemetry(&config, TelemetrySpawnLocation::Custom, cx);let task_context = task_contexts.active_context().cloned().unwrap_or_default();let worktree_id = task_contexts.worktree();cx.spawn_in(window, async move |this, cx| {@@ -277,8 +280,8 @@ impl NewSessionModal {})}- fn task_contexts<'a>(&self, cx: &'a mut Context<Self>) -> Option<&'a TaskContexts> {- self.launch_picker.read(cx).delegate.task_contexts.as_ref()+ fn task_contexts(&self, cx: &App) -> Option<Arc<TaskContexts>> {+ self.launch_picker.read(cx).delegate.task_contexts.clone()}fn adapter_drop_down_menu(@@ -901,7 +904,7 @@ pub(super) struct DebugScenarioDelegate {matches: Vec<StringMatch>,prompt: String,debug_panel: WeakEntity<DebugPanel>,- task_contexts: Option<TaskContexts>,+ task_contexts: Option<Arc<TaskContexts>>,divider_index: Option<usize>,last_used_candidate_index: Option<usize>,}@@ -954,7 +957,7 @@ impl DebugScenarioDelegate {_window: &mut Window,cx: &mut Context<Picker<Self>>,) {- self.task_contexts = Some(task_contexts);+ self.task_contexts = Some(Arc::new(task_contexts));let (recent, scenarios) = self.task_store@@ -1090,6 +1093,7 @@ impl PickerDelegate for DebugScenarioDelegate {}).unwrap_or_default();+ send_telemetry(&debug_scenario, TelemetrySpawnLocation::ScenarioList, cx);self.debug_panel.update(cx, |panel, cx| {panel.start_session(debug_scenario, task_context, None, worktree_id, window, cx);diff --git a/crates/editor/Cargo.toml b/crates/editor/Cargo.tomlindex 6edc7a5f6af..cd1db877e70 100644--- a/crates/editor/Cargo.toml+++ b/crates/editor/Cargo.toml@@ -37,6 +37,7 @@ clock.workspace = truecollections.workspace = truecommand_palette_hooks.workspace = trueconvert_case.workspace = true+dap.workspace = truedb.workspace = truebuffer_diff.workspace = trueemojis.workspace = truediff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex f079d0fb275..1f39f9ed7b7 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -59,6 +59,7 @@ use client::{Collaborator, ParticipantIndex};use clock::{AGENT_REPLICA_ID, ReplicaId};use collections::{BTreeMap, HashMap, HashSet, VecDeque};use convert_case::{Case, Casing};+use dap::TelemetrySpawnLocation;use display_map::*;pub use display_map::{ChunkRenderer, ChunkRendererContext, DisplayPoint, FoldPlaceholder};pub use editor_settings::{@@ -5619,6 +5620,7 @@ impl Editor {let context = actions_menu.actions.context.clone();workspace.update(cx, |workspace, cx| {+ dap::send_telemetry(&scenario, TelemetrySpawnLocation::Gutter, cx);workspace.start_debug_session(scenario, context, Some(buffer), window, cx);});Some(Task::ready(Ok(())))