mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
feat: resolve errors more cautious
This commit is contained in:
parent
bf2bd4d4de
commit
94a9317e13
1 changed files with 24 additions and 1 deletions
|
|
@ -5,13 +5,36 @@ import { IN_PRODUCTION_MODE, VERSION } from 'env'
|
|||
const PUBLIC_KEY = 'd22ec5c9cc874539a51c78388c12e3b0'
|
||||
const PROJECT_ID = '1406497'
|
||||
|
||||
const errorSet = new Set<string>([
|
||||
'inThisSearch is null', // weird bug in Firefox
|
||||
'The quota has been exceeded.', // caused by other addons in Firefox
|
||||
'NetworkError when attempting to fetch resource.', // network fail in Firefox
|
||||
'Failed to fetch', // network fail in Chrome
|
||||
])
|
||||
|
||||
const sentryOptions: Sentry.BrowserOptions = {
|
||||
dsn: `https://${PUBLIC_KEY}@sentry.io/${PROJECT_ID}`,
|
||||
release: VERSION,
|
||||
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
|
||||
integrations: ints => ints.filter(({ name }) => name !== 'TryCatch'),
|
||||
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
|
||||
}
|
||||
return event
|
||||
},
|
||||
beforeBreadcrumb(breadcrumb, hint) {
|
||||
if (breadcrumb.category === 'ui.click') {
|
||||
const ariaLabel = hint?.event?.target?.ariaLabel
|
||||
if (ariaLabel) {
|
||||
breadcrumb.message = ariaLabel
|
||||
}
|
||||
}
|
||||
return breadcrumb
|
||||
},
|
||||
}
|
||||
Sentry.init(sentryOptions)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue