Skip to content

Commit c924f0d

Browse files
authored
feat(feedback): document new feedback envelope format and rename old format (#12188)
* feat(feedback): document new feedback envelope format and rename old format * Attachments note * Doc max message length * Review comments - rewording and rm max screenshots
1 parent 8e1a6a5 commit c924f0d

File tree

3 files changed

+108
-21
lines changed

3 files changed

+108
-21
lines changed

develop-docs/application-architecture/feedback-architecture.mdx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ It will:
1111

1212
## Creation sources
1313

14-
When broken down, there are **5** ways to create feedback in our system 😵‍💫.
15-
(But 4 of them, related to user reports, are quite similar!) A good reference is the
14+
When broken down, there are **4** ways to create feedback in our system, with
15+
3 sharing the same data model. A good reference is the
1616
`FeedbackCreationSource(Enum)` in [create_feedback.py](https://github.com/getsentry/sentry/blob/2b642e149c79b251e1c2f4339fc73d656347d74e/src/sentry/feedback/usecases/create_feedback.py#L33-L33).
1717
The 4 ways _clients_ can create feedback are:
1818

19-
`NEW_FEEDBACK_ENVELOPE`: [The new format](https://develop.sentry.dev/sdk/data-model/envelopes/#full-examples) created by the Replay team when adding
19+
`NEW_FEEDBACK_ENVELOPE`: [The new format](/sdk/data-model/envelope-items/#user-feedback) created by the Replay team when adding
2020
the [User Feedback Widget](https://docs.sentry.io/product/user-feedback/#user-feedback-widget)
2121
to the JavaScript SDK. It allows adding more information, for example tags,
2222
release, url, etc.
2323

24-
`USER_REPORT_ENVELOPE`: [The older format](https://develop.sentry.dev/sdk/data-model/envelope-items/#user-feedback) with name/email/comments, that requires
24+
`USER_REPORT_ENVELOPE`: [The older format](/sdk/data-model/envelope-items/#user-report) with name/email/comments, that requires
2525
`event_id` to link a Sentry error event.
2626

2727
`USER_REPORT_DJANGO_ENDPOINT`: [The deprecated Web API](https://docs.sentry.io/api/projects/submit-user-feedback/)
@@ -31,7 +31,7 @@ release, url, etc.
3131
## How feedback is stored
3232

3333
On the backend, each feedback submission in Sentry's UI is **an un-grouped issue occurrence**,
34-
saved via the [issues platform](https://develop.sentry.dev/issue-platform/).
34+
saved via the [issues platform](/issue-platform/).
3535
The entrypoint is [**`create_feedback_issue()`**](https://github.com/getsentry/sentry/blob/2b642e149c79b251e1c2f4339fc73d656347d74e/src/sentry/feedback/usecases/create_feedback.py#L184-L184),
3636
which
3737

@@ -42,7 +42,7 @@ which
4242

4343
## Feedback events
4444

45-
The new and preferred way to send feedback from the SDK is in an [event envelope](https://develop.sentry.dev/sdk/data-model/envelopes/#full-examples).
45+
The preferred way of sending feedback from the SDK is in [feedback envelope](/sdk/data-model/envelope-items/#user-feedback).
4646
The format is the same as error events, except the `type` header = `"feedback"`. While
4747
user reports have an associated event, **new feedback _is_ an event**. This
4848
offers 2 improvements:
@@ -94,7 +94,7 @@ In Relay v24.5.1, we migrated feedback to its own kafka topic + consumer,
9494
### Attachments
9595

9696
We only use attachments for the widget’s screenshot feature, which allows users
97-
to submit **at most 1 screenshot per feedback**. Attachments are another [item type](https://develop.sentry.dev/sdk/data-model/envelopes/#attachment)
97+
to submit **at most 1 screenshot per feedback**. Attachments are another [item type](/sdk/data-model/envelopes/#attachment)
9898
in an envelope.
9999

100100
- SDK v8.0.0+, Relay v24.5.1+: Sends the feedback and attachment items in the same envelope.
@@ -186,9 +186,7 @@ graph TD
186186

187187
### Envelopes
188188

189-
User reports are also sent to Relay in [envelope format](https://develop.sentry.dev/sdk/data-model/envelope-items/#user-feedback).
190-
**This item type is misleadingly called “user feedback” in some of our docs, but the
191-
item header will read `"user_report"`.**
189+
User reports are also sent to Relay in envelope format, item type [user_report](/sdk/data-model/envelope-items/#user-report).
192190

193191
The SDK function that sends these is `captureUserFeedback`.
194192

develop-docs/sdk/data-model/envelope-items.mdx

Lines changed: 99 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The headers described in this section are **in addition to the common headers**.
1616

1717
### Event
1818

19-
Item type `"event"`. This Item contains an error or default event payload
19+
Item type `"event"`. This Item contains an error or default [event payload](/sdk/data-model/event-payloads/)
2020
encoded in JSON.
2121

2222
**Constraints:**
@@ -181,18 +181,101 @@ details.
181181

182182
### User Feedback
183183

184-
User Feedback was called User Report in the beginning. Therefore the envelope item type is `"user_report"`.
185-
The item contains a user feedback / user report JSON payload:
184+
Item type `"feedback"`. This Item contains an [event payload](/sdk/data-model/event-payloads/) encoded in JSON, with an additional `feedback` context object.
185+
186+
Example payload:
186187
```json
187-
{"event_id":"9ec79c33ec9942ab8353589fcb2e04dc","email":"[email protected]","name":"John Me","comments":"It broke."}\n
188+
{
189+
"event_id": "9ec79c33ec9942ab8353589fcb2e04dc",
190+
"timestamp": "2011-05-02T17:41:36Z",
191+
"platform": "javascript",
192+
"level": "error",
193+
"contexts": {
194+
"feedback": {
195+
"contact_email": "[email protected]",
196+
"name": "John Smith",
197+
"message": "I love session replay!",
198+
"url": "https://sentry.io/replays/",
199+
"associated_event_id": "32fd1995636d446385016e2747623e11",
200+
"replay_id":"82840977e85b4ed3bc27f7b5b25cec15"
201+
}
202+
}
203+
}
188204
```
189205

190-
**Attributes**
206+
**Payload Attributes**
207+
208+
We only document attributes for the `contexts.feedback` object, which is **required**
209+
for this item type. For other attributes, see [Event Payloads](/sdk/data-model/event-payloads/).
210+
211+
`message`
212+
213+
: **String, required.** Comments of the user, describing what happened and/or sharing
214+
feedback. The max length is **4096 characters**.
215+
216+
`contact_email`
217+
218+
: *String, recommended.* The email of the user who submitted the feedback.
219+
220+
`name`
221+
222+
: *String, optional.* The name of the user who submitted the feedback.
223+
224+
`url`
225+
226+
: *String, optional.* The URL of the webpage the user was on when submitting feedback.
227+
This may be used to search for or set alerts on feedback.
228+
229+
`associated_event_id`
230+
231+
: *UUID String, optional.* The identifier of an error event in the same project.
232+
Use this to explicitly link a related error in the feedback UI.
233+
234+
`replay_id`
235+
236+
: *UUID String, optional.* The identifier of a related Session Replay in the same
237+
project. Sentry uses this ID to render a Replay clip in the feedback UI.
238+
239+
**Attaching Screenshots:**
240+
241+
You can associate screenshots with a feedback by sending image data as
242+
[attachment items](/sdk/data-model/envelope-items/#attachment), with `event_id`
243+
corresponding to the feedback item. We recommend sending the items in the same
244+
Envelope.
245+
246+
**Constraints:**
247+
248+
- This Item may occur at most once per Envelope.
249+
- This Item is mutually exclusive with `"transaction"` items.
250+
251+
**Required Envelope Headers:**
191252

192253
`event_id`
193254

194-
: **UUID String, required.** The identifier of the event or transaction.
255+
: **UUID String, required.** Corresponds to the `event_id` field of the event
256+
payload. **It is not equal to the `associated_event_id`** field in the feedback
257+
context. Clients are required to generate an event identifier ahead of time
258+
and set it at least in the Envelope headers. If the identifier mismatches
259+
between the Envelope and payload, the Envelope header takes precedence.
260+
261+
### User Report
195262

263+
Item type `"user_report"`. This is an older way of submitting user feedback we
264+
are in the process of deprecating. It works by associating user information and
265+
comments with an event. If both the item and its associated event are accepted,
266+
we convert it to a user feedback.
267+
268+
The item contains a JSON payload like this:
269+
```json
270+
{"event_id":"9ec79c33ec9942ab8353589fcb2e04dc","email":"[email protected]","name":"John Me","comments":"It broke."}\n
271+
```
272+
273+
**Payload Attributes**
274+
275+
`event_id`
276+
277+
: **UUID String, required.** The identifier of the associated event, ideally
278+
an error.
196279

197280
`email`
198281

@@ -204,19 +287,25 @@ The item contains a user feedback / user report JSON payload:
204287

205288
`comments`
206289

207-
: *String, recommended.* Comments of the user about what happened.
290+
: *String, recommended.* Comments of the user about what happened. The max length is **4096 characters**.
208291

209292
**Constraints:**
210293

211294
- This Item may occur once per Envelope.
212-
- User Feedbacks / Reports can be ingested separately from their events. We recommended to
213-
send them in the same Envelope.
295+
- User Reports can be ingested separately from their events. However, we recommend
296+
sending them in the same Envelope.
297+
- You may not associate multiple User Reports to the same event.
298+
- The event can not be more than 30 minutes old.
299+
- If the event does not exist in the same project or was never ingested, the report
300+
is discarded and never converted to feedback.
214301

215302
**Envelope Headers:**
216303

217304
`event_id`
218305

219-
: **UUID String, required.** The identifier of the event or transaction.
306+
: **UUID String, required.** Corresponds to the `event_id` field of the payload.
307+
If the identifier mismatches between the Envelope and payload, the Envelope
308+
header takes precedence.
220309

221310
**Additional Item Headers:**
222311

develop-docs/sdk/expected-features/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Ability to get the ID of the last event sent. Event IDs are useful for correlati
147147

148148
## User Feedback
149149

150-
For all SDKs, it is strongly recommended to send the `User Feedback` as an [envelope item](/sdk/data-model/envelope-items/#user-feedback). Alternatively, the SDKs can
150+
For all SDKs, it is strongly recommended to send the `User Feedback` as an [envelope item](/sdk/data-model/envelope-items/#user-report). Alternatively, the SDKs can
151151
use the [User Feedback endpoint](https://docs.sentry.io/api/projects/submit-user-feedback/), which is not recommended.
152152

153153
### User Facing Platforms

0 commit comments

Comments
 (0)