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

User Feedback Feature Request: Custom context

Open lbernick opened this issue 1 year ago • 3 comments

Problem Statement

Use case: When an error occurs, we prompt the user for feedback and also for consent to upload diagnostic info. Diagnostic info is uploaded to cloud storage, and I'd like to associate the cloud storage URI with the event created in Sentry. This URI is only generated after the user consents to uploading diagnostics, so it's not available at the time of the crash. This is very similar to https://forum.sentry.io/t/updating-event-after-initial-upload/15057 but I didn't see a solution for that issue.

For user feedback that isn't related to a crash, we can do:

    Sentry.withScope(function (scope) {
      scope.setContext("Diagnostic Info", {
        URI: uri,
      })
      eventId = Sentry.captureMessage(`User Feedback from ${name}`)
    })
    const userFeedback = {
      event_id: eventId,
      name: name,
      email: email,
      comments: comments,
    }
    Sentry.captureUserFeedback(userFeedback)

However, for user feedback for a crash report, I don't see a way of attaching this context to the original event.

Workarounds: I'd rather not do either of these options but I suppose they could work:

  • use "comments" field in user feedback api for jsonified context
  • create a global setting to opt in to diagnostics upload and automatically upload after a crash

Let me know if there are other options I should consider.

Alternatives:

  • Attachments for user feedback: This could work but the size of the diagnostic info is larger than Sentry's allowable attachment size.
  • Allow an event's context to be updated after creation.

Solution Brainstorm

No response

Product Area

User Feedback

lbernick avatar Mar 04 '24 01:03 lbernick

Assigning to @getsentry/support for routing ⏲️

getsantry[bot] avatar Mar 04 '24 01:03 getsantry[bot]

Routing to @getsentry/product-owners-user-feedback for triage ⏲️

getsantry[bot] avatar Mar 04 '24 17:03 getsantry[bot]

Thanks for raising. This makes sense and on v8 of the JS SDK we plan to align the captureUserFeedback with the new sendFeedback that was created to send feedback outside errors (but ties to session replay etc).

bruno-garcia avatar Mar 04 '24 23:03 bruno-garcia

in v8, you can add any data via the scope, which will be picked up by the feedback event like any other event.

You can do either this:

Sentry.captureFeedback(
  { message: "I really like your App, thanks!" },
  {
    captureContext: {
      tags: { key: "value" },
      extra: { key: "value" },
    },
  }
);

Or you can put data on the scope, which will be automatically picked up as well:

Sentry.withScope(scope => {
  scope.setTag('my-tag', 'value');
  Sentry.captureFeedback({ message: 'My feedback goes here!' });
});

mydea avatar May 28 '24 08:05 mydea