Beta SDK

Learn about general User Feedback configuration fields for version TBD of the sentry-cocoa SDK.

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:

KeyTypeDefaultDescription
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.
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.
useSentryUserBoolfalseSets the email and name field text content to SentryUser.email and SentryUser.name.

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

KeyTypeDefaultDescription
showBrandingBooltrueDisplays the Sentry logo inside of the form
showNameBooltrueDisplays the name field on the feedback form.
showEmailBooltrueDisplays the email field on the feedback form.
isNameRequiredBoolfalseRequires the name field on the feedback form to be filled in.
isEmailRequiredBoolfalseRequires the email field on the feedback form to be filled in.
useSentryUserBooltrueSets the email and name fields to the corresponding Sentry SDK user fields that were called with Sentry.setUser.

Example:

Copied
SentrySDK.start { options in 
    options.configureForm { form in
        form.isEmailRequired = true
        form.useSentryUser = false
    }
}

Most text that you see in the default Feedback widget can be customized via SentryUserFeedbackThemeConfiguration:

KeyDefaultDescription
submitButtonLabelSend Bug ReportThe label of the submit button used in the feedback form.
cancelButtonLabelCancelThe label of the cancel button used in the feedback form.
formTitleReport a BugThe title at the top of the feedback form.
nameLabelNameThe label of the name input field.
namePlaceholderYour NameThe placeholder for the name input field.
emailLabelEmailThe label of the email input field.
emailPlaceholderyour.email@example.orgThe placeholder for the email input field.
messageLabelDescriptionThe label for the feedback description input field.
messagePlaceholderWhat's the bug? What did you expect?The placeholder for the feedback description input field.
successMessageTextThank you for your report!The message to be displayed after a successful feedback submission.
isRequiredText(required)The text displayed next to a required field.

Example of customization:

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

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

KeyCSS VariableLightDarkDescription
foreground--foreground#2b2233#ebe6efForeground text color of the widget and form.
background--background#ffffff#29232fBackground color of the widget and form.
submitForeground--submit-foreground#ffffff#ffffffForeground color for the form submit button.
submitBackground--submit-backgroundrgba(88, 74, 192, 1)rgba(88, 74, 192, 1)Background color for the form submit button.
buttonForeground--cancel-foregroundSame as foregroundSame as foregroundForeground color for the cancel and screenshot buttons.
buttonBackground--cancel-backgroundtransparenttransparentBackground color for the form cancel and screenshot buttons.
successColor--success#268d75#2da98cColor used for success-related components.
errorColor--error#df3338#f55459Color used for error-related components.
inputBackground--input-backgroundinheritinheritBackground color for form inputs.
inputForeground--input-foregroundinheritinheritForeground color for form inputs.

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.configureTheme { theme in 
            theme.background = .init(color: .yellow)
        }
        config.configureDarkTheme { theme in 
            theme.background = .init(color: .darkGray)
        }
    }
}

These are additional CSS variables that can be overridden, similar to the theme customization above. They're not supported in the constructor.

VariableDefaultDescription
SentryUserFeedbackWidgetConfiguration.location[NSDirectionalRectEdge.bottom, NSDirectionalRectEdge.trailing]By default, the widget has a appears in the bottom trailing corner.
SentryUserFeedbackWidgetConfiguration.windowLevelUIWindow.Level.normal + 1The window level of the widget button.
SentryUserFeedbackFormConfiguration.fontFamilynilThe font family to use for form text elements. Defaults to the system font.

Because it's sometimes useful to know when a user started interacting with the feedback form, we've made it possible for you to add custom logging, or start and stop background timers on the page that tell you when the user is done.

Set these callbacks in SentryUserFeedbackConfiguration:

| Key | Type | Default | Description | | onFormOpen | () -> Void | nil | Called when the feedback form is opened. | | onFormClose | () -> Void | nil | Called when the feedback form is closed. | | onSubmitSuccess | ([String: Any]) -> Void | nil | Called when feedback is successfully submitted via the prepared form. | | onSubmitError | (Error) -> Void | nil | Called when there is an error submitting feedback via the prepared form. |

You can use your own button instead of the default injected button to trigger the form being displayed, by calling SentrySDK.showUserFeedbackForm() from your button's action handler.

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
));
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").