[web] Ignore Propensity Network errors (#26840)

* Test the scripts by adding fake ids

* Test Propensity errors

* Don't send Sentry event if `isPropensityNetworkError`

* Revert "Test Propensity errors"

This reverts commit 7052ca20d0bee3bb32b39fb90c473458a4375d7b.

* Revert "Test the scripts by adding fake ids"

This reverts commit 2ac797aadf24359917a10119155c5e41935a7482.

GitOrigin-RevId: 03c1e63e359d41ad83ce1ae5cc1063f1c59d0b4e
This commit is contained in:
Antoine Clausse
2025-07-04 12:31:33 +02:00
committed by Copybot
parent ba1884ae11
commit 6da01b8238
@@ -2,6 +2,7 @@
import getMeta from '../utils/meta'
import OError from '@overleaf/o-error'
import { debugConsole } from '@/utils/debugging'
import type { ErrorEvent } from '@sentry/types/types/event'
const {
sentryAllowedOriginRegex,
@@ -12,6 +13,21 @@ const {
const reporterPromise = sentryDsn ? sentryReporter() : nullReporter()
const isPropensityNetworkError = (err: ErrorEvent) => {
const errorBreadcrumbs = err.breadcrumbs?.filter(b => b.level === 'error')
if (!errorBreadcrumbs || errorBreadcrumbs.length !== 1) {
// don't ignore Propensity if there are more errors to report
return false
}
return Boolean(
errorBreadcrumbs[0].data?.url.startsWith(
'https://analytics.propensity.com/'
)
)
}
function sentryReporter() {
return (
import(/* webpackMode: "eager" */ '@sentry/browser')
@@ -86,6 +102,10 @@ function sentryReporter() {
}
}
if (isPropensityNetworkError(event)) {
return null
}
return event
},
})