Skip to content

Conversation

@tustanivsky
Copy link
Collaborator

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:

// Create the feedback (what to send)
sentry_value_t feedback = sentry_value_new_feedback(...);

// Create a hint
sentry_feedback_hint_t *hint = sentry_feedback_hint_new();
sentry_feedback_hint_attach_file(hint, "screenshot.png");

// Capture feedback with hint (both are freed automatically)
sentry_capture_feedback_with_hint(feedback, hint);

Example feedback with two image attachments.

Current implementation focuses on the feedback use case but it leaves room for an easy refactor to support additional APIs later on if needed.

@github-actions
Copy link

github-actions bot commented Oct 16, 2025

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

Generated by 🚫 dangerJS against 9e98e17

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@jpnurmi
Copy link
Collaborator

jpnurmi commented Oct 17, 2025

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?

@jpnurmi
Copy link
Collaborator

jpnurmi commented Oct 28, 2025

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.

To elaborate a bit, I'd propose wrapping/exposing the missing parts from sentry_envelope.h so that the code becomes:

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);

@tustanivsky
Copy link
Collaborator Author

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 sentry_hint_t instead of sentry_feedback_hint_t) could serve as a public interface for attaching extra data to captured events as well.

Also, the before_send callback already accepts a hint parameter (currently defaulted to NULL) which might be repurposed for this as well - for example, in Android SDK the beforeSend handler provides a hint parameter that can be used to attach files to specific events. This contrasts with the current approach in Unreal SDK where attachments (like game screenshot) are added to the global scope during the on_crash hook processing so that crashpad can pick them up during uploading the event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants