Configuration

Learn about the User Feedback Form configuration options.

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

To collect user feedback from inside your application, use the showFeedbackForm method to present the form.

Copied
import * as Sentry from "@sentry/react-native";

Sentry.wrap(RootComponent);

Sentry.showFeedbackForm();

Note that the root application component must be wrapped with Sentry.wrap for this to work.

The following options can be configured for the integration in feedbackIntegration({}) or passed in the FeedbackForm component props:

KeyTypeDefaultDescription
showBrandingbooleantrueDisplays the Sentry logo.
showNamebooleantrueDisplays the name field on the feedback form.
showEmailbooleantrueDisplays the email field on the feedback form.
enableShakeToReportbooleanfalseOpens the Feedback Form when the user shakes the device.
enableScreenshotbooleanfalseAllows the user to send a screenshot attachment with their feedback.
enableTakeScreenshotbooleanfalseDetermines whether the "Take Screenshot" button is displayed.
isNameRequiredbooleanfalseRequires the name field on the feedback form to be filled in.
isEmailRequiredbooleanfalseRequires the email field on the feedback form to be filled in.
shouldValidateEmailbooleantrueIf set the email is validated with the following regular expression "/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/"
useSentryUserRecord<string, string>{ email: 'email', name: 'username'}Sets the default values for the email and name fields.

All the text that you see in the Feedback Form can be customized.

The following options can be configured for the integration in feedbackIntegration({}) or passed in the FeedbackForm component props:

KeyDefaultDescription
formTitle"Report a Bug"The title at the top of the feedback form.
submitButtonLabel"Send Bug Report"The label of the submit button used in the feedback form.
cancelButtonLabel"Cancel"The label of cancel buttons used in the feedback form.
addScreenshotButtonLabel"Add a screenshot"The label of the button to add a screenshot to the form.
removeScreenshotButtonLabel"Remove screenshot"The label of the button to remove the screenshot.
captureScreenshotButtonLabel"Take a screenshot"The label for the button that triggers the capture screenshot flow.
nameLabel"Name"The label of the name input field.
namePlaceholder"Your Name"The placeholder for the name input field.
emailLabel"Email"The label of the email input field.
emailPlaceholder"your.email@example.org"The placeholder for the email input field.
isRequiredLabel"(required)"The label shown next to an input field that is required.
messageLabel"Description"The label for the feedback description input field.
messagePlaceholder"What's the bug? What did you expect?"The placeholder for the feedback description input field.
successMessageText"Thank you for your report!"The message displayed after a successful feedback submission.
errorTitle"Error"The title of the error message dialog.
formError"Please fill out all required fields."Form validation error message.
emailError"Please enter a valid email address."Email validation error message.
genericError"Unable to send feedback due to an unexpected error."The generic error message.

Example of customization:

Copied
feedbackIntegration({
  nameLabel: "Full Name",
  submitButtonLabel: "Send",
  formTitle: "Give Feedback",
});

You can customize placement of the feedback components on the form, as well as the fonts and colors.

The example below shows how to customize the submit button background color and border radius with the feedbackIntegration.

Copied
import * as Sentry from "@sentry/react-native";

Sentry.feedbackIntegration({
  styles: {
    submitButton: {
      backgroundColor: "#6a1b9a",
      borderRadius: 5,
    },
  },
});

Sentry.showFeedbackForm();

The same can be achieved by passing the styles prop to the FeedbackForm component:

Copied
import { FeedbackForm } from "@sentry/react-native";

<FeedbackForm
  styles={{
    submitButton: {
      backgroundColor: "#6a1b9a",
      borderRadius: 5,
    },
  }}
/>;

The following styles are available for customisation.

StyleTypeDescription
containerViewStyleThe form container style.
titleTextStyleThe title text style.
labelTextStyleThe label text style (name, email).
inputTextStyleThe input field text style (name, email).
textAreaTextStyleThe message text style.
submitButtonViewStyleThe submit button style.
submitTextTextStyleThe submit button text style.
cancelButtonViewStyleThe cancel button style.
cancelTextTextStyleThe cancel button text style.
screenshotButtonViewStyleThe screenshot button style.
screenshotTextTextStyleThe screenshot button text style.
screenshotContainerTextStyleThe screenshot thumbnail container style.
screenshotThumbnailImageStyleThe screenshot thumbnail image style.
titleContainerViewStyleThe title container style.

The following callbacks can be configured for the integration in feedbackIntegration({}) or passed in the FeedbackForm component props:

CallbackParametersDefault behaviorDescription
onFormOpenCallback when form is opened.
onFormCloseThe form is unmounted.Callback when form is closed and not submitted.
onSubmitSuccessdata: FeedbackFormDataCallback when feedback is successfully submitted.
onSubmitErrorerror: ErrorCallback when feedback is unsuccessfully submitted.
onFormSubmittedThe form is unmounted.Callback when the feedback form is submitted successfully, and the SuccessMessage is complete, or dismissed.
onAddScreenshotaddScreenshot: (uri: string) => voidCallback when a screenshot is added.

The screenshot functionality is disabled by default. To enable it, pass an imagePicker integration library or set the enableScreenshot option to true and implement the onAddScreenshot callback.

Currently the supported libraries are:

You just need to import the library and pass it to the feedbackIntegration method.

Copied
import * as ImagePicker from "expo-image-picker";

Or react-native-image-picker:

Copied
import * as ImagePicker from "react-native-image-picker";

And then pass it to feedbackIntegration:

Copied
Sentry.init({
  integrations: [
    Sentry.feedbackIntegration({
      imagePicker: ImagePicker,
    }),
  ],
});

The imagePicker integration is used when launching the feedback form with showFeedbackForm. In order to use it with a custom FeedbackForm component, you need to pass the imagePicker prop to the component as shown below:

Copied
<FeedbackForm imagePicker={ImagePicker} />;

If the above libraries do not cover your use case you can manually integrate screenshots by implementing the onAddScreenshot callback. The callback receives the uri of the image like in the example below.

Copied
import * as Sentry from '@sentry/react-native';
import { getImage } from 'custom-image-picker';

const handleChooseImage = (addScreenshot: (uri: string) => void): void => {
  const { uri, error, canceled } = getImage();
  if (canceled) {
  	console.log('User canceled image choice.');
  } else if (error) {
    console.log('Error during image loading', error);
  } else {
    addScreenshot(uri);
  }
};

Sentry.feedbackIntegration({
    onAddScreenshot={handleChooseImage}
});

You can show a button that allows the user to take a screenshot in the Feedback Form. The button is shown when enableTakeScreenshot is set to true in the feedbackIntegration method like in the example below.

Copied
import * as Sentry from "@sentry/react-native";

Sentry.init({
  integrations: [
    Sentry.feedbackIntegration({
      enableTakeScreenshot: true,
      screenshotButtonOptions: {
        triggerLabel: "Take Screenshot",
        styles: {
          triggerButton: {
            marginBottom: 75,
          },
        },
      },
    }),
  ],
});

You can customize the Feedback Form screenshot button text with the following options.

KeyDefaultDescription
triggerLabel"Take Screenshot"The label for the Screenshot button.
triggerAriaLabel-The aria label for the Screenshot button.

The capture screenshot button can be customized too. The following styles are available.

StyleTypeDescription
triggerButtonViewStyleThe screenshot button style.
triggerTextTextStyleThe screenshot button text style.
triggerIconImageStyleThe screenshot button icon style.

You can also customize the Feedback Form colors to match your app's theme. The example below shows how to customize the form background and foreground for the light and dark system themes with the feedbackIntegration.

Copied
import * as Sentry from "@sentry/react-native";

Sentry.init({
  integrations: [
    Sentry.feedbackIntegration({
      colorScheme: "system",
      themeLight: {
        foreground: "#ff0000",
        background: "#00ff00",
      },
      themeDark: {
        foreground: "#00ff00",
        background: "#ff0000",
      },
    }),
  ],
});

The available theme options are:

KeyTypeDefaultDescription
colorScheme"system", "light", "dark""system"The color theme. "system" will use your OS color scheme.
themeLightFeedback Form Theme-The light color scheme.
themeDarkFeedback Form Theme-The dark color scheme.

For each theme you can set the following colors:

KeyDescription
backgroundBackground color for surfaces.
foregroundForeground color (i.e. text color).
accentForegroundForeground color for accented elements.
accentBackgroundBackground color for accented elements.
borderBorder color.
feedbackIconColor for feedback icon.
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").