Skip to content

Commit d01688a

Browse files
romtsnclaude
andauthored
chore(android): Update feedback docs to use new Sentry.feedback() API (#17631)
Switch all Android user feedback documentation from the old `showUserFeedbackDialog`/`captureFeedback` APIs to the new `Sentry.feedback().show()` and `Sentry.feedback().capture()` entry points. Drop the `SentryUserFeedbackButton` widget section and rename `SentryUserFeedbackDialog` references to `SentryUserFeedbackForm`. **New API examples** All code examples now use `Sentry.feedback()` as the entry point — `show()` for displaying the built-in form and `capture()` for submitting feedback from custom UI. **Builder-based custom form** Added a "Custom Form" subsection showing `SentryUserFeedbackForm.Builder` for full control over theme, associated event, and per-form options. **Per-form shake-to-show** Added documentation for enabling shake detection on individual form instances via `Builder.configurator { it.isUseShakeGesture = true }`, as an alternative to the global shake setting. Depends on getsentry/sentry-java#5353 and getsentry/sentry-java#5366. Closes getsentry/sentry-java#5306 --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 62e4a58 commit d01688a

4 files changed

Lines changed: 163 additions & 179 deletions

File tree

docs/platforms/android/user-feedback/configuration/index.mdx

Lines changed: 53 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ sidebar_order: 6900
44
description: "Learn about general User Feedback configuration fields."
55
---
66

7-
## User Feedback Widget
7+
## User Feedback Form
88

9-
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).
10-
The widget is a custom button that opens the form, a custom AlertDialog that allows users to submit feedback.
9+
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).
1110

1211
### Hooks
1312

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

2928
Example:
3029

31-
```java
32-
SentryAndroid.init(context, options -> {
33-
options.getFeedbackOptions().setOnFormOpen(() -> System.out.println("Form opened"));
34-
options.getFeedbackOptions().setOnFormClose(() -> System.out.println("Form closed"));
35-
options.getFeedbackOptions().setOnSubmitSuccess((feedback) -> System.out.println("Feedback submitted successfully: " + feedback.toString()));
36-
options.getFeedbackOptions().setOnSubmitError((feedback) -> System.out.println("Failed to submit feedback: " + feedback.toString()));
37-
});
38-
```
3930
```kotlin
4031
SentryAndroid.init(this) { options ->
4132
options.feedbackOptions.onFormOpen = Runnable { println("Form opened") }
@@ -48,44 +39,13 @@ SentryAndroid.init(this) { options ->
4839
}
4940
}
5041
```
51-
52-
### Widget
53-
54-
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.
55-
The default attributes of the widget are:
56-
57-
| Attribute | Default Value |
58-
| -------------------------- | ------------------------------------------- |
59-
| `android:drawablePadding` | `4dp` |
60-
| `android:drawableStart` | `@drawable/baseline_campaign_24` |
61-
| `android:textAllCaps` | `false` |
62-
| `android:background` | `@drawable/oval_button_ripple_background` |
63-
| `android:padding` | `12dp` |
64-
| `android:textColor` | `?android:attr/colorForeground` |
65-
| `android:text` | `"Report a Bug"` |
66-
67-
Example:
68-
```xml {filename:myLayout.xml}
69-
<?xml version="1.0" encoding="utf-8"?>
70-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
71-
android:layout_width="match_parent"
72-
android:layout_height="match_parent"
73-
android:orientation="vertical">
74-
75-
<io.sentry.android.core.SentryUserFeedbackButton
76-
android:layout_width="wrap_content"
77-
android:layout_height="wrap_content"/>
78-
</LinearLayout>
79-
```
8042
```java
81-
import io.sentry.android.core.SentryUserFeedbackButton;
82-
83-
SentryUserFeedbackButton widget = new SentryUserFeedbackButton(context);
84-
```
85-
```kotlin
86-
import io.sentry.android.core.SentryUserFeedbackButton
87-
88-
val widget = SentryUserFeedbackButton(context)
43+
SentryAndroid.init(context, options -> {
44+
options.getFeedbackOptions().setOnFormOpen(() -> System.out.println("Form opened"));
45+
options.getFeedbackOptions().setOnFormClose(() -> System.out.println("Form closed"));
46+
options.getFeedbackOptions().setOnSubmitSuccess((feedback) -> System.out.println("Feedback submitted successfully: " + feedback.toString()));
47+
options.getFeedbackOptions().setOnSubmitError((feedback) -> System.out.println("Failed to submit feedback: " + feedback.toString()));
48+
});
8949
```
9050

9151
### Form Configuration
@@ -115,17 +75,6 @@ Example:
11575
<meta-data android:name="io.sentry.feedback.use-shake-gesture" android:value="true" />
11676
</application>
11777
```
118-
```java
119-
SentryAndroid.init(context, options -> {
120-
options.getFeedbackOptions().setNameRequired(true);
121-
options.getFeedbackOptions().setShowName(false);
122-
options.getFeedbackOptions().setEmailRequired(true);
123-
options.getFeedbackOptions().setShowEmail(false);
124-
options.getFeedbackOptions().setUseSentryUser(false);
125-
options.getFeedbackOptions().setShowBranding(false);
126-
options.getFeedbackOptions().setUseShakeGesture(true);
127-
});
128-
```
12978
```kotlin
13079
SentryAndroid.init(this) { options ->
13180
options.feedbackOptions.isNameRequired = true
@@ -137,6 +86,17 @@ SentryAndroid.init(this) { options ->
13786
options.feedbackOptions.isUseShakeGesture = true
13887
}
13988
```
89+
```java
90+
SentryAndroid.init(context, options -> {
91+
options.getFeedbackOptions().setNameRequired(true);
92+
options.getFeedbackOptions().setShowName(false);
93+
options.getFeedbackOptions().setEmailRequired(true);
94+
options.getFeedbackOptions().setShowEmail(false);
95+
options.getFeedbackOptions().setUseSentryUser(false);
96+
options.getFeedbackOptions().setShowBranding(false);
97+
options.getFeedbackOptions().setUseShakeGesture(true);
98+
});
99+
```
140100

141101
### Form Label Customization
142102

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

160120
Example:
161121

162-
```java
163-
SentryAndroid.init(context, options -> {
164-
options.getFeedbackOptions().setFormTitle("We want to hear from you!");
165-
options.getFeedbackOptions().setMessageLabel("Feedback");
166-
options.getFeedbackOptions().setMessagePlaceholder("Type your feedback");
167-
options.getFeedbackOptions().setIsRequiredLabel(" *");
168-
options.getFeedbackOptions().setSuccessMessageText("Thanks for the feedback!");
169-
options.getFeedbackOptions().setNameLabel("Full Name");
170-
options.getFeedbackOptions().setNamePlaceholder("Type your full name");
171-
options.getFeedbackOptions().setEmailLabel("Email Address");
172-
options.getFeedbackOptions().setEmailPlaceholder("Type your email");
173-
options.getFeedbackOptions().setSubmitButtonLabel("Submit");
174-
options.getFeedbackOptions().setCancelButtonLabel("Back");
175-
});
176-
```
177122
```kotlin
178123
SentryAndroid.init(this) { options ->
179124
options.feedbackOptions.formTitle = "We want to hear from you!"
@@ -189,6 +134,21 @@ SentryAndroid.init(this) { options ->
189134
options.feedbackOptions.cancelButtonLabel = "Back"
190135
}
191136
```
137+
```java
138+
SentryAndroid.init(context, options -> {
139+
options.getFeedbackOptions().setFormTitle("We want to hear from you!");
140+
options.getFeedbackOptions().setMessageLabel("Feedback");
141+
options.getFeedbackOptions().setMessagePlaceholder("Type your feedback");
142+
options.getFeedbackOptions().setIsRequiredLabel(" *");
143+
options.getFeedbackOptions().setSuccessMessageText("Thanks for the feedback!");
144+
options.getFeedbackOptions().setNameLabel("Full Name");
145+
options.getFeedbackOptions().setNamePlaceholder("Type your full name");
146+
options.getFeedbackOptions().setEmailLabel("Email Address");
147+
options.getFeedbackOptions().setEmailPlaceholder("Type your email");
148+
options.getFeedbackOptions().setSubmitButtonLabel("Submit");
149+
options.getFeedbackOptions().setCancelButtonLabel("Back");
150+
});
151+
```
192152

193153
### Theme Customization
194154

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

212-
```java
213-
SentryUserFeedbackDialog dialog = new SentryUserFeedbackDialog.Builder(context, R.style.MyAppDialogTheme).create();
214-
```
215172
```kotlin
216-
val dialog = SentryUserFeedbackDialog.Builder(context, R.style.MyAppDialogTheme).create()
173+
val form = SentryUserFeedbackForm.Builder(context, R.style.MyAppDialogTheme).create()
174+
```
175+
```java
176+
SentryUserFeedbackForm form = new SentryUserFeedbackForm.Builder(context, R.style.MyAppDialogTheme).create();
217177
```
218178

219179
Here is an example of how the feedback form can be customized:
@@ -255,22 +215,10 @@ Here is an example of how the feedback form can be customized:
255215
</style>
256216
```
257217

258-
### Bring Your Own Widget
259-
260-
You can also use your own UI components to gather feedback and pass the feedback data object to the `Sentry.captureFeedback(Feedback)` function:
218+
### Bring Your Own Form
261219

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

266-
Feedback feedback = new Feedback("I encountered a bug while using the app.");
267-
feedback.setName("John Doe");
268-
feedback.setContactEmail("john.doe@example.com");
269-
// Optionally associate the feedback with an event
270-
SentryId sentryId = Sentry.captureMessage("My message");
271-
feedback.setAssociatedEventId(sentryId);
272-
Sentry.captureFeedback(feedback);
273-
```
274222
```kotlin
275223
import io.sentry.Sentry
276224
import io.sentry.protocol.Feedback
@@ -281,5 +229,17 @@ feedback.contactEmail = "john.doe@example.com"
281229
// Optionally associate the feedback with an event
282230
val sentryId = Sentry.captureMessage("My message")
283231
feedback.associatedEventId = sentryId
284-
Sentry.captureFeedback(feedback)
232+
Sentry.feedback().capture(feedback)
233+
```
234+
```java
235+
import io.sentry.Sentry;
236+
import io.sentry.protocol.Feedback;
237+
238+
Feedback feedback = new Feedback("I encountered a bug while using the app.");
239+
feedback.setName("John Doe");
240+
feedback.setContactEmail("john.doe@example.com");
241+
// Optionally associate the feedback with an event
242+
SentryId sentryId = Sentry.captureMessage("My message");
243+
feedback.setAssociatedEventId(sentryId);
244+
Sentry.feedback().capture(feedback);
285245
```

0 commit comments

Comments
 (0)