-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(feedback): add User Feedbacks as Events (#2604)
Relay changes for the revamped User Feedback feature. User Feedbacks (Known as `UserFeedbackV2`), will be events that flow through our system instead of attachments. See [here](https://www.notion.so/sentry/User-Feedback-Beta-11d68db039bc436bae017ad56c0c20f9?pvs=4) for more information on the tech spec (and the link at the bottom for what we do once they're ingested). Note that within this code, we're calling it `UserReportV2`. This is to avoid confusion with the existing `UserReport`. A PR to shim the previous `UserReports` as new `UserReportV2`'s will follow, at which point we'll rename this in the code to be `UserFeedback`. The string `feedback` is used for the context and ItemType / EventType parsing. - [x] Adds a feature flag for ingest `UserReportV2Ingest`. This is backed by options getsentry/getsentry#11573 - [x] Creates a new EventType `UserReportV2` - [x] Creates a new ItemType `UserReportV2` - [x] Creates a new DataCategory `UserReportV2` - [x] Adds a new context `UserReportV2Context` that for now contains two properties, `contact_email` (no pii stripping), and the `message` which contains the feedback text. --------- Co-authored-by: Iker Barriocanal <32816711+iker-barriocanal@users.noreply.github.com>
- Loading branch information
1 parent
939dab7
commit 20f72be
Showing
20 changed files
with
307 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
relay-event-schema/src/protocol/contexts/user_report_v2.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#[cfg(feature = "jsonschema")] | ||
use relay_jsonschema_derive::JsonSchema; | ||
use relay_protocol::{Annotated, Empty, FromValue, IntoValue, Object, Value}; | ||
|
||
use crate::processor::ProcessValue; | ||
|
||
/// Feedback context. | ||
/// | ||
/// This contexts contains user feedback specific attributes. | ||
/// We don't PII scrub contact_email as that is provided by the user. | ||
/// TODO(jferg): rename to FeedbackContext once old UserReport logic is deprecated. | ||
#[derive(Clone, Debug, Default, PartialEq, Empty, FromValue, IntoValue, ProcessValue)] | ||
#[cfg_attr(feature = "jsonschema", derive(JsonSchema))] | ||
pub struct UserReportV2Context { | ||
/// The feedback message which contains what the user has to say. | ||
pub message: Annotated<String>, | ||
|
||
/// an email optionally provided by the user, which can be different from user.email | ||
#[metastructure(pii = "false")] | ||
pub contact_email: Annotated<String>, | ||
/// Additional arbitrary fields for forwards compatibility. | ||
#[metastructure(additional_properties, retain = "true")] | ||
pub other: Object<Value>, | ||
} | ||
|
||
impl super::DefaultContext for UserReportV2Context { | ||
fn default_key() -> &'static str { | ||
"feedback" | ||
} | ||
|
||
fn from_context(context: super::Context) -> Option<Self> { | ||
match context { | ||
super::Context::UserReportV2(c) => Some(*c), | ||
_ => None, | ||
} | ||
} | ||
|
||
fn cast(context: &super::Context) -> Option<&Self> { | ||
match context { | ||
super::Context::UserReportV2(c) => Some(c), | ||
_ => None, | ||
} | ||
} | ||
|
||
fn cast_mut(context: &mut super::Context) -> Option<&mut Self> { | ||
match context { | ||
super::Context::UserReportV2(c) => Some(c), | ||
_ => None, | ||
} | ||
} | ||
|
||
fn into_context(self) -> super::Context { | ||
super::Context::UserReportV2(Box::new(self)) | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use crate::protocol::Context; | ||
|
||
#[test] | ||
fn test_feedback_context() { | ||
let json = r#"{ | ||
"message": "test message", | ||
"contact_email": "test@test.com", | ||
"type": "feedback" | ||
}"#; | ||
let context = Annotated::new(Context::UserReportV2(Box::new(UserReportV2Context { | ||
message: Annotated::new("test message".to_string()), | ||
contact_email: Annotated::new("test@test.com".to_string()), | ||
other: Object::default(), | ||
}))); | ||
|
||
assert_eq!(context, Annotated::from_json(json).unwrap()); | ||
assert_eq!(json, context.to_json_pretty().unwrap()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.