Skip to content
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

Implementing a capture_feedback function #743

Open
zmitchell opened this issue Feb 18, 2025 · 2 comments
Open

Implementing a capture_feedback function #743

zmitchell opened this issue Feb 18, 2025 · 2 comments

Comments

@zmitchell
Copy link
Contributor

I forked the repo to attempt to implement this function based off of the corresponding function in the Javascript SDK: https://github.com/getsentry/sentry-javascript/blob/136370c8d4f0c0cd9ec80b47ba2292406d0b4ba7/packages/core/src/feedback.ts#L8

From what I gather, the necessary steps are:

  • Add a Feedback variant to the Context enum.
  • Add a FeedbackContext struct that holds contact_email, name, and message.
  • I'm not sure what to do about the type field in the Javascript Event. I see it in the Go SDK as well for their event type, but I don't see it in the Rust SDK's Event type.
  • Add the Context::Feedback to the contexts field of the Event
  • Call capture_event with this new Event.

I went ahead and implemented that locally, but it's showing up as an "unlabeled event" (and not displaying in the User Feedback section), even though the "Feedback" context is populated as shown in the screenshot below. I've also checked that the project this event is sent to has User Feedback enabled.

Image

You can see what I've implemented so far here (there's no capture_feedback function, but I'm creating the event and calling capture_event manually in my own project): zmitchell@248de09

@lcian
Copy link
Member

lcian commented Feb 19, 2025

Hi @zmitchell , thanks for opening this issue and giving it a try.

If you check the develop docs for this feature https://develop.sentry.dev/sdk/data-model/envelope-items/#user-feedback it's mentioned that user feedback is an item type.
This means that when sending it in an envelope we should set the item header (https://develop.sentry.dev/sdk/data-model/envelopes/#items) type to feedback for it to be recognized properly.
If we use capture_event, then the item header will be set to event, which is not what we want.

So the proper solution should be to create a new variant in EnvelopeItem, making sure that it serializes with the type header set to feedback. This way we could create an envelope with an item of this type and then call transport.send_envelope directly.

Unfortunately we're not prioritizing this feature at the moment, but would be happy to review the PR if you get it to work.
(we don't necessarily need the whole API like in JS, just being able to create envelopes with items of this type would be great and we can document that)

@zmitchell
Copy link
Contributor Author

Thanks for the pointers! I have this working now and I'll clean it up and submit a PR in the next couple of days.

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

No branches or pull requests

2 participants