How do I get Sentry reference ID in html template using sentry-sdk?

526 views Asked by At

Since the raven is deprecated I need an alternative way to display Sentry reference ID in my html template.

The previous version looks like this from the example:

<p>You've encountered an error, oh noes!</p>
{% if request.sentry.id %}
<p>
  If you need assistance, you may reference this error as
  <strong>{{ request.sentry.id }}</strong>.
</p>
{% endif %}

How do I do this now? I tried to use sentry_sdk.capture_exception() or sentry_sdk.last_event_id() method. The first one returns None in my template, the second one looks like it's now what I am looking for.

1

There are 1 answers

1
Pinguin Pinguin On

Sentry has a new User Feedback function.

Here are the docs: https://docs.sentry.io/platforms/python/guides/django/enriching-events/user-feedback/