Skip to content

Commit 4152701

Browse files
authored
New User Feedback form (#4384)
* added SentryFeedbackOptions * added feedbackOptions to SentryOptions * SentryUserFeedbackDialog * user feedback dialog uses dialogTheme * added dialog theme to sample app * MainActivity "send user feedback" button now opens feedback dialog instead of sending feedback * added tests and UI tests * added manifest options * added replay capturing on feedback dialog open * added SentryUserFeedbackDialog.Builder, allowing a configuration being passed for the current dialog options * added SentryFeedbackOptions copy constructor
1 parent e16d062 commit 4152701

File tree

23 files changed

+2114
-8
lines changed

23 files changed

+2114
-8
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Features
6+
7+
- Add New User Feedback form ([#4384](https://github.com/getsentry/sentry-java/pull/4384))
8+
- We now introduce SentryUserFeedbackDialog, which extends AlertDialog, inheriting the show() and cancel() methods, among others.
9+
To use it, just instantiate it and call show() on the instance (Sentry must be previously initialized).
10+
For customization options, please check the [User Feedback documentation](https://docs.sentry.io/platforms/android/user-feedback/configuration/).
11+
```java
12+
import io.sentry.android.core.SentryUserFeedbackDialog;
13+
14+
new SentryUserFeedbackDialog.Builder(context).create().show();
15+
```
16+
```kotlin
17+
import io.sentry.android.core.SentryUserFeedbackDialog
18+
19+
SentryUserFeedbackDialog.Builder(context).create().show()
20+
```
21+
322
## 8.13.3
423

524
### Fixes

sentry-android-core/api/sentry-android-core.api

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,24 @@ public final class io/sentry/android/core/SentryPerformanceProvider {
385385
public fun shutdown ()V
386386
}
387387

388+
public final class io/sentry/android/core/SentryUserFeedbackDialog : android/app/AlertDialog {
389+
public fun setCancelable (Z)V
390+
public fun setOnDismissListener (Landroid/content/DialogInterface$OnDismissListener;)V
391+
public fun show ()V
392+
}
393+
394+
public class io/sentry/android/core/SentryUserFeedbackDialog$Builder {
395+
public fun <init> (Landroid/content/Context;)V
396+
public fun <init> (Landroid/content/Context;I)V
397+
public fun <init> (Landroid/content/Context;ILio/sentry/android/core/SentryUserFeedbackDialog$OptionsConfiguration;)V
398+
public fun <init> (Landroid/content/Context;Lio/sentry/android/core/SentryUserFeedbackDialog$OptionsConfiguration;)V
399+
public fun create ()Lio/sentry/android/core/SentryUserFeedbackDialog;
400+
}
401+
402+
public abstract interface class io/sentry/android/core/SentryUserFeedbackDialog$OptionsConfiguration {
403+
public abstract fun configure (Landroid/content/Context;Lio/sentry/SentryFeedbackOptions;)V
404+
}
405+
388406
public class io/sentry/android/core/SpanFrameMetricsCollector : io/sentry/IPerformanceContinuousCollector, io/sentry/android/core/internal/util/SentryFrameMetricsCollector$FrameMetricsCollectorListener {
389407
protected final field lock Lio/sentry/util/AutoClosableReentrantLock;
390408
public fun <init> (Lio/sentry/android/core/SentryAndroidOptions;Lio/sentry/android/core/internal/util/SentryFrameMetricsCollector;)V

sentry-android-core/src/main/java/io/sentry/android/core/ManifestMetadataReader.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import io.sentry.ILogger;
77
import io.sentry.InitPriority;
88
import io.sentry.ProfileLifecycle;
9+
import io.sentry.SentryFeedbackOptions;
910
import io.sentry.SentryIntegrationPackageStorage;
1011
import io.sentry.SentryLevel;
1112
import io.sentry.protocol.SdkVersion;
@@ -126,6 +127,18 @@ final class ManifestMetadataReader {
126127
static final String ENABLE_AUTO_TRACE_ID_GENERATION =
127128
"io.sentry.traces.enable-auto-id-generation";
128129

130+
static final String FEEDBACK_NAME_REQUIRED = "io.sentry.feedback.is-name-required";
131+
132+
static final String FEEDBACK_SHOW_NAME = "io.sentry.feedback.show-name";
133+
134+
static final String FEEDBACK_EMAIL_REQUIRED = "io.sentry.feedback.is-email-required";
135+
136+
static final String FEEDBACK_SHOW_EMAIL = "io.sentry.feedback.show-email";
137+
138+
static final String FEEDBACK_USE_SENTRY_USER = "io.sentry.feedback.use-sentry-user";
139+
140+
static final String FEEDBACK_SHOW_BRANDING = "io.sentry.feedback.show-branding";
141+
129142
/** ManifestMetadataReader ctor */
130143
private ManifestMetadataReader() {}
131144

@@ -477,6 +490,21 @@ static void applyMetadata(
477490
options
478491
.getLogs()
479492
.setEnabled(readBool(metadata, logger, ENABLE_LOGS, options.getLogs().isEnabled()));
493+
494+
final @NotNull SentryFeedbackOptions feedbackOptions = options.getFeedbackOptions();
495+
feedbackOptions.setNameRequired(
496+
readBool(metadata, logger, FEEDBACK_NAME_REQUIRED, feedbackOptions.isNameRequired()));
497+
feedbackOptions.setShowName(
498+
readBool(metadata, logger, FEEDBACK_SHOW_NAME, feedbackOptions.isShowName()));
499+
feedbackOptions.setEmailRequired(
500+
readBool(metadata, logger, FEEDBACK_EMAIL_REQUIRED, feedbackOptions.isEmailRequired()));
501+
feedbackOptions.setShowEmail(
502+
readBool(metadata, logger, FEEDBACK_SHOW_EMAIL, feedbackOptions.isShowEmail()));
503+
feedbackOptions.setUseSentryUser(
504+
readBool(
505+
metadata, logger, FEEDBACK_USE_SENTRY_USER, feedbackOptions.isUseSentryUser()));
506+
feedbackOptions.setShowBranding(
507+
readBool(metadata, logger, FEEDBACK_SHOW_BRANDING, feedbackOptions.isShowBranding()));
480508
}
481509
options
482510
.getLogger()

0 commit comments

Comments
 (0)