1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use serde::{Deserialize, Serialize};

use crate::protocol::utils::null_to_default;
use crate::protocol::EventId;

/// User feedback for an event as sent by the client to the userfeedback/userreport endpoint.
///
/// Historically the "schema" for user report has been "defined" as the set of possible
/// keyword-arguments `sentry.models.UserReport` accepts. Anything the model constructor
/// accepts goes.
///
/// For example, `{"email": null}` is only invalid because `UserReport(email=None).save()` is. SDKs
/// may neither send this (historically, in Relay we relaxed this already), but more importantly
/// the ingest consumer may never receive this... because it would end up crashing the ingest
/// consumer (while in older versions of Sentry it would simply crash the endpoint).
///
/// The database/model schema is a bunch of not-null strings that have (pgsql) defaults, so that's
/// how we end up with this struct definition.
#[derive(Debug, Deserialize, Serialize)]
pub struct UserReport {
    /// The event ID for which this user feedback is created.
    pub event_id: EventId,
    /// The user's name.
    #[serde(default, deserialize_with = "null_to_default")]
    pub name: String,
    /// The user's email address.
    #[serde(default, deserialize_with = "null_to_default")]
    pub email: String,
    /// Comments supplied by the user.
    #[serde(default, deserialize_with = "null_to_default")]
    pub comments: String,
}