如何使用sentry-sdk在html模板中获取Sentry参考ID?

发布于 2025-01-09 20:24:58 字数 598 浏览 3 评论 0原文

由于 raven 已被弃用,我需要一种替代方法在我的 html 模板中显示 Sentry 参考 ID。

以前的版本在示例中看起来像这样:

<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 %}

我如何现在就做这个吗?我尝试使用 sentry_sdk.capture_exception()sentry_sdk.last_event_id() 方法。第一个在我的模板中返回 None ,第二个看起来像是我现在正在寻找的。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文