feat: Add attachment support to user feedback#1414
Conversation
|
|
Looks good at first glance, even though it feels like it's a lot of new API for a very specific use case. Since the goal is to add attachments to envelopes, I wonder if it would make sense to open up some of the existing but internal envelope APIs to make the same achievable in a more generic way. What do you think? |
To elaborate a bit, I'd propose wrapping/exposing the missing parts from sentry_value_t feedback = sentry_value_new_feedback(...);
sentry_envelope_t *envelope = sentry_envelope_new();
sentry_envelope_add_feedback(envelope, feedback);
sentry_envelope_attach_file(envelope, "screenshot.png");
sentry_capture_envelope(envelope); |
|
Exposing internal envelope APIs sounds like a reasonable alternative to me. However, if there are any concerns about doing so, the newly introduced hint type (perhaps with a more generic name like Also, the UPD: |
| SENTRY_WITH_OPTIONS (options) { | ||
| envelope = prepare_user_feedback(user_feedback); | ||
| envelope = prepare_user_feedback(user_feedback, hint); | ||
| if (envelope) { | ||
| sentry__capture_envelope(options->transport, envelope); | ||
| } else { | ||
| sentry_value_decref(user_feedback); | ||
| } | ||
| } | ||
|
|
||
| if (hint) { | ||
| sentry__feedback_hint_free(hint); | ||
| } | ||
| } |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
If envelope was created successfully it takes ownership of the user_feedback value so we don't have to decref manually.
|
@JoshuaMoelans @jpnurmi The PR was updated to make the hint structure more generic rather than feedback-specific ( |
|
I think it looks good in principle. 👍 There are still some "setry_feedback_hint" references to rename, and perhaps |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
Yes, cleaning up the remaining references to |
| if (envelope) { | ||
| sentry__capture_envelope(options->transport, envelope); | ||
| } else { | ||
| sentry_value_decref(user_feedback); |
There was a problem hiding this comment.
Was this decref intentionally removed? In the happy path above, the envelope takes ownership of user_feedback, but if it failed to prepare an envelope, would user_feedback be leaked?
There was a problem hiding this comment.
If prepare_user_feedback fails to create an envelope the user_feedback should be freed automatically:
sentry-native/src/sentry_core.c
Lines 799 to 803 in 5f54734
There was a problem hiding this comment.
ah, so there's a bug in the existing implementation. good catch, and thanks for fixing it! 👍
JoshuaMoelans
left a comment
There was a problem hiding this comment.
Looks good! Small nit on clarifying a docstring, but no issues otherwise.
Co-authored-by: JoshuaMoelans <[email protected]>
**Before** - https://develop.sentry.dev/sdk/telemetry/feedbacks/#attaching-screenshots - https://develop.sentry.dev/sdk/data-model/envelope-items/#user-feedback:~:text=Attaching%20Screenshots%3A **After** (awaiting vercel preview) ## DESCRIBE YOUR PR With this PR in native getsentry/sentry-native#1414 we noticed the docs are outdated, since Feedback can get more than just screenshots attached (see [this event](https://sentry-sdks.sentry.io/issues/feedback/?feedbackSlug=sentry-native%3A7227469676&mailbox=ignored&project=4506178389999616&referrer=feedback_list_page&statsPeriod=14d) for example). I updated the docs to be more generic as to what someone can attach to Feedbacks. ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [x] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs)
**Before** - https://develop.sentry.dev/sdk/telemetry/feedbacks/#attaching-screenshots - https://develop.sentry.dev/sdk/data-model/envelope-items/#user-feedback:~:text=Attaching%20Screenshots%3A **After** (awaiting vercel preview) ## DESCRIBE YOUR PR With this PR in native getsentry/sentry-native#1414 we noticed the docs are outdated, since Feedback can get more than just screenshots attached (see [this event](https://sentry-sdks.sentry.io/issues/feedback/?feedbackSlug=sentry-native%3A7227469676&mailbox=ignored&project=4506178389999616&referrer=feedback_list_page&statsPeriod=14d) for example). I updated the docs to be more generic as to what someone can attach to Feedbacks. ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [x] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs)
This PR adds the ability to attach files and binary data to feedback submissions allowing users to include screenshots, logs or other contextual information alongside their text messages.
The initial request to add attachment support for user feedback originated from the Unreal SDK:
Here, a hint pattern is used (borrowed from the Android SDK) which relies on an opaque pointer to provide a standardized way to attach optional context or metadata to feedback without modifying its core value.
Example usage:
Current implementation focuses on the feedback use case but it can be expanded to support additional APIs later on if needed.