User Feedback

Sentry provides the ability to collect additional feedback from the user upon hitting an error. This is primarily useful in situations where you might generally render a plain error page (the classic 500.html). To collect the feedback, an embeddable JavaScript widget is available, which can then be shown on demand to your users.

The following pieces of information are requested and collected:

  • The user’s name
  • The user’s email address
  • A description of what happened

When feedback is collected, Sentry will pair it up with the original event giving you additional insights into issues.

Collecting Feedback

The integration process consists of running our JavaScript SDK (2.1 or newer), authenticating with your public DSN, and passing in the client-side generated Event ID:

Custom 500 handler:

from flask import render_template
from sentry_sdk import last_event_id

@app.errorhandler(500)
def server_error_handler(error):
    return render_template("500.html", sentry_event_id=last_event_id()), 500

And the template that brings up the dialog:

<script src="https://browser.sentry-cdn.com/4.4.1/bundle.min.js" crossorigin="anonymous"></script>

{% if sentry_event_id %}
<script>
  Sentry.init({ dsn: '___PUBLIC_DSN___' });
  Sentry.showReportDialog({ eventId: '{{ sentry_event_id }}' })
</script>
{% endif %}

<script src="https://browser.sentry-cdn.com/4.4.1/bundle.min.js" crossorigin="anonymous"></script>

<script>
  Sentry.init({
    dsn: '___PUBLIC_DSN___',
    beforeSend(event) {
      // Check if it is an exception, if so, show the report dialog
      if (event.exception) {
        Sentry.showReportDialog();
      }
      return event;
    }
  });
</script>

With ASP.NET Core MVC, the Error.cshtml razor page:

<script src="https://browser.sentry-cdn.com/4.4.1/bundle.min.js" crossorigin="anonymous"></script>

@using Sentry

@if (SentrySdk.LastEventId != Guid.Empty)
{
    <script>
        Sentry.init({ dsn: '___PUBLIC_DSN___' });
        Sentry.showReportDialog({ eventId: '@SentrySdk.LastEventId' });
    </script>
}

Custom 500 handler:

from sentry_sdk import last_event_id
from django.shortcuts import render

def handler500(request, *args, **argv):
    return render(request, "500.html", {
        'sentry_event_id': last_event_id(),
    }, status=500)

And the template that brings up the dialog

<script src="https://browser.sentry-cdn.com/4.4.1/bundle.min.js" crossorigin="anonymous"></script>

{% if sentry_event_id %}
<script>
  Sentry.init({ dsn: '___PUBLIC_DSN___' });
  Sentry.showReportDialog({ eventId: '{{ sentry_event_id }}' })
</script>
{% endif %}

const { init, showReportDialog } = require('@sentry/electron');

init({
  dsn: '___PUBLIC_DSN___',
  beforeSend(event) {
    // Check if it is an exception, if so, show the report dialog
    // Note that this only will work in the renderer process, it's a noop on the main process
    if (event.exception) {
      Sentry.showReportDialog();
    }
    return event;
  }
});

If you don’t want to use Sentry’s native widget, you can also send feedback using our User Feedback API.

Customizing the Widget

Several parameters are available to customize the widget, specifically for localization. All options can be passed through the showReportDialog call.

An override for Sentry’s automatic language detection (e.g. lang=de)

Param Default
eventId Manually set the id of the event.
dsn Manually set dsn to report to.
user Manually set user data [an object with keys listed above].
user.email User’s email address.
user.name User’s name.
lang [automatic]override for Sentry’s language code
title It looks like we’re having issues.
subtitle Our team has been notified.
subtitle2 If you’d like to help, tell us what happened below. – not visible on small screen resolutions
labelName Name
labelEmail Email
labelComments What happened?
labelClose Close
labelSubmit Submit
errorGeneric An unknown error occurred while submitting your report. Please try again.
errorFormEntry Some fields were invalid. Please correct the errors and try again.
successMessage Your feedback has been sent. Thank you!