Scrape email from feedback editor (#2543)
Add release note lines here: N/A
This commit is contained in:
Generated
+1
@@ -2236,6 +2236,7 @@ dependencies = [
|
|||||||
"log",
|
"log",
|
||||||
"postage",
|
"postage",
|
||||||
"project",
|
"project",
|
||||||
|
"regex",
|
||||||
"search",
|
"search",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ editor = { path = "../editor" }
|
|||||||
language = { path = "../language" }
|
language = { path = "../language" }
|
||||||
gpui = { path = "../gpui" }
|
gpui = { path = "../gpui" }
|
||||||
project = { path = "../project" }
|
project = { path = "../project" }
|
||||||
|
regex.workspace = true
|
||||||
search = { path = "../search" }
|
search = { path = "../search" }
|
||||||
settings = { path = "../settings" }
|
settings = { path = "../settings" }
|
||||||
theme = { path = "../theme" }
|
theme = { path = "../theme" }
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ use isahc::Request;
|
|||||||
use language::Buffer;
|
use language::Buffer;
|
||||||
use postage::prelude::Stream;
|
use postage::prelude::Stream;
|
||||||
use project::Project;
|
use project::Project;
|
||||||
|
use regex::Regex;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::{
|
use std::{
|
||||||
@@ -46,6 +47,7 @@ pub fn init(cx: &mut AppContext) {
|
|||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct FeedbackRequestBody<'a> {
|
struct FeedbackRequestBody<'a> {
|
||||||
feedback_text: &'a str,
|
feedback_text: &'a str,
|
||||||
|
email: Option<String>,
|
||||||
metrics_id: Option<Arc<str>>,
|
metrics_id: Option<Arc<str>>,
|
||||||
installation_id: Option<Arc<str>>,
|
installation_id: Option<Arc<str>>,
|
||||||
system_specs: SystemSpecs,
|
system_specs: SystemSpecs,
|
||||||
@@ -157,8 +159,18 @@ impl FeedbackEditor {
|
|||||||
let is_staff = telemetry.is_staff();
|
let is_staff = telemetry.is_staff();
|
||||||
let http_client = zed_client.http_client();
|
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 {
|
let request = FeedbackRequestBody {
|
||||||
feedback_text: &feedback_text,
|
feedback_text: &feedback_text,
|
||||||
|
email,
|
||||||
metrics_id,
|
metrics_id,
|
||||||
installation_id,
|
installation_id,
|
||||||
system_specs,
|
system_specs,
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ impl View for FeedbackInfoText {
|
|||||||
Flex::row()
|
Flex::row()
|
||||||
.with_child(
|
.with_child(
|
||||||
Text::new(
|
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(),
|
theme.feedback.info_text_default.text.clone(),
|
||||||
)
|
)
|
||||||
.with_soft_wrap(false)
|
.with_soft_wrap(false)
|
||||||
@@ -60,7 +60,7 @@ impl View for FeedbackInfoText {
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.with_child(
|
.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)
|
.with_soft_wrap(false)
|
||||||
.aligned(),
|
.aligned(),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user