Set Up User Feedback

Learn how to enable User Feedback in your Android app.

The User Feedback feature allows you to collect user feedback from anywhere inside your application at any time, without needing an error event to occur first.

The User Feedback form allows users to submit feedback from anywhere inside your application. For the configuration options, please refer to the User Feedback Form Configuration.

Copied
import io.sentry.Sentry

val sentryId = Sentry.captureMessage("My message") // You can optionally associate an event using its id
Sentry.feedback().show(sentryId) { options ->
  // The options set here will be applied to the current form only
  options.formTitle = "We want to hear from you!"
}

For more control over the form instance (custom theme, per-form configuration, etc.), use the Builder:

Copied
import io.sentry.Sentry
import io.sentry.android.core.SentryUserFeedbackForm

val sentryId = Sentry.captureMessage("My message")
val form = SentryUserFeedbackForm.Builder(activity)
    .associatedEventId(sentryId)
    .configurator { options ->
      options.formTitle = "We want to hear from you!"
    }
    .create()
form.show()

The User Feedback form integrates seamlessly with Session Replay. When the form is opened, the SDK buffers up to 30 seconds of the user's session. If feedback is submitted, this replay is sent along with the feedback, allowing you to view both the feedback and the user's actions leading up to the feedback submission.

You can enable shake-to-report so that shaking the device opens the User Feedback form. This uses the device's accelerometer and does not require any additional permissions.

Copied
SentryAndroid.init(this) { options ->
    options.feedbackOptions.isUseShakeGesture = true
}

If you only want shake-to-show for specific screens instead of globally, you can enable it on individual form instances using the Builder. This only works when global shake is disabled (the default).

Copied
import io.sentry.android.core.SentryUserFeedbackForm

val form = SentryUserFeedbackForm.Builder(activity)
    .configurator { it.isUseShakeGesture = true }
    .create()

The form will automatically start and stop shake detection based on the activity lifecycle.

The User Feedback API allows you to collect user feedback while using your own UI components. You can submit feedback directly using the Sentry.feedback().capture(Feedback) method.

Sentry can optionally pair this feedback with an event, giving you additional insight into issues. Sentry needs the eventId to be able to associate the user feedback to the corresponding event. For example, to get the eventId, you can use beforeSend, or the return value of the method capturing an event.

Copied
import io.sentry.Sentry
import io.sentry.protocol.Feedback

val feedback = Feedback("I encountered a bug while using the app.")
feedback.name = "John Doe"
feedback.contactEmail = "john.doe@example.com"
// Optionally associate the feedback with an event
val sentryId = Sentry.captureMessage("My message")
feedback.associatedEventId = sentryId
Sentry.feedback().capture(feedback)
Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").