-
-
Notifications
You must be signed in to change notification settings - Fork 468
feat(feedback): Add per-form shake detection and sample app showcases #5353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f6f626b
feat(feedback): Add per-form shake detection and sample app showcases
romtsn 973955f
docs(changelog): Add per-form shake detection entry
romtsn 51209a7
Format code
getsentry-bot 109a8a2
docs(changelog): Add usage example for per-form shake detection
romtsn 929b476
docs(changelog): Use Kotlin example and clarify per-screen usage
romtsn 35ee7a5
ref(feedback): Extract shared shake listener in SentryUserFeedbackForm
romtsn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,7 @@ import androidx.compose.material.icons.filled.Settings | |
| import androidx.compose.material.icons.filled.Speed | ||
| import androidx.compose.material.icons.filled.Videocam | ||
| import androidx.compose.material3.AlertDialog | ||
| import androidx.compose.material3.Button | ||
| import androidx.compose.material3.ExperimentalMaterial3Api | ||
| import androidx.compose.material3.Icon | ||
| import androidx.compose.material3.MaterialTheme | ||
|
|
@@ -62,6 +63,7 @@ import androidx.compose.runtime.mutableStateOf | |
| import androidx.compose.runtime.remember | ||
| import androidx.compose.runtime.rememberCoroutineScope | ||
| import androidx.compose.runtime.setValue | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.ExperimentalComposeUiApi | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.draw.rotate | ||
|
|
@@ -79,8 +81,9 @@ import io.sentry.MeasurementUnit | |
| import io.sentry.Sentry | ||
| import io.sentry.SentryLogLevel | ||
| import io.sentry.UpdateStatus | ||
| import io.sentry.android.core.SentryUserFeedbackForm | ||
| import io.sentry.compose.SentryTraced | ||
| import io.sentry.compose.SentryUserFeedbackButton | ||
| import io.sentry.protocol.Feedback | ||
| import io.sentry.protocol.User | ||
| import java.io.File | ||
| import java.io.FileOutputStream | ||
|
|
@@ -615,8 +618,106 @@ fun UserFeedbackScreen() { | |
| } | ||
| } | ||
|
|
||
| // SentryUserFeedbackButton as a special item | ||
| item(span = { GridItemSpan(maxLineSpan) }) { SentryUserFeedbackButton(modifier = Modifier) } | ||
| // Bring up User Feedback Form from a custom button using the global Sentry.feedback() API | ||
| item(span = { GridItemSpan(maxLineSpan) }) { | ||
| Button(modifier = Modifier, onClick = { Sentry.feedback().show() }) { | ||
| Row( | ||
| verticalAlignment = Alignment.CenterVertically, | ||
| horizontalArrangement = Arrangement.Center, | ||
| ) { | ||
| Icon( | ||
| painter = | ||
| painterResource( | ||
| id = io.sentry.compose.R.drawable.sentry_user_feedback_compose_button_logo_24 | ||
| ), | ||
| contentDescription = null, | ||
| ) | ||
| Spacer(Modifier.padding(horizontal = 4.dp)) | ||
| Text(text = "Report a Bug") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Create a SentryUserFeedbackForm programmatically and show it | ||
| item(span = { GridItemSpan(maxLineSpan) }) { | ||
| Button( | ||
| modifier = Modifier, | ||
| onClick = { | ||
| SentryUserFeedbackForm.Builder(activity) | ||
| .configurator { options -> | ||
| options.formTitle = "Custom Form" | ||
| options.submitButtonLabel = "Send" | ||
| options.cancelButtonLabel = "Never mind" | ||
| options.messageLabel = "What happened?" | ||
| options.messagePlaceholder = "Describe the issue..." | ||
| options.isShowBranding = false | ||
| options.isNameRequired = true | ||
| options.isEmailRequired = true | ||
| options.setOnSubmitSuccess { feedback -> | ||
| Toast.makeText(activity, "Thanks for the feedback!", Toast.LENGTH_SHORT).show() | ||
| } | ||
| } | ||
| .create() | ||
| .show() | ||
| }, | ||
| ) { | ||
| Text(text = "Custom Form (Builder)") | ||
| } | ||
| } | ||
|
|
||
| // Showcases how to manually show and dismiss a form programmatically | ||
| item(span = { GridItemSpan(maxLineSpan) }) { | ||
| Button( | ||
| modifier = Modifier, | ||
| onClick = { | ||
| val form = | ||
| SentryUserFeedbackForm.Builder(activity) | ||
| .configurator { options -> options.formTitle = "Quick! You have 2 seconds" } | ||
| .create() | ||
| form.show() | ||
| Handler(Looper.getMainLooper()).postDelayed({ form.dismiss() }, 2000) | ||
| }, | ||
| ) { | ||
| Text(text = "Auto-dismiss Form (2s)") | ||
| } | ||
| } | ||
|
|
||
| // Send feedback programmatically without showing a form | ||
| item(span = { GridItemSpan(maxLineSpan) }) { | ||
| Button( | ||
| modifier = Modifier, | ||
| onClick = { | ||
| val feedback = | ||
| Feedback("The app crashed when I tapped the button").apply { | ||
| name = "Jane Doe" | ||
| contactEmail = "[email protected]" | ||
| url = "https://example.com/page" | ||
| } | ||
| val eventId = Sentry.feedback().capture(feedback) | ||
| Toast.makeText(activity, "Feedback sent: $eventId", Toast.LENGTH_SHORT).show() | ||
| }, | ||
| ) { | ||
| Text(text = "Send Feedback (no form)") | ||
| } | ||
| } | ||
|
|
||
| // Enable shake-to-show for a specific form instance | ||
| item(span = { GridItemSpan(maxLineSpan) }) { | ||
| Button( | ||
| modifier = Modifier, | ||
| onClick = { | ||
| SentryUserFeedbackForm.Builder(activity) | ||
| .configurator { options -> | ||
| options.isUseShakeGesture = true | ||
| options.formTitle = "Shake Feedback" | ||
| } | ||
| .create() | ||
| Toast.makeText(activity, "Shake your device to open the form!", Toast.LENGTH_SHORT).show() | ||
| }, | ||
| ) { | ||
| Text(text = "Enable Shake-to-Show") | ||
| } | ||
| } | ||
|
romtsn marked this conversation as resolved.
|
||
| } | ||
| } | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.