-
-
Notifications
You must be signed in to change notification settings - Fork 58
feat: User Feedback #2220
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
feat: User Feedback #2220
Conversation
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
- User Feedback ([#2220](https://github.com/getsentry/sentry-unity/pull/2220))If none of the above apply, you can opt out of this check by adding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this out of the ScreenshotEventProcessor to be reused by CaptureUserFeedback as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the UserFeedback to the scene
71ab2cb to
b5555dc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the custom inspector for the SentryUserFeedback MonoBehaviour that we're providing as .cs.
| using System; | ||
| using System.Collections; | ||
| using UnityEngine; | ||
| using UnityEngine.UI; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could have this MonoBehaviour as part of the SDK and ship it precompiled. But there are a couple for downsides
- The SDK would need to take on an additional dependency on
UnityEngine.UI. This is not part of theManagedPath/UnityEnginebut lives somewhere in/ProjectPath/Libraryinstead. We'd need create some workaround like we do for the testrunner. - Users can't inspect the
.csin the Editor. - The workflow of Embed&Change would not work that way
| [SerializeField] private InputField _message; | ||
| [SerializeField] private Toggle _addScreenshot; | ||
|
|
||
| private void Awake() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The checks here go to the console and not the SDK logger and all have this as context. This allows us to
- Warn right in the Editor
- Clicking on the log highlights the GameObject in the Hierarchy
- The custom inspector highlights any missing references
|
@sentry review |
|
On it! We are reviewing the PR and will provide feedback shortly. |
PR DescriptionThis pull request introduces a user feedback mechanism to the Sentry Unity SDK. The goal is to allow users to easily submit bug reports and feedback directly from within the application, including optional screenshots, to provide more context for debugging and issue resolution. Click to see moreKey Technical Changes
Architecture DecisionsThe user feedback functionality is implemented as a self-contained MonoBehaviour with a corresponding editor script. This allows developers to easily integrate the feedback form into their existing UI. The screenshot capture logic is extracted into a separate utility class to promote code reuse and maintainability. The prefab is set up to use Unity's UI system, ensuring cross-platform compatibility. Dependencies and InteractionsThis feature depends on the Risk Considerations
Notable Implementation DetailsThe |
| } | ||
| else | ||
| { | ||
| hint.AddAttachment(CaptureScreenshot(Screen.width, Screen.height), "screenshot.jpg", contentType: "image/jpeg"); | ||
| hint.AddAttachment(SentryScreenshotUtility.Capture(_options), "screenshot.jpg", contentType: "image/jpeg"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The refactoring looks good, but the method call should include error handling in case screenshot capture fails.
| } | |
| else | |
| { | |
| hint.AddAttachment(CaptureScreenshot(Screen.width, Screen.height), "screenshot.jpg", contentType: "image/jpeg"); | |
| hint.AddAttachment(SentryScreenshotUtility.Capture(_options), "screenshot.jpg", contentType: "image/jpeg"); | |
| else | |
| { | |
| try | |
| { | |
| hint.AddAttachment(SentryScreenshotUtility.Capture(_options), "screenshot.jpg", contentType: "image/jpeg"); | |
| } | |
| catch (System.Exception ex) | |
| { | |
| _options.DiagnosticLogger?.LogError("Failed to capture screenshot: {0}", ex, ex.Message); | |
| } | |
| } |
| /// <summary> | ||
| /// Captures a User Feedback | ||
| /// </summary> | ||
| public static void CaptureFeedback(string message, string? email, string? name, bool addScreenshot) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm this is odd that we add an API here because it creates further confusion between SentrySdk vs SentryUnity. Both will have CaptureFeedback from the SentrySdk and get the screenshot taken before calling it and doing s => s.AddAttachment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also not totally against adding this here, just sayijng it's not ideal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the .NET SDK one should be hidden along with its Init.
Add a screenshot to the feedback should not require to either
- Implement their own screenshot capture to pass it in as attachment
- The SDK to make the screenshot capture publicly accessible
- Having to write code like this
SentryHint.WithAttachments(
new SentryAttachment(
AttachmentType.Default,
new ByteAttachmentContent(SentryScreenshotUtility.Capture(_options)),
"screenshot.jpg",
"image/jpeg"))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the .NET SDK one should be hidden along with its Init.
How do you capture events? It'll be on SentrySdk, right? some stuff on one, some on another
| _feedbackForm.SetActive(false); | ||
|
|
||
| // We're waiting for the EndOfFrame so the FeedbackForm gets updated before capturing the screenshot | ||
| yield return new WaitForEndOfFrame(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
| // save event id | ||
| // wait for end of frame | ||
| // check if last id is event it | ||
| // send screenshot | ||
|
|
||
| // add workitem: screentshot for ID xxx | ||
| // sdk integration checking for work: if ID got sent, follow up with screenshot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs to be cleaned up?
| /// <summary> | ||
| /// Captures a User Feedback | ||
| /// </summary> | ||
| public static void CaptureFeedback(string message, string? email, string? name, bool addScreenshot) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the .NET SDK one should be hidden along with its Init.
How do you capture events? It'll be on SentrySdk, right? some stuff on one, some on another
Fixes #928
Note: I've updated the prefab to include the logo on the top right. See the updated screenshot on Android.
Goal
The idea is to provide users a simple to use prefab to add to their game to allow players to provide user feedback. This is a first iteration and the things we're looking to have added to the feedback is:
Implementation Details
A prefab that holds a GameObject with a scaling canvas that can be dropped into any scene.
The prefab consists of two parts:
One Prefab
Button and form are part of the same prefab. It make little sense to provide them separately to customize them. The button would need to be provided with the form prefab, making this a customization. So you'd always end up with changes to both anyway.
Attempting to pass this (or parts of it) into the editor configuration window would counter the Unity workflow of adding prefabs to scenes that are support to have the feedback.
One
MonoBehaviourthat's shipped as.csSince we're providing a prefab to be dragged into scenes and we expect users to customize them, the accompanying
MonoBehaviourshould be as accessible as possible. We're providing it as a heavily commented "raw".csfile that is getting compiled with the game.This also allows us not to take on
UnityEngine.UIas a dependency for the Unity SDK.Custom Inspector
We're providing the
SentryUserFeedbackMonoBehaviourit's own custom inspector to highlight broken or missing referencesHow to allow for customization
The prefab can be dragged anywhere into the
/Assetsallowing for the creation of a prefab variant. This variant "inherits" from the original and all values that have not been explicitly changed will get updated.The form is controlled by a
VertialLayoutGroupwhich allows for optional inputs (i.e. name, email) to be dropped while retaining the layout.Adding to the scene
Adding the User Feedback to the scene can be done via drag&drop:
Addition.mov
The Feature in Action
Clicking the megaphone button pops up the form to submit user feedback.
Screen.Recording.2025-06-27.at.13.13.54.mov
Since the canvas scales with the screen, this works on a wide range of displays and resolutions, i.e. mobile
When submitting the report we're delaying to send it to the
EndOfFrameso the screenshot does not contain the form.