Skip to content

Commit

Permalink
feat(debugger): add telemetry for debugger
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
obycode authored and lgalabru committed Mar 30, 2022
1 parent 38a89b5 commit 4438e23
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/frontend/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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() => {
Expand Down
11 changes: 11 additions & 0 deletions src/frontend/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub enum DeveloperUsageEvent {
TestSuiteExecuted(DeveloperUsageDigest, bool, u32),
DevnetExecuted(DeveloperUsageDigest),
ContractPublished(DeveloperUsageDigest, Network),
DebugStarted(DeveloperUsageDigest, u32),
UnknownCommand(DeveloperUsageDigest, String),
}

Expand Down Expand Up @@ -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!({
Expand Down

0 comments on commit 4438e23

Please sign in to comment.