relay_event_schema/protocol/user_report.rs
1use serde::{Deserialize, Serialize};
2
3use crate::protocol::EventId;
4use crate::protocol::utils::null_to_default;
5
6/// User feedback for an event as sent by the client to the userfeedback/userreport endpoint.
7///
8/// Historically the "schema" for user report has been "defined" as the set of possible
9/// keyword-arguments `sentry.models.UserReport` accepts. Anything the model constructor
10/// accepts goes.
11///
12/// For example, `{"email": null}` is only invalid because `UserReport(email=None).save()` is. SDKs
13/// may neither send this (historically, in Relay we relaxed this already), but more importantly
14/// the ingest consumer may never receive this... because it would end up crashing the ingest
15/// consumer (while in older versions of Sentry it would simply crash the endpoint).
16///
17/// The database/model schema is a bunch of not-null strings that have (pgsql) defaults, so that's
18/// how we end up with this struct definition.
19#[derive(Debug, Deserialize, Serialize)]
20pub struct UserReport {
21 /// The event ID for which this user feedback is created.
22 pub event_id: EventId,
23 /// The user's name.
24 #[serde(default, deserialize_with = "null_to_default")]
25 pub name: String,
26 /// The user's email address.
27 #[serde(default, deserialize_with = "null_to_default")]
28 pub email: String,
29 /// Comments supplied by the user.
30 #[serde(default, deserialize_with = "null_to_default")]
31 pub comments: String,
32}