Skip to content

Commit 6ddaffa

Browse files
committed
feat(feedback): document new feedback envelope format and rename old format
1 parent 764e66f commit 6ddaffa

File tree

3 files changed

+99
-20
lines changed

3 files changed

+99
-20
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: 90 additions & 9 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,93 @@ 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 feedback.
214+
215+
`contact_email`
216+
217+
: *String, recommended.* The email of the user.
218+
219+
`name`
220+
221+
: *String, optional.* The name of the user.
222+
223+
`url`
224+
225+
: *String, optional.* The URL of the referring webpage which may be used to search
226+
for or set alerts on feedback.
227+
228+
`associated_event_id`
229+
230+
: *UUID String, optional.* The identifier of an error event in the same project.
231+
Use this to explicitly link a related error in the feedback UI.
232+
233+
`replay_id`
234+
235+
: *UUID String, optional.* The identifier of a related session replay in the same
236+
project. Sentry uses this ID to render a replay clip in the feedback UI.
237+
238+
**Constraints:**
239+
240+
- This Item may occur at most once per Envelope.
241+
- This Item is mutually exclusive with `"transaction"` Items.
242+
243+
**Required Envelope Headers:**
191244

192245
`event_id`
193246

194-
: **UUID String, required.** The identifier of the event or transaction.
247+
: **UUID String, required.** Corresponds to the `event_id` field of the event
248+
payload. **It is not equal to the `associated_event_id`** field in the feedback
249+
context. Clients are required to generate an event identifier ahead of time
250+
and set it at least in the Envelope headers. If the identifier mismatches
251+
between the Envelope and payload, the Envelope header takes precedence.
252+
253+
### User Report
195254

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

197272
`email`
198273

@@ -209,14 +284,20 @@ The item contains a user feedback / user report JSON payload:
209284
**Constraints:**
210285

211286
- 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.
287+
- User Reports can be ingested separately from their events. However, we recommend
288+
sending them in the same Envelope.
289+
- You may not associate multiple User Reports to the same event.
290+
- The event can not be more than 30 minutes old.
291+
- If the event does not exist in the same project or was never ingested, the report
292+
is discarded and never converted to feedback.
214293

215294
**Envelope Headers:**
216295

217296
`event_id`
218297

219-
: **UUID String, required.** The identifier of the event or transaction.
298+
: **UUID String, required.** Corresponds to the `event_id` field of the payload.
299+
If the identifier mismatches between the Envelope and payload, the Envelope
300+
header takes precedence.
220301

221302
**Additional Item Headers:**
222303

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)