Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 53 additions & 93 deletions docs/platforms/android/user-feedback/configuration/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ sidebar_order: 6900
description: "Learn about general User Feedback configuration fields."
---

## User Feedback Widget
## User Feedback Form

The User Feedback Widget offers many customization options, and if the available options are insufficient, you can [use your own UI](#bring-your-own-widget).
The widget is a custom button that opens the form, a custom AlertDialog that allows users to submit feedback.
The User Feedback form offers many customization options, and if the available options are insufficient, you can [use your own UI](#bring-your-own-form).

### Hooks

Expand All @@ -28,14 +27,6 @@ There are hooks available so you can react when the user opens or closes the for

Example:

```java
SentryAndroid.init(context, options -> {
options.getFeedbackOptions().setOnFormOpen(() -> System.out.println("Form opened"));
options.getFeedbackOptions().setOnFormClose(() -> System.out.println("Form closed"));
options.getFeedbackOptions().setOnSubmitSuccess((feedback) -> System.out.println("Feedback submitted successfully: " + feedback.toString()));
options.getFeedbackOptions().setOnSubmitError((feedback) -> System.out.println("Failed to submit feedback: " + feedback.toString()));
});
```
```kotlin
SentryAndroid.init(this) { options ->
options.feedbackOptions.onFormOpen = Runnable { println("Form opened") }
Expand All @@ -48,44 +39,13 @@ SentryAndroid.init(this) { options ->
}
}
```

### Widget

The widget is a custom button that opens the feedback form. As such, you can treat it like any View, customizing it through its XML attributes or programmatically.
The default attributes of the widget are:

| Attribute | Default Value |
| -------------------------- | ------------------------------------------- |
| `android:drawablePadding` | `4dp` |
| `android:drawableStart` | `@drawable/baseline_campaign_24` |
| `android:textAllCaps` | `false` |
| `android:background` | `@drawable/oval_button_ripple_background` |
| `android:padding` | `12dp` |
| `android:textColor` | `?android:attr/colorForeground` |
| `android:text` | `"Report a Bug"` |

Example:
```xml {filename:myLayout.xml}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<io.sentry.android.core.SentryUserFeedbackButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
```
```java
import io.sentry.android.core.SentryUserFeedbackButton;

SentryUserFeedbackButton widget = new SentryUserFeedbackButton(context);
```
```kotlin
import io.sentry.android.core.SentryUserFeedbackButton

val widget = SentryUserFeedbackButton(context)
SentryAndroid.init(context, options -> {
options.getFeedbackOptions().setOnFormOpen(() -> System.out.println("Form opened"));
options.getFeedbackOptions().setOnFormClose(() -> System.out.println("Form closed"));
options.getFeedbackOptions().setOnSubmitSuccess((feedback) -> System.out.println("Feedback submitted successfully: " + feedback.toString()));
options.getFeedbackOptions().setOnSubmitError((feedback) -> System.out.println("Failed to submit feedback: " + feedback.toString()));
});
```

### Form Configuration
Expand Down Expand Up @@ -115,17 +75,6 @@ Example:
<meta-data android:name="io.sentry.feedback.use-shake-gesture" android:value="true" />
</application>
```
```java
SentryAndroid.init(context, options -> {
options.getFeedbackOptions().setNameRequired(true);
options.getFeedbackOptions().setShowName(false);
options.getFeedbackOptions().setEmailRequired(true);
options.getFeedbackOptions().setShowEmail(false);
options.getFeedbackOptions().setUseSentryUser(false);
options.getFeedbackOptions().setShowBranding(false);
options.getFeedbackOptions().setUseShakeGesture(true);
});
```
```kotlin
SentryAndroid.init(this) { options ->
options.feedbackOptions.isNameRequired = true
Expand All @@ -137,6 +86,17 @@ SentryAndroid.init(this) { options ->
options.feedbackOptions.isUseShakeGesture = true
}
```
```java
SentryAndroid.init(context, options -> {
options.getFeedbackOptions().setNameRequired(true);
options.getFeedbackOptions().setShowName(false);
options.getFeedbackOptions().setEmailRequired(true);
options.getFeedbackOptions().setShowEmail(false);
options.getFeedbackOptions().setUseSentryUser(false);
options.getFeedbackOptions().setShowBranding(false);
options.getFeedbackOptions().setUseShakeGesture(true);
});
```

### Form Label Customization

Expand All @@ -159,21 +119,6 @@ Note: manifest options are not supported here, due to internationalization:

Example:

```java
SentryAndroid.init(context, options -> {
options.getFeedbackOptions().setFormTitle("We want to hear from you!");
options.getFeedbackOptions().setMessageLabel("Feedback");
options.getFeedbackOptions().setMessagePlaceholder("Type your feedback");
options.getFeedbackOptions().setIsRequiredLabel(" *");
options.getFeedbackOptions().setSuccessMessageText("Thanks for the feedback!");
options.getFeedbackOptions().setNameLabel("Full Name");
options.getFeedbackOptions().setNamePlaceholder("Type your full name");
options.getFeedbackOptions().setEmailLabel("Email Address");
options.getFeedbackOptions().setEmailPlaceholder("Type your email");
options.getFeedbackOptions().setSubmitButtonLabel("Submit");
options.getFeedbackOptions().setCancelButtonLabel("Back");
});
```
```kotlin
SentryAndroid.init(this) { options ->
options.feedbackOptions.formTitle = "We want to hear from you!"
Expand All @@ -189,6 +134,21 @@ SentryAndroid.init(this) { options ->
options.feedbackOptions.cancelButtonLabel = "Back"
}
```
```java
SentryAndroid.init(context, options -> {
options.getFeedbackOptions().setFormTitle("We want to hear from you!");
options.getFeedbackOptions().setMessageLabel("Feedback");
options.getFeedbackOptions().setMessagePlaceholder("Type your feedback");
options.getFeedbackOptions().setIsRequiredLabel(" *");
options.getFeedbackOptions().setSuccessMessageText("Thanks for the feedback!");
options.getFeedbackOptions().setNameLabel("Full Name");
options.getFeedbackOptions().setNamePlaceholder("Type your full name");
options.getFeedbackOptions().setEmailLabel("Email Address");
options.getFeedbackOptions().setEmailPlaceholder("Type your email");
options.getFeedbackOptions().setSubmitButtonLabel("Submit");
options.getFeedbackOptions().setCancelButtonLabel("Back");
});
```

### Theme Customization

Expand All @@ -209,11 +169,11 @@ Here are the attributes used by the form:
The theme used by the form is the one set in the application theme as the `android:dialogTheme`.
A custom theme can be also set when instantiating it:

```java
SentryUserFeedbackDialog dialog = new SentryUserFeedbackDialog.Builder(context, R.style.MyAppDialogTheme).create();
```
```kotlin
val dialog = SentryUserFeedbackDialog.Builder(context, R.style.MyAppDialogTheme).create()
val form = SentryUserFeedbackForm.Builder(context, R.style.MyAppDialogTheme).create()
```
```java
SentryUserFeedbackForm form = new SentryUserFeedbackForm.Builder(context, R.style.MyAppDialogTheme).create();
```

Here is an example of how the feedback form can be customized:
Expand Down Expand Up @@ -255,22 +215,10 @@ Here is an example of how the feedback form can be customized:
</style>
```

### Bring Your Own Widget

You can also use your own UI components to gather feedback and pass the feedback data object to the `Sentry.captureFeedback(Feedback)` function:
### Bring Your Own Form

```java
import io.sentry.Sentry;
import io.sentry.protocol.Feedback;
You can also use your own UI components to gather feedback and pass the feedback data object to the `Sentry.feedback().capture(Feedback)` method:

Feedback feedback = new Feedback("I encountered a bug while using the app.");
feedback.setName("John Doe");
feedback.setContactEmail("john.doe@example.com");
// Optionally associate the feedback with an event
SentryId sentryId = Sentry.captureMessage("My message");
feedback.setAssociatedEventId(sentryId);
Sentry.captureFeedback(feedback);
```
```kotlin
import io.sentry.Sentry
import io.sentry.protocol.Feedback
Expand All @@ -281,5 +229,17 @@ feedback.contactEmail = "john.doe@example.com"
// Optionally associate the feedback with an event
val sentryId = Sentry.captureMessage("My message")
feedback.associatedEventId = sentryId
Sentry.captureFeedback(feedback)
Sentry.feedback().capture(feedback)
```
```java
import io.sentry.Sentry;
import io.sentry.protocol.Feedback;

Feedback feedback = new Feedback("I encountered a bug while using the app.");
feedback.setName("John Doe");
feedback.setContactEmail("john.doe@example.com");
// Optionally associate the feedback with an event
SentryId sentryId = Sentry.captureMessage("My message");
feedback.setAssociatedEventId(sentryId);
Sentry.feedback().capture(feedback);
```
Loading
Loading