Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Scrape email from feedback editor

Joseph Lyons501f9ab2c6dc
diff --git a/Cargo.lock b/Cargo.lock
index 3537056373c..3751b34d315 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2236,6 +2236,7 @@ dependencies = [
"log",
"postage",
"project",
+ "regex",
"search",
"serde",
"serde_derive",
diff --git a/crates/feedback/Cargo.toml b/crates/feedback/Cargo.toml
index cd35afbda8c..07b6ad790c8 100644
--- a/crates/feedback/Cargo.toml
+++ b/crates/feedback/Cargo.toml
@@ -16,6 +16,7 @@ editor = { path = "../editor" }
language = { path = "../language" }
gpui = { path = "../gpui" }
project = { path = "../project" }
+regex.workspace = true
search = { path = "../search" }
settings = { path = "../settings" }
theme = { path = "../theme" }
diff --git a/crates/feedback/src/feedback_editor.rs b/crates/feedback/src/feedback_editor.rs
index d5d20b069ac..5a4f912e3a0 100644
--- a/crates/feedback/src/feedback_editor.rs
+++ b/crates/feedback/src/feedback_editor.rs
@@ -14,6 +14,7 @@ use isahc::Request;
use language::Buffer;
use postage::prelude::Stream;
use project::Project;
+use regex::Regex;
use serde::Serialize;
use smallvec::SmallVec;
use std::{
@@ -46,6 +47,7 @@ pub fn init(cx: &mut AppContext) {
#[derive(Serialize)]
struct FeedbackRequestBody<'a> {
feedback_text: &'a str,
+ email: Option<String>,
metrics_id: Option<Arc<str>>,
installation_id: Option<Arc<str>>,
system_specs: SystemSpecs,
@@ -157,8 +159,18 @@ impl FeedbackEditor {
let is_staff = telemetry.is_staff();
let http_client = zed_client.http_client();
+ let re = Regex::new(r"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b").unwrap();
+
+ let emails: Vec<&str> = re
+ .captures_iter(feedback_text)
+ .map(|capture| capture.get(0).unwrap().as_str())
+ .collect();
+
+ let email = emails.first().map(|e| e.to_string());
+
let request = FeedbackRequestBody {
feedback_text: &feedback_text,
+ email,
metrics_id,
installation_id,
system_specs,
diff --git a/crates/feedback/src/feedback_info_text.rs b/crates/feedback/src/feedback_info_text.rs
index 5852cd9a618..6c55b7a7139 100644
--- a/crates/feedback/src/feedback_info_text.rs
+++ b/crates/feedback/src/feedback_info_text.rs
@@ -34,7 +34,7 @@ impl View for FeedbackInfoText {
Flex::row()
.with_child(
Text::new(
- "We read whatever you submit here. For issues and discussions, visit the ",
+ "Share your feedback. Include your email for replies. For issues and discussions, visit the ",
theme.feedback.info_text_default.text.clone(),
)
.with_soft_wrap(false)
@@ -60,7 +60,7 @@ impl View for FeedbackInfoText {
}),
)
.with_child(
- Text::new(" on GitHub.", theme.feedback.info_text_default.text.clone())
+ Text::new(".", theme.feedback.info_text_default.text.clone())
.with_soft_wrap(false)
.aligned(),
)