Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Uncomment Editor::report_editor_event
Antonio Scandurra97d1d9bd9b3b
diff --git a/Cargo.lock b/Cargo.lockindex 135e8a7ca94..161bc15d97f 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.tomlindex e356a351553..121c03ec009 100644--- a/crates/editor2/Cargo.toml+++ b/crates/editor2/Cargo.toml@@ -62,6 +62,7 @@ postage.workspace = truerand.workspace = trueschemars.workspace = trueserde.workspace = true+serde_json.workspace = trueserde_derive.workspace = truesmallvec.workspace = truesmol.workspace = truediff --git a/crates/editor2/src/editor.rs b/crates/editor2/src/editor.rsindex 4bd1a515386..18b5b547dfc 100644--- a/crates/editor2/src/editor.rs+++ b/crates/editor2/src/editor.rs@@ -8981,45 +8981,43 @@ impl Editor {file_extension: Option<String>,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::<SettingsStore>()+ .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::<SettingsStore>()- // .raw_user_settings()- // .get("vim_mode")- // == Some(&serde_json::Value::Bool(true));- // let telemetry_settings = *settings::get::<TelemetrySettings>(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.