|
| 1 | +--- |
| 2 | +title: Feedbacks |
| 3 | +sidebar_order: 4 |
| 4 | +--- |
| 5 | + |
| 6 | +This document is meant for Sentry SDK developers and maintainers of the Feedback ingestion pipeline. |
| 7 | + |
| 8 | +## Feedback Protocol |
| 9 | + |
| 10 | +Item type `"feedback"`. This Item contains an [event payload](/sdk/data-model/event-payloads/) encoded in JSON, with an additional `feedback` context object. |
| 11 | + |
| 12 | +## `"feedback"` Item |
| 13 | + |
| 14 | +### Feedback Context Attributes |
| 15 | + |
| 16 | +| Key | Type | Description | |
| 17 | +| ---------------------- | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 18 | +| message | string | Required. Comments of the user, describing what happened and/or sharing feedback. The max length is **4096 characters**. | |
| 19 | +| contact_email | string | The email of the user who submitted the feedback. If excluded, Sentry (not the SDK) attempts to fill this in with user context. Anonymous feedbacks (no name or email) are still accepted. | |
| 20 | +| name | string | The name of the user who submitted the feedback. If excluded, Sentry (not the SDK) attempts to fill this in with user context. Anonymous feedbacks (no name or email) are still accepted. | |
| 21 | +| 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. | |
| 22 | +| 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. | |
| 23 | +| 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. | |
| 24 | + |
| 25 | +### Event Attributes |
| 26 | + |
| 27 | +Below is a recap of the [required attributes](/sdk/data-model/event-payloads/#required-attributes) for the event payload. |
| 28 | +For the full list of attributes, see [Event Payloads](/sdk/data-model/event-payloads/). |
| 29 | + |
| 30 | +| Key | Type | Description | |
| 31 | +| -------------------------- | ------ | ----------------------------------------------- | |
| 32 | +| timestamp | number | UNIX timestamp of the current time (in seconds) | |
| 33 | +| event_id | string | Hexadecimal string representing a uuid4 value | |
| 34 | +| platform | string | Platform of the SDK | |
| 35 | + |
| 36 | +### Example |
| 37 | +```json |
| 38 | +{ |
| 39 | + "event_id": "9ec79c33ec9942ab8353589fcb2e04dc", |
| 40 | + "timestamp": "2011-05-02T17:41:36Z", |
| 41 | + "platform": "javascript", |
| 42 | + "contexts": { |
| 43 | + "feedback": { |
| 44 | + "contact_email": "[email protected]", |
| 45 | + "name": "John Smith", |
| 46 | + "message": "I love session replay!", |
| 47 | + "url": "https://sentry.io/replays/", |
| 48 | + "associated_event_id": "32fd1995636d446385016e2747623e11", |
| 49 | + "replay_id":"82840977e85b4ed3bc27f7b5b25cec15" |
| 50 | + } |
| 51 | + } |
| 52 | +} |
| 53 | +``` |
| 54 | + |
| 55 | +### Attaching Screenshots |
| 56 | + |
| 57 | +You can associate screenshots with a feedback by sending image data as |
| 58 | +[attachment items](/sdk/data-model/envelope-items/#attachment), with `event_id` |
| 59 | +corresponding to the feedback item. We recommend sending the items in the same |
| 60 | +Envelope. |
| 61 | + |
| 62 | +## Full Envelope Example |
| 63 | + |
| 64 | +```json |
| 65 | +{"event_id":"9ec79c33ec9942ab8353589fcb2e04dc","sent_at":"2024-03-19T15:18:27.581Z","sdk":{"name":"sentry.javascript.react","version":"7.105.0"}} |
| 66 | +{"type":"feedback"} |
| 67 | +{ |
| 68 | + "event_id": "9ec79c33ec9942ab8353589fcb2e04dc", |
| 69 | + "timestamp": "2011-05-02T17:41:36Z", |
| 70 | + "platform": "javascript", |
| 71 | + "contexts": { |
| 72 | + "organization": { "id": "0", "slug": "sentry" }, |
| 73 | + "feedback": { |
| 74 | + "contact_email": "[email protected]", |
| 75 | + "name": "John Smith", |
| 76 | + "message": "I love session replay!", |
| 77 | + "url": "https://sentry.io/replays/", |
| 78 | + "associated_event_id": "32fd1995636d446385016e2747623e11", |
| 79 | + "replay_id":"82840977e85b4ed3bc27f7b5b25cec15" |
| 80 | + } |
| 81 | + }, |
| 82 | + "level": "error", |
| 83 | + "environment": "prod", |
| 84 | + "release": "frontend@f00", |
| 85 | + "sdk": { |
| 86 | + "integrations": [ |
| 87 | + "BrowserTracing", |
| 88 | + "BrowserProfiling", |
| 89 | + "Replay", |
| 90 | + "ReplayCanvas" |
| 91 | + ], |
| 92 | + "name": "sentry.javascript.react", |
| 93 | + "version": "7.105.0" |
| 94 | + }, |
| 95 | + "tags": { |
| 96 | + "sentry_version": "24.4.0.dev0", |
| 97 | + }, |
| 98 | + "user": { |
| 99 | + "ip_address": "127.0.0.1", |
| 100 | + |
| 101 | + "id": 1, |
| 102 | + "name": "John Smith" |
| 103 | + } |
| 104 | +} |
| 105 | +``` |
| 106 | + |
| 107 | +## Feedback SDK Pipeline |
| 108 | + |
| 109 | +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. |
| 110 | + |
| 111 | +### BeforeSendFeedback |
| 112 | + |
| 113 | +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. |
| 114 | + |
| 115 | +### Scope Data and Event Processors |
| 116 | + |
| 117 | +The scope is applied to the feedbacks, including tags, user, trace and contexts. The scope’s _event processors_ are invoked, too. |
| 118 | + |
| 119 | +### Rate Limiting |
| 120 | + |
| 121 | +[Rate limiting](/sdk/expected-features/rate-limiting/) is applied to feedbacks in the same way as it is applied to events. |
| 122 | + |
| 123 | +### Dropped Feedback Reports |
| 124 | + |
| 125 | +There is no sample rate for feedbacks, as they are always sampled. However, a feedback can be discarded at any of the pipeline stages, for reasons like rate limiting or an invalid message (too large or empty). The SDK should report dropped feedbacks through [client reports](/sdk/telemetry/client-reports/). |
| 126 | + |
| 127 | +### Session Replay Integration |
| 128 | + |
| 129 | +When sending feedback, 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. |
0 commit comments