mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
4e18a81944
Silence some more expected/spurious frontend errors in Sentry GitOrigin-RevId: e2ad049e83e53806b9233b51ae88288d16b36053
48 lines
1.9 KiB
JavaScript
48 lines
1.9 KiB
JavaScript
// Conditionally enable Sentry based on whether the DSN token is set
|
|
// Conditionally enable Sentry based on whether the DSN token is set
|
|
if (window.ExposedSettings.sentryDsn) {
|
|
import(/* webpackChunkName: "sentry" */ '@sentry/browser').then(Sentry => {
|
|
let eventCount = 0
|
|
|
|
Sentry.init({
|
|
dsn: window.ExposedSettings.sentryDsn,
|
|
release: window.ExposedSettings.sentryRelease,
|
|
environment: window.ExposedSettings.sentryEnvironment,
|
|
|
|
// Ignore errors unless they come from our origins
|
|
// Adapted from: https://docs.sentry.io/platforms/javascript/#decluttering-sentry
|
|
whitelistUrls: [
|
|
new RegExp(window.ExposedSettings.sentryAllowedOriginRegex)
|
|
],
|
|
|
|
ignoreErrors: [
|
|
// Ignore very noisy error
|
|
'SecurityError: Permission denied to access property "pathname" on cross-origin object',
|
|
// Ignore unhandled error that is "expected" - see https://github.com/overleaf/issues/issues/3321
|
|
/^Missing PDF/,
|
|
// Ignore "expected" error from aborted fetch - see https://github.com/overleaf/issues/issues/3321
|
|
/^AbortError/,
|
|
// Ignore spurious error from Ace internals - see https://github.com/overleaf/issues/issues/3321
|
|
'ResizeObserver loop limit exceeded',
|
|
'ResizeObserver loop completed with undelivered notifications.'
|
|
],
|
|
|
|
beforeSend(event) {
|
|
// Limit number of events sent to Sentry to 100 events "per page load",
|
|
// (i.e. the cap will be reset if the page is reloaded). This prevent
|
|
// hitting their server-side event cap.
|
|
eventCount++
|
|
if (eventCount > 100) {
|
|
return null // Block the event from sending
|
|
} else {
|
|
return event
|
|
}
|
|
}
|
|
})
|
|
|
|
Sentry.setUser({ id: window.user_id })
|
|
|
|
// Previously Raven added itself as a global, so we mimic that old behaviour
|
|
window.Raven = Sentry
|
|
})
|
|
}
|