From 4438e23430f3beee04ef0629c144b428adc55cf6 Mon Sep 17 00:00:00 2001 From: Brice Dobry Date: Mon, 21 Mar 2022 20:47:25 -0400 Subject: [PATCH] feat(debugger): add telemetry for debugger For each execution of the console that includes at least one use of the debugger, a telemetry event is sent with the number of debug sessions executed during that console session. --- src/frontend/cli.rs | 25 ++++++++++++++++++++++--- src/frontend/telemetry.rs | 11 +++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/frontend/cli.rs b/src/frontend/cli.rs index aee39c732..5539d7b89 100644 --- a/src/frontend/cli.rs +++ b/src/frontend/cli.rs @@ -443,12 +443,12 @@ pub fn main() { Command::Console(cmd) => { let manifest_path = get_manifest_path_or_exit(cmd.manifest_path); let start_repl = true; - let project_manifest = match load_session(&manifest_path, start_repl, &Network::Devnet) + let (session, project_manifest) = match load_session(&manifest_path, start_repl, &Network::Devnet) { - Ok((_, _, res, _)) => res, + Ok((session, _, project_manifest, _)) => (Some(session), project_manifest), Err((project_manifest, e)) => { println!("{}: Unable to start REPL: {}", red!("error"), e); - project_manifest + (None, project_manifest) } }; if hints_enabled { @@ -462,6 +462,25 @@ pub fn main() { &project_manifest.project.authors, ), )); + + #[cfg(feature = "telemetry")] + if let Some(session) = session { + let mut debug_count = 0; + for command in session.executed { + if command.starts_with("::debug") { + debug_count += 1; + } + } + if debug_count > 0 { + telemetry_report_event(DeveloperUsageEvent::DebugStarted( + DeveloperUsageDigest::new( + &project_manifest.project.name, + &project_manifest.project.authors, + ), + debug_count, + )); + } + } } } Command::Check(cmd) if cmd.file.is_some() => { diff --git a/src/frontend/telemetry.rs b/src/frontend/telemetry.rs index 6c83f5085..2f968e7e9 100644 --- a/src/frontend/telemetry.rs +++ b/src/frontend/telemetry.rs @@ -14,6 +14,7 @@ pub enum DeveloperUsageEvent { TestSuiteExecuted(DeveloperUsageDigest, bool, u32), DevnetExecuted(DeveloperUsageDigest), ContractPublished(DeveloperUsageDigest, Network), + DebugStarted(DeveloperUsageDigest, u32), UnknownCommand(DeveloperUsageDigest, String), } @@ -110,6 +111,16 @@ async fn send_event(event: DeveloperUsageEvent) { "ci_mode": ci_mode, }), ), + DeveloperUsageEvent::DebugStarted(digest, num_sessions) => ( + "DebugStarted", + json!({ + "project_id": digest.project_id, + "team_id": digest.team_id, + "clarinet_version": clarinet_version, + "ci_mode": ci_mode, + "sessions": num_sessions, + }), + ), DeveloperUsageEvent::UnknownCommand(digest, command) => ( "UnknownCommand", json!({