mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
fix: retrieve error message properly and protect error peak
This commit is contained in:
parent
21f2999061
commit
d0411be620
1 changed files with 13 additions and 4 deletions
|
|
@ -5,6 +5,9 @@ import { IN_PRODUCTION_MODE, VERSION } from 'env'
|
|||
const PUBLIC_KEY = 'd22ec5c9cc874539a51c78388c12e3b0'
|
||||
const PROJECT_ID = '1406497'
|
||||
|
||||
const MAX_REPORT_COUNT = 10 // protect for error leaking
|
||||
let countReportedError = 0
|
||||
|
||||
const errorSet = new Set<string>([
|
||||
'inThisSearch is null', // weird bug in Firefox
|
||||
'The quota has been exceeded.', // caused by other addons in Firefox
|
||||
|
|
@ -18,13 +21,19 @@ const sentryOptions: Sentry.BrowserOptions = {
|
|||
environment: IN_PRODUCTION_MODE ? 'production' : 'development',
|
||||
// Not safe to activate all integrations in non-Chrome environments where Gitako may not run in top context
|
||||
// https://docs.sentry.io/platforms/javascript/#sdk-integrations
|
||||
defaultIntegrations: false,
|
||||
integrations: integrations => integrations.filter(({ name }) => name !== 'TryCatch'),
|
||||
beforeSend(event) {
|
||||
if (event.message) {
|
||||
if (errorSet.has(event.message)) return null
|
||||
errorSet.add(event.message) // prevent reporting duplicated error
|
||||
const message = event.exception?.values?.[0].value || event.message
|
||||
if (message) {
|
||||
if (errorSet.has(message)) return null
|
||||
errorSet.add(message) // prevent reporting duplicated error
|
||||
}
|
||||
return event
|
||||
if (countReportedError < MAX_REPORT_COUNT) {
|
||||
++countReportedError
|
||||
return event
|
||||
}
|
||||
return null
|
||||
},
|
||||
beforeBreadcrumb(breadcrumb, hint) {
|
||||
if (breadcrumb.category === 'ui.click') {
|
||||
|
|
|
|||
Loading…
Reference in a new issue