Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
maxBreadcrumbs: 50,
attachStacktrace: true,
}
// When we're developing locally
if (process.env.NODE_ENV !== 'production') {
/* eslint-disable-next-line global-require */
const sentryTestkit = require('sentry-testkit')
const { sentryTransport } = sentryTestkit()
// Don't actually send the errors to Sentry
sentryOptions.transport = sentryTransport
// Instead, dump the errors to the console
sentryOptions.integrations = [
new Sentry.Integrations.Debug({
// Trigger DevTools debugger instead of using console.log
debugger: false,
}),
]
}
Sentry.init(sentryOptions)
return {
Sentry,
captureException: (err, { req, res, errorInfo, query, pathname }) => {
Sentry.configureScope(scope => {
if (err.message) {
// De-duplication currently doesn't work correctly for SSR / browser errors
// so we force deduplication by error message if it is present
scope.setFingerprint([err.message])
chalk.bold.red(
'您的 Node 版本较低,CloudBase CLI 可能无法正常运行,请升级 Node 到 v8.6.0 以上!\n'
)
)
}
// Sentry 错误上报
Sentry.init({
release: pkg.version,
dsn: 'https://fff0077d06624655ad70d1ee25df419e@report.url.cn/sentry/1782',
httpsProxy: getProxy() || '',
serverName: os.hostname(),
// 忽略错误,正则匹配,
// ignoreErrors: [],
integrations: [
new Sentry.Integrations.OnUnhandledRejection({
mode: 'none'
})
]
})
// 检查更新
const ONE_DAY = 86400000
// Beta 版 1 个小时检查一次,稳定版 1 天检查一次
const CheckInterval = isBeta ? 3600000 : ONE_DAY
const notifier = updateNotifier({
pkg,
distTag: isBeta ? 'beta' : 'latest',
// 检查更新间隔 1 天
updateCheckInterval: CheckInterval
})
private _initSentry() {
Sentry.init({
dsn: this.options.sentryDsn,
release: this.options.release,
environment: this.options.ethNetworkName,
integrations: [
new Sentry.Integrations.Http({ tracing: true }),
new Tracing.Integrations.Express({
app: this.state.app,
}),
],
tracesSampleRate: this.options.sentryTraceRate,
})
this.state.app.use(Sentry.Handlers.requestHandler())
this.state.app.use(Sentry.Handlers.tracingHandler())
}