From 97d1d9bd9b3ba4b9367c8025b99cf101793ceb44 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 3 Nov 2023 10:53:55 +0100 Subject: [PATCH] Uncomment Editor::report_editor_event --- Cargo.lock | 1 + crates/editor2/Cargo.toml | 1 + crates/editor2/src/editor.rs | 74 ++++++++++++++++++------------------ 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 135e8a7ca9..161bc15d97 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2657,6 +2657,7 @@ dependencies = [ "schemars", "serde", "serde_derive", + "serde_json", "settings2", "smallvec", "smol", diff --git a/crates/editor2/Cargo.toml b/crates/editor2/Cargo.toml index e356a35155..121c03ec00 100644 --- a/crates/editor2/Cargo.toml +++ b/crates/editor2/Cargo.toml @@ -62,6 +62,7 @@ postage.workspace = true rand.workspace = true schemars.workspace = true serde.workspace = true +serde_json.workspace = true serde_derive.workspace = true smallvec.workspace = true smol.workspace = true diff --git a/crates/editor2/src/editor.rs b/crates/editor2/src/editor.rs index 4bd1a51538..18b5b547df 100644 --- a/crates/editor2/src/editor.rs +++ b/crates/editor2/src/editor.rs @@ -8981,45 +8981,43 @@ impl Editor { file_extension: Option, cx: &AppContext, ) { - todo!("old version below"); + let Some(project) = &self.project else { return }; + + // If None, we are in a file without an extension + let file = self + .buffer + .read(cx) + .as_singleton() + .and_then(|b| b.read(cx).file()); + let file_extension = file_extension.or(file + .as_ref() + .and_then(|file| Path::new(file.file_name(cx)).extension()) + .and_then(|e| e.to_str()) + .map(|a| a.to_string())); + + let vim_mode = cx + .global::() + .raw_user_settings() + .get("vim_mode") + == Some(&serde_json::Value::Bool(true)); + let telemetry_settings = *TelemetrySettings::get_global(cx); + let copilot_enabled = all_language_settings(file, cx).copilot_enabled(None, None); + let copilot_enabled_for_language = self + .buffer + .read(cx) + .settings_at(0, cx) + .show_copilot_suggestions; + + let telemetry = project.read(cx).client().telemetry().clone(); + let event = ClickhouseEvent::Editor { + file_extension, + vim_mode, + operation, + copilot_enabled, + copilot_enabled_for_language, + }; + telemetry.report_clickhouse_event(event, telemetry_settings) } - // let Some(project) = &self.project else { return }; - - // // If None, we are in a file without an extension - // let file = self - // .buffer - // .read(cx) - // .as_singleton() - // .and_then(|b| b.read(cx).file()); - // let file_extension = file_extension.or(file - // .as_ref() - // .and_then(|file| Path::new(file.file_name(cx)).extension()) - // .and_then(|e| e.to_str()) - // .map(|a| a.to_string())); - - // let vim_mode = cx - // .global::() - // .raw_user_settings() - // .get("vim_mode") - // == Some(&serde_json::Value::Bool(true)); - // let telemetry_settings = *settings::get::(cx); - // let copilot_enabled = all_language_settings(file, cx).copilot_enabled(None, None); - // let copilot_enabled_for_language = self - // .buffer - // .read(cx) - // .settings_at(0, cx) - // .show_copilot_suggestions; - - // let telemetry = project.read(cx).client().telemetry().clone(); - // let event = ClickhouseEvent::Editor { - // file_extension, - // vim_mode, - // operation, - // copilot_enabled, - // copilot_enabled_for_language, - // }; - // telemetry.report_clickhouse_event(event, telemetry_settings) - // } // /// Copy the highlighted chunks to the clipboard as JSON. The format is an array of lines, // /// with each line being an array of {text, highlight} objects.