Configure User Feedback

Learn about general User Feedback configuration fields.

The User Feedback Widget offers many customization options, and if the available options are insufficient, you can use your own UI.

The following options can be configured for the integration in SentryUserFeedbackConfiguration:

OptionTypeDefaultDescription
animationsBooltrueWhether or not to show animations, like for presenting and dismissing the form.
useShakeGestureBoolfalseUse a shake gesture to display the form.
showFormForScreenshotsBoolfalseAny time a user takes a screenshot, bring up the form with the screenshot attached.
tags[String: Any]nilTags to set on the feedback event. This is a dictionary where keys are strings and values can be different data types such as NSNumber, NSString, etc.

Some hooks are available so you can react to the user opening and closing the form, when the user successfully submits the form or when there is an error:

HookTypeDescription
onFormOpen() -> VoidCalled when the feedback form is opened.
onFormClose() -> VoidCalled when the feedback form is closed.
onSubmitSuccess([String: Any]) -> VoidCalled when feedback is successfully submitted via the prepared form.
onSubmitError(Error) -> VoidCalled when there is an error submitting feedback via the prepared form.

onSubmitSuccess provides a dictionary with the following keys:

  • message: The message the user entered in the feedback form.
  • name: The name the user entered in the feedback form.
  • email: The email the user entered in the feedback form.
  • attachments: An array of attachments to be included with the feedback; currently only one screenshot is supported.

Example:

Copied
SentrySDK.start { options in 
    options.showFormForScreenshots = true
    options.configureUserFeedback { config in
        config.onSubmitSuccess = { data in
            print("Feedback submitted successfully from \(data["name"]) at \(data["email"]): \(data["message"])")
        }
    }
}

The following options can be configured for the integration in SentryUserFeedbackWidgetConfiguration:

OptionTypeDefaultDescription
location[NSDirectionalRectEdge][.bottom, .trailing]The location of the widget on the screen.
autoInjectBooltrueInjects the Feedback widget into the application when the integration is added. Set autoInject: false if you want to call feedback.attachTo() or feedback.openDialog() directly, or only want to show the widget on certain views.
windowLevelUIWindow.LevelUIWindow.Level.normal + 1The window level of the widget.
showIconBooltrueWhether to show the widget icon.
labelTextString?"Report a Bug"The text of the widget label. If nil, then only the icon is shown. It is an error to set both labelText to nil and showIcon to false.
layoutUIOffsetUIOffsetUIOffset.zeroThe offset of the widget from edge(s) of the screen specified in location.

You can customize which form elements are shown, whether they are required, and even prefill some info, in SentryUserFeedbackFormConfiguration:

OptionTypeDefaultDescription
showBrandingBooltrueDisplays the Sentry logo inside of the form
formTitleString"Report a Bug"The title of the feedback form.
messageLabelString"Description"The label of the feedback description input field.
messagePlaceholderString"What's the bug? What did you expect?"The placeholder in the feedback description input field.
isRequiredLabelString"(Required)"The text to attach to the title label for a required field.
successMessageTextString"Screenshot"The label of the screenshot button.
removeScreenshotButtonLabelString"Remove Screenshot"The label of the remove screenshot button.
isNameRequiredBoolfalseRequires the name field on the feedback form to be filled in.
showNameBooltrueDisplays the name field on the feedback form. Ignored if isNameRequired is true.
nameLabelString"Name"The label next to the name input field.
namePlaceholderString"Your Name"The placeholder in the name input field.
isEmailRequiredBoolfalseRequires the email field on the feedback form to be filled in.
showEmailBooltrueDisplays the email field on the feedback form. Ignored if isEmailRequired is true.
emailLabelString"Email"The label next to the email input field.
emailPlaceholderString"your.email@example.org"The placeholder in the email input field.
submitButtonLabelString"Send Bug Report"The label of the submit button.
cancelButtonLabelString"Cancel"The label of the cancel button.
useSentryUserBooltrueSets the email and name fields to the corresponding Sentry SDK user fields that were called with SentrySDK.setUser.
isRequiredTextString(required)The text displayed next to a required field.

Example:

Copied
SentrySDK.start { options in 
    options.configureUserFeedback { config in
        config.configureForm { form in
            form.isRequiredText = "*"
            form.title = "We want to hear from you!"
            form.useSentryUser = false
        }
    }
}

Colors can be customized via the top-level config object, configuring for both light and dark themes.

OptionLightDarkDescription
backgroundrgb(255, 255, 255)rgb(41, 35, 47)Background color of the widget and form.
foregroundrgb(43, 34, 51)rgb(235, 230, 239)Foreground text color of the widget and form.
submitForegroundrgb(255, 255, 255)rgb(255, 255, 255)Foreground color for the form submit button.
submitBackgroundrgb(88, 74, 192)rgb(88, 74, 192)Background color for the form submit button.
buttonForegroundSame as foregroundSame as foregroundForeground color for the cancel and screenshot buttons.
buttonBackgroundUIColor.clearUIColor.clearBackground color for the form cancel and screenshot buttons.
errorColorrgb(223, 51, 56)rgb(245, 84, 89)Color used for error-related components.
inputBackgroundUIColor.secondarySystemBackgroundUIColor.secondarySystemBackgroundBackground color for form inputs.
inputForegroundUIColor.darkTextUIColor.lightTextForeground color for form inputs.

Form element outlines can be configured via the outlineStyle property. By default, the color is rgb(204, 204, 204), the width is 0.5, and the corner radius is 5.0.

Fonts can be directly customized, but by default they will scale with the user's preferred text size using predefined font styles:

OptionDefault Text StyleDescription
font"UIFontTextStyleCallout"The font family to use for form input elements and the widget button label.
headerFont"UIFontTextStyleTitle1"The font family to use for the main header title of the feedback form.
titleFont"UIFontTextStyleHeadline"The font family to use for titles of text fields and buttons in the form.

You can still configure the fontFamily setting and we will request an appropriately scaled font from the system.

Here is an example of customizing only the background color for the light theme using the Feedback constructor configuration:

Copied
SentrySDK.start { options in 
    options.configureUserFeedback { config in
        // configureTheme is used for light themes on iOS versions that support dark mode, and as the sole theme configuration for earlier iOS versions that don't support dark mode
        config.theme { theme in 
            theme.background = .init(color: .yellow)
        }
        config.darkTheme { theme in 
            theme.background = .init(color: .darkGray)
        }
    }
}

The Feedback widget is designed to be accessible, with a set of default accessibility labels that can be overriden. The following attributes are set to ensure the widget is accessible:

Configuration KeyDefault Value
widgetAccessibilityLabellabelText or, if that is nil, "Report a Bug"

Configuration KeyDefault Value
messageTextViewAccessibilityLabelmessagePlaceholder
removeScreenshotButtonAccessibilityLabelremoveScreenshotButtonLabel
nameTextFieldAccessibilityLabelnamePlaceholder
emailTextFieldAccessibilityLabel"Your email address"
submitButtonAccessibilityLabelsubmitButtonLabel
cancelButtonAccessibilityLabelcancelButtonLabel

Example:

Copied
SentrySDK.start { options in 
    options.configureUserFeedback { config in
        config.configureWidget { widget in
            widget.widgetAccessibilityLabel = "Report an Issue" // default: "Report a Bug"
        }
        config.configureForm { form in
            form.messageTextViewAccessibilityLabel = "What happened?" // default: "What's the bug? What did you expect?"
        }
    }
}

You can also use your own UI components to gather feedback and pass the feedback data object to the SentrySDK.capture(feedback: SentryFeedback) function.

Copied
SentrySDK.capture(feedback: .init(
    message: "This is an example feedback", // required
    name: "Jane Doe", // optional
    email: "email@example.org", // optional
    source: .custom,
    screenshot: somePngImageData // optional
));
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").