# Set Up User Feedback

## Learn more about collecting user feedback when an event occurs. Sentry pairs the feedback with the original event, giving you additional insight into issues.

When a user experiences an error, Sentry provides the ability to collect additional feedback. You can collect feedback according to the method supported by the SDK.

## [User Feedback API](#user-feedback-api)

The user feedback API allows you to collect user feedback while utilizing your own UI. You can use the same programming language you have in your app to send user feedback. In this case, the SDK creates the HTTP request so you don't have to deal with posting data via HTTP.

Sentry pairs the feedback with the original event, giving you additional insight into issues. Sentry needs the `eventId` to be able to associate the user feedback to the corresponding event. There are several ways to get the `eventId`:

* use [`beforeSend`](/platforms/dart/configuration/options/#before-send)
* use the return value of any method capturing an event.
* use `Sentry.lastEventId` to get the ID of the last event sent.

```dart
// Option 1: Retrieving SentryId from beforeSend
SentryId sentryId = SentryId.empty();

await Sentry.init((options) {
  options.beforeSend = (event, hint) {
    sentryId = event.eventId;
    return event;
  };
});

// Option 2: Retrieving SentryId from the method capturing the event
SentryId sentryId = Sentry.captureMessage("My message");

// Option 3: Retrieving SentryId from the beforeSend callback
SentryId sentryId = Sentry.lastEventId;

final feedback = SentryFeedback(
    message: 'Hello World!',
    contactEmail: 'foo@bar.org',
    name: 'John Doe',
    associatedEventId: sentryId,
);

Sentry.captureFeedback(feedback);
```
