Skip to content

feat(feedback): Add screenshot attachment button to user feedback widget - #5828

Open
markushi wants to merge 17 commits into
mainfrom
feat/feedback-screenshot-attachment
Open

feat(feedback): Add screenshot attachment button to user feedback widget#5828
markushi wants to merge 17 commits into
mainfrom
feat/feedback-screenshot-attachment

Conversation

@markushi

@markushi markushi commented Jul 23, 2026

Copy link
Copy Markdown
Member

📜 Description

Adds an "Add a screenshot" button to the Android user feedback form that opens the
androidx photo picker (ActivityResultContracts.PickVisualMedia, images only) and sends
the picked image as an attachment in the same envelope as the feedback.

Screen_recording_20260813_202418.mp4
image
  • New SentryFeedbackOptions: enableAttachScreenshot (default true, matching the JS SDK),
    addScreenshotButtonLabel, removeScreenshotButtonLabel, screenshotTooLargeMessageText, plus the
    io.sentry.feedback.enable-attach-screenshot manifest flag
  • androidx.activity:activity:1.8.2 is added as compileOnly — no new transitive
    dependency; the button is hidden (with a warning log) when androidx.activity is missing
    or the host Activity is not a ComponentActivity
  • The image is size-checked against maxAttachmentSize at pick time

Fixed along the way

The form was not scrollable, so in landscape or at large font scales the send and cancel
buttons were pushed off screen and the dialog could not be dismissed. It is now wrapped in
a ScrollView, and the three full width buttons were replaced with the framework dialog
button bar (cancel and send in a right aligned bar, screenshot as a borderless full width
action). No changelog entry, as it is bundled with this feature.

💡 Motivation and Context

💚 How did you test it?

Unit tests + Manual testing.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

@linear-code

linear-code Bot commented Jul 23, 2026

Copy link
Copy Markdown

JAVA-538

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 5edad4a

@sentry

sentry Bot commented Jul 23, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.53.0 (1) release

⚙️ sentry-android Build Distribution Settings

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 396.43 ms 478.04 ms 81.61 ms
Size 0 B 0 B 0 B

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
d8b6ce1 314.62 ms 348.67 ms 34.05 ms
0d66c0b 327.83 ms 403.40 ms 75.57 ms
fcec2f2 311.35 ms 384.94 ms 73.59 ms
c3ee041 310.64 ms 361.90 ms 51.26 ms
22f4345 313.52 ms 364.96 ms 51.44 ms
6b019b7 343.31 ms 417.23 ms 73.91 ms
b6cfb57 372.92 ms 507.77 ms 134.85 ms
b67bb28 307.59 ms 341.24 ms 33.65 ms
5865051 319.74 ms 365.60 ms 45.86 ms
80fd6ad 321.06 ms 375.79 ms 54.73 ms

App size

Revision Plain With Sentry Diff
d8b6ce1 0 B 0 B 0 B
0d66c0b 1.58 MiB 2.29 MiB 720.89 KiB
fcec2f2 1.58 MiB 2.12 MiB 551.51 KiB
c3ee041 0 B 0 B 0 B
22f4345 1.58 MiB 2.29 MiB 719.83 KiB
6b019b7 0 B 0 B 0 B
b6cfb57 1.58 MiB 2.28 MiB 718.80 KiB
b67bb28 0 B 0 B 0 B
5865051 0 B 0 B 0 B
80fd6ad 0 B 0 B 0 B

Previous results on branch: feat/feedback-screenshot-attachment

Startup times

Revision Plain With Sentry Diff
71243e7 313.69 ms 370.22 ms 56.54 ms
37c6869 327.68 ms 381.06 ms 53.38 ms
676848b 367.87 ms 443.02 ms 75.15 ms
86e5409 326.20 ms 351.31 ms 25.11 ms

App size

Revision Plain With Sentry Diff
71243e7 0 B 0 B 0 B
37c6869 0 B 0 B 0 B
676848b 0 B 0 B 0 B
86e5409 0 B 0 B 0 B

@markushi
markushi marked this pull request as ready for review July 23, 2026 17:27
Comment thread sentry/src/main/java/io/sentry/util/FileUtils.java
Comment thread sentry/src/main/java/io/sentry/util/FileUtils.java Outdated

@runningcode runningcode left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this!

Comment thread sentry/src/main/java/io/sentry/util/FileUtils.java Outdated
Comment thread sentry-android-core/build.gradle.kts
Comment thread sentry/src/main/java/io/sentry/SentryFeedbackOptions.java Outdated
Comment thread sentry/src/main/java/io/sentry/SentryFeedbackOptions.java Outdated
markushi added 2 commits July 24, 2026 10:39
Use term "screenshot" everywhere
Improve nullability handling

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0a3d51d. Configure here.

markushi and others added 2 commits August 12, 2026 12:48
…hment paths

Routes the three catch-all blocks around the screenshot picker through
ExceptionUtils.rethrowIfFatal, so OOM, ThreadDeath and linkage errors
propagate instead of being hidden, and logs the previously silent
failure in getUriSize.

Also moves the androidx.activity availability check out of
SentryFeedbackScreenshotPicker, so the class is only loaded once the
check passed, as its javadoc requires.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
markushi and others added 2 commits August 13, 2026 12:52
… buttons

The form was not scrollable, so in landscape or at large font scales the
send and cancel buttons were pushed off screen and the dialog could not
be dismissed. Wraps it in a ScrollView.

Also replaces the three full width buttons with the framework dialog
button bar: cancel and send sit in a right aligned bar, and the
screenshot button becomes a borderless full width action.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…istration

ActivityResultRegistry.registerKey returns early for a key that is already
registered, so re-registering would not have thrown.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@markushi
markushi requested a review from runningcode August 13, 2026 18:25
@markushi markushi added the sanity-check PR needs a lightweight review for obvious issues label Aug 13, 2026
markushi and others added 2 commits August 13, 2026 20:54
…hot-attachment

# Conflicts:
#	CHANGELOG.md
#	sentry-android-core/src/main/java/io/sentry/android/core/SentryUserFeedbackForm.java
#	sentry-android-core/src/test/java/io/sentry/android/core/SentryUserFeedbackFormTest.kt
#	sentry/api/sentry.api
#	sentry/src/main/java/io/sentry/SentryFeedbackOptions.java
#	sentry/src/main/java/io/sentry/SentryOptions.java
#	sentry/src/test/java/io/sentry/SentryFeedbackOptionsTest.kt
…ed types

AGENTS.md now forbids new catch (Throwable). Replaces the three broad
catches with the types the guarded code can actually throw:

- launch() documents ActivityNotFoundException and the registry throws
  IllegalStateException for an unregistered launcher
- the ContentResolver calls cross into the provider process, where Binder
  can only deliver the exceptions Parcel marshals, all RuntimeException

Fatal throwables now propagate because they are never caught, so
ExceptionUtils.rethrowIfFatal is no longer needed here.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sanity-check PR needs a lightweight review for obvious issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add file attachment support to user feedback widget

2 participants