[英]How can I capture errors and exceptions data from frontend response to django to add more context
I want to receive some parameters with my error capture on django when something wrong on the front-end 当前端出现问题时,我想在django上接收一些参数以进行错误捕获
I have react frontend running on a django backend. 我有在Django后端上运行的前端反应。 Sentry is been used to capture errors and report.
Sentry用于捕获错误和报告。
In settings.py: 在settings.py中:
SENTRY_DSN = os.environ.get("SENTRY_DSN")
if SENTRY_DSN:
sentry_sdk.init(
dsn=SENTRY_DSN,
integrations=[DjangoIntegration()],
environment=ENVIRONMENT,
release=os.environ.get("HEROKU_RELEASE_VERSION")
or "HEROKU_RELEASE_VERSION not set",
)
with configure_scope() as scope:
scope.user = {"user": "broken lol"}
This is reporting the errors from entire app. 这是报告整个应用程序中的错误。
However, I want to add user ids to error Sentry reports. 但是,我想将用户ID添加到错误Sentry报告中。 To do that I need to capture the response from frontend and somehow get that into settings.py and replace the
"broken lol"
string with UserId
为此,我需要捕获来自前端的响应,并以某种方式将其放入settings.py中,并用
UserId
替换"broken lol"
字符串
To capture user IDs from Django's user objects, set init(..., send_default_pii=True)
. 要从Django的用户对象中捕获用户ID,请设置
init(..., send_default_pii=True)
。 We do not have this as default because this can be a footgun for privacy. 我们没有默认设置,因为这可能是保护隐私的步枪。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.