我才刚刚开始使用Sentry。这是它给我的建议:
// add this
const Sentry = require('@sentry/node');
Sentry.init({ dsn: 'https://eed343acxxxxxxxxxxx3bb7e3f4bc10@sentry.io/1511416' });
// and call some undefined function
myUndefinedFunction();附注:我感兴趣的是工作的内部机制,而不是用户说明。
发布于 2019-07-23 19:55:50
您只需添加captureExcepton:
Sentry.init({ dsn: 'https://8ad77012ba2c436aba8a12e0b6cfd46b@sentry.io/1382991' });function captureError(err){
Sentry.withScope(scope => {
Object.keys(extra).forEach(key => { //Here you can add extra message(optional)
scope.setExtra(key, extra[key]);
});
Sentry.captureException(error); //important
});
}
and you can call this function from anywhere just pass err object注意:您需要在函数或try catch中的某个位置捕获此错误。您需要告诉sentry来捕获此异常
发布于 2019-07-23 19:10:25
如果你有一个错误,你应该发送错误给卫兵,如下所示:
import * as Sentry from "@sentry/browser";
handleError(error: any): void {
Sentry.captureException(error);
}https://stackoverflow.com/questions/57162795
复制相似问题