到目前为止,我们有两种方式向哨兵发送错误:
Errors
都被 Sentry 抓到了。<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?