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

时间:2021-04-16 15:30:05

标签: javascript react-native logging sentry react-native-sentry

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

  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?

0 个答案:

没有答案