Skip to content
62 changes: 2 additions & 60 deletions develop-docs/sdk/data-model/envelope-items.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -181,67 +181,9 @@ details.

### User Feedback

Item type `"feedback"`. This Item contains an [event payload](/sdk/data-model/event-payloads/) encoded in JSON, with an additional `feedback` context object.
Item type `"feedback"` contains an event with a feedback context in the payload encoded in JSON.

Example payload:
```json
{
"event_id": "9ec79c33ec9942ab8353589fcb2e04dc",
"timestamp": "2011-05-02T17:41:36Z",
"platform": "javascript",
"level": "error",
"contexts": {
"feedback": {
"contact_email": "[email protected]",
"name": "John Smith",
"message": "I love session replay!",
"url": "https://sentry.io/replays/",
"associated_event_id": "32fd1995636d446385016e2747623e11",
"replay_id":"82840977e85b4ed3bc27f7b5b25cec15"
}
}
}
```

**Payload Attributes**

We only document attributes for the `contexts.feedback` object, which is **required**
for this item type. For other attributes, see [Event Payloads](/sdk/data-model/event-payloads/).

`message`

: **String, required.** Comments of the user, describing what happened and/or sharing
feedback. The max length is **4096 characters**.

`contact_email`

: *String, optional.* The email of the user who submitted the feedback. If excluded, Sentry attempts to fill this in with user context. Anonymous feedbacks (no name or email) are still accepted.

`name`

: *String, optional.* The name of the user who submitted the feedback. If excluded, Sentry attempts to fill this in with user context. Anonymous feedbacks (no name or email) are still accepted.

`url`

: *String, optional.* The URL of the webpage the user was on when submitting feedback.
This may be used to search for or set alerts on feedback.

`associated_event_id`

: *UUID String, optional.* The identifier of an error event in the same project.
Use this to explicitly link a related error in the feedback UI.

`replay_id`

: *UUID String, optional.* The identifier of a related Session Replay in the same
project. Sentry uses this ID to render a Replay clip in the feedback UI.

**Attaching Screenshots:**

You can associate screenshots with a feedback by sending image data as
[attachment items](/sdk/data-model/envelope-items/#attachment), with `event_id`
corresponding to the feedback item. We recommend sending the items in the same
Envelope.
See the <Link to="/sdk/telemetry/feedbacks/">feedback</Link> documentation for the payload details.

**Constraints:**

Expand Down
3 changes: 2 additions & 1 deletion develop-docs/sdk/expected-features/rate-limiting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,12 @@ While these [data categories](https://github.com/getsentry/relay/blob/master/rel
- `attachment`: Attachment bytes stored (unused for rate limiting)
- `session`: Session update events
- `profile`: Profiling events
- `profile_chunk`: Continuous Profiling chunks
- `replay`: Session Replays
- `feedback`: User Feedbacks
- `metric_bucket`: Sentry Metrics sent via the `statsd` or `metrics` items. The `namespaces` component of the *quota_limit* defines which namespace(s) will be affected.
- `internal`: a sentry/system internal event[^internal]


- **Scope**: The unit / model in Sentry that quotas are enforced for.
- `organization`
- `project`
Expand Down
140 changes: 140 additions & 0 deletions develop-docs/sdk/telemetry/feedback.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
---
title: Feedbacks
sidebar_order: 4
---

This document is meant for Sentry SDK developers and maintainers of the Feedback ingestion pipeline.

## Feedback Protocol

Item type `"feedback"`. This Item contains an [event payload](/sdk/data-model/event-payloads/) encoded in JSON, with an additional `feedback` context object.

## `"feedback"` Item

### Feedback Context Attributes

| Key | Type | Description |
| ---------------------- | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| message | string | Required. Comments of the user, describing what happened and/or sharing feedback. The max length is **4096 characters**. |
| contact_email | string | The email of the user who submitted the feedback. If excluded, Sentry attempts to fill this in with user context. Anonymous feedbacks (no name or email) are still accepted. |
| name | string | The name of the user who submitted the feedback. If excluded, Sentry attempts to fill this in with user context. Anonymous feedbacks (no name or email) are still accepted. |
| url | string | The URL of the webpage the user was on when submitting feedback. This may be used to search for or set alerts on feedback. |
| associated_event_id | string | The identifier of an error event in the same project. Use this to explicitly link a related error in the feedback UI. |
| replay_id | string | The identifier of a related Session Replay in the same project. Sentry uses this ID to render a Replay clip in the feedback UI. |

### Event Event Attributes

For the full list of attributes, see [Event Payloads](/sdk/data-model/event-payloads/).

| Key | Type | Description |
| -------------------------- | ------ | ------------------------------------------------ |
| timestamp | number | UNIX timestamp of the current time (in seconds). |
| event_id | string | This should be the same as `replay_id` |
| dist | string | - |
| platform | string | - |
| environment | string | - |
| release | string | - |
| user.id | string | - |
| user.username | string | - |
| user.email | string | - |
| user.ip_address | string | - |
| sdk.name | string | - |
| sdk.version | string | - |
| request.url | string | - |
| request.headers.User-Agent | string | - |

### Example
```json
{
"event_id": "9ec79c33ec9942ab8353589fcb2e04dc",
"timestamp": "2011-05-02T17:41:36Z",
"platform": "javascript",
"level": "error",
"contexts": {
"feedback": {
"contact_email": "[email protected]",
"name": "John Smith",
"message": "I love session replay!",
"url": "https://sentry.io/replays/",
"associated_event_id": "32fd1995636d446385016e2747623e11",
"replay_id":"82840977e85b4ed3bc27f7b5b25cec15"
}
}
}
```

### Attaching Screenshots

You can associate screenshots with a feedback by sending image data as
[attachment items](/sdk/data-model/envelope-items/#attachment), with `event_id`
corresponding to the feedback item. We recommend sending the items in the same
Envelope.

## Full Envelope Example

```json
{"event_id":"9ec79c33ec9942ab8353589fcb2e04dc","sent_at":"2024-03-19T15:18:27.581Z","sdk":{"name":"sentry.javascript.react","version":"7.105.0"}}
{"type":"feedback"}
{
"event_id": "9ec79c33ec9942ab8353589fcb2e04dc",
"timestamp": "2011-05-02T17:41:36Z",
"platform": "javascript",
"level": "error",
"contexts": {
"organization": { "id": "0", "slug": "sentry" },
"feedback": {
"contact_email": "[email protected]",
"name": "John Smith",
"message": "I love session replay!",
"url": "https://sentry.io/replays/",
"associated_event_id": "32fd1995636d446385016e2747623e11",
"replay_id":"82840977e85b4ed3bc27f7b5b25cec15"
}
},
"environment": "prod",
"release": "frontend@f00",
"sdk": {
"integrations": [
"BrowserTracing",
"BrowserProfiling",
"Replay",
"ReplayCanvas"
],
"name": "sentry.javascript.react",
"version": "7.105.0"
},
"tags": {
"sentry_version": "24.4.0.dev0",
},
"user": {
"ip_address": "127.0.0.1",
"email": "[email protected]",
"id": 1,
"name": "Admin"
}
}
```

## Feedback SDK Pipeline

A feedback captured by capture_feedback is processed by the SDK. Note: The event can be discarded at any of the stages, at which point no further processing happens.

### BeforeSendFeedback

SDKs should implement a `beforeSendFeedback` callback to allow users to modify the feedback before it is sent. This callback should be similar to the existing [`beforeSend`](/sdk/expected-features/#before-send-hook) callback used for events.

### Scope Data and Event Processors

The scope is applied to the feedbacks, including tags, attachments, and trace context. The scope’s _event processors_ are invoked, too.

### Rate Limiting

[Rate limiting](/sdk/expected-features/rate-limiting/) is applied to feedbacks in the same way as it is applied to events.

### Dropped feedback reports

There is no sample rate for feedbacks, as they are always sampled. However, a feedback can be discarded at any of the pipeline stages. The SDK should report dropped feedbacks through [client reports](/sdk/telemetry/client-reports/).

### Session Replay Integration

SDKs are expected to flush the current Session Replay, if running. This ensures a meaningful replay recording exists and can be included in the `replay_id` attribute of the feedback context.
Loading