如何在本机反应中将 userId 传递给哨兵?

问题描述

到目前为止,我们有两种方式向哨兵发送错误

  1. 所有 Errors 都被 Sentry 抓到了。
  2. 我们的 <ErrorBoundary /> 组件使用 captureException

我们想将 userId 传递给哨兵,它存储在 AuthContext 中并且可以使用反应钩子读取。

如何重新配置​​ Sentry 以传入 extras 此信息?

我应该使用:

  • Sentry.setExtra("userId",userId);
  • Sentry.withScope((scope) => { scope.setExtra("userId",userId); })
  • Sentry.configureScope(scope => { scope.setExtra("userId",userId); })

我关心的是react流程,我只需要在用户登录时配置一次(如果用户退出我们保留旧ID)

如何根据我的要求正确配置 Sentry?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)