Set Up User Feedback
Learn how to enable User Feedback in your Cocoa 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.
If you're using a self-hosted Sentry instance, you'll need to be on version 24.4.2 or higher in order to use the full functionality of the User Feedback feature. Lower versions may have limited functionality.
The User Feedback widget allows users to submit feedback from anywhere inside your application.
Ensure that your project is set up with Sentry and that you have added the Sentry Cocoa SDK to your project.
- Install the Sentry Cocoa SDK using CocoaPods, Carthage, or Swift Package Manager.
- Ensure you are using version 8.35.0 or above of the SDK to access the latest features.
To start using the User Feedback widget in your Cocoa application, enable the feedback integration and provide an optional configuration in your SentryOptions when starting the SDK:
SentrySDK.start { options in
options.configureUserFeedback = { config in
config.onSubmitSuccess = { data in
print("Feedback submitted successfully: \(data)")
}
config.onSubmitError = { error in
print("Failed to submit feedback: \(error)")
}
}
}
This setup will insert the widget into your app's view hierarchy. By default, it appears in the bottom trailing corner of the screen, but you can fully customize its appearance and behavior.
You can customize the widget by setting various properties in the instance of SentryUserFeedbackConfiguration
provided by SentryOptions.configureUserFeedback
:
let widgetConfig = SentryUserFeedbackWidgetConfiguration()
widgetConfig.triggerLabel = "Feedback"
widgetConfig.triggerAccessibilityLabel = "Submit Feedback"
// Form customization
let formConfig = SentryUserFeedbackFormConfiguration()
formConfig.showName = false
formConfig.isNameRequired = false
formConfig.enableScreenshot = true
formConfig.formTitle = "Report an Issue"
formConfig.submitButtonLabel = "Submit"
formConfig.cancelButtonLabel = "Cancel"
let feedbackConfig = SentryUserFeedbackConfiguration { config in
config.widgetConfig = widgetConfig
config.uiFormConfig = formConfig
}
let feedbackIntegration = SentryUserFeedbackIntegration(configuration: feedbackConfig)
feedbackIntegration.createWidget()
This configuration customizes the widget's button text, form fields, and whether the user can attach screenshots.
The User Feedback widget integrates seamlessly with Session Replay. When the widget is opened, the Replay 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.
The User Feedback API allows you to collect user feedback while using your own UI components. You can submit feedback directly using the captureFeedback
method in the SentryUserFeedbackIntegration
class:
feedbackIntegration.captureFeedback(
message: "I encountered a bug while using the app.",
name: "John Doe",
email: "john.doe@example.com",
hints: ["page": "Settings"]
)
This method associates the feedback with the corresponding event in Sentry, giving you valuable insights into user issues.
Alternatively, you can use the User Feedback API endpoint directly if you prefer to handle the HTTP request manually.
The Cocoa-based Crash-Report Modal is a customizable feature that prompts users for feedback when an error occurs. This modal captures the user's name, email, and a description of the issue, pairing the feedback with the event in Sentry.
To integrate the Crash-Report Modal in your Cocoa app, configure it in your Sentry initialization:
SentrySDK.showReportDialog(eventId: eventId) {
print("Crash report dialog shown")
}
This will display a modal dialog where users can provide feedback related to a specific error event.
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").