sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

feat(feedback): Add `captureFeedback` method

Open mydea opened this issue 1 year ago โ€ข 3 comments

This PR adds a new captureFeedback method which is exported from all SDKs.

This method can be used to capture a (new) user feedback from any package.

We follow the same semantics as for other capture methods like captureException() or captureMessage(): The method returns a string, which is the event id. We do not wait for sending to be successful or not, we just try to send it and return. You can both set an associatedEventId (which replaces the event_id of the "old" captureUserFeedback), and also pass attachments to send along (which for now are sent as a separate envelope).

For usage in the modal UI, there is still sendFeedback which continues to return a promise that resolves with the event ID, or rejects with a meaningful error message if sending fails.

This also deprecates captureUserFeedback(), which is only exported in browser. We cannot remove this yet because captureFeedback will only work on newer self-hosted instances, so not all users can easily update. We can/should remove this in v9.

Includes https://github.com/getsentry/sentry-javascript/pull/11626

mydea avatar Apr 04 '24 14:04 mydea

size-limit report ๐Ÿ“ฆ

Path Size
@sentry/browser 21.65 KB (+0.01% ๐Ÿ”บ)
@sentry/browser (incl. Tracing) 32.69 KB (+0.01% ๐Ÿ”บ)
@sentry/browser (incl. Tracing, Replay) 68.04 KB (+0.01% ๐Ÿ”บ)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 61.43 KB (+0.01% ๐Ÿ”บ)
@sentry/browser (incl. Tracing, Replay with Canvas) 72.07 KB (+0.01% ๐Ÿ”บ)
@sentry/browser (incl. Tracing, Replay, Feedback) 84.2 KB (-0.09% ๐Ÿ”ฝ)
@sentry/browser (incl. Feedback) 37.69 KB (-0.39% ๐Ÿ”ฝ)
@sentry/browser (incl. sendFeedback) 26.21 KB (-0.87% ๐Ÿ”ฝ)
@sentry/browser (incl. FeedbackAsync) 30.77 KB (-0.65% ๐Ÿ”ฝ)
@sentry/react 24.33 KB (+0.01% ๐Ÿ”บ)
@sentry/react (incl. Tracing) 35.65 KB (+0.01% ๐Ÿ”บ)
@sentry/vue 25.48 KB (+0.01% ๐Ÿ”บ)
@sentry/vue (incl. Tracing) 34.48 KB (+0.01% ๐Ÿ”บ)
@sentry/svelte 21.78 KB (+0.01% ๐Ÿ”บ)
CDN Bundle 24.03 KB (+0.01% ๐Ÿ”บ)
CDN Bundle (incl. Tracing) 34.05 KB (+0.01% ๐Ÿ”บ)
CDN Bundle (incl. Tracing, Replay) 67.73 KB (+0.01% ๐Ÿ”บ)
CDN Bundle (incl. Tracing, Replay, Feedback) 72.85 KB (-0.3% ๐Ÿ”ฝ)
CDN Bundle - uncompressed 70.64 KB (+0.01% ๐Ÿ”บ)
CDN Bundle (incl. Tracing) - uncompressed 101 KB (+0.01% ๐Ÿ”บ)
CDN Bundle (incl. Tracing, Replay) - uncompressed 210.61 KB (+0.01% ๐Ÿ”บ)
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 223.66 KB (-0.26% ๐Ÿ”ฝ)
@sentry/nextjs (client) 34.87 KB (+0.01% ๐Ÿ”บ)
@sentry/sveltekit (client) 33.25 KB (+0.01% ๐Ÿ”บ)
@sentry/node 138.72 KB (+0.01% ๐Ÿ”บ)

github-actions[bot] avatar Apr 04 '24 14:04 github-actions[bot]

Feel free to merge https://github.com/getsentry/sentry-javascript/pull/11626 into this PR if it makes sense; otherwise we can also merge sequentially :)

Lms24 avatar Apr 16 '24 12:04 Lms24

So I updated this to send attachments in the same envelope! Makes everything easier. With this change, I also removed the attachments option from captureFeedback() and sendFeedback(), instead leveraging this normally through the event hint. This means you have to do:

Sentry.captureFeedback({ message: 'xx' }, { attachments: [attachment1] });

Same as with all other capture methods.

mydea avatar Apr 26 '24 11:04 mydea

The change on ingest to accept feedback and attachments on the same envelope was done through:

  • https://github.com/getsentry/relay/pull/3403

This change has been live on SaaS and made it to self hosted: 24.4.2

  • https://github.com/getsentry/relay/releases/tag/24.4.2

bruno-garcia avatar Apr 30 '24 14:04 bruno-garcia

Assuming this PR sends feedback+attach in same envelope, let me know before you merge so I can turn on the ingest FF! I'ts only set in s4s right now.

  • Turned on: accepts same envelope AND separate envs
  • Turned off: only accepts separate envs Or you can make a PR to do so yourself like so: https://github.com/getsentry/sentry-options-automator/pull/1234

The change on ingest to accept feedback and attachments on the same envelope was done through:

This change has been live on SaaS and made it to self hosted: 24.4.2

  • https://github.com/getsentry/relay/releases/tag/24.4.2

aliu39 avatar May 01 '24 22:05 aliu39