beforeSend does not work for us

We have a code like this (typescript) and there are some issues caused by browsers bugs like resizeObserver that are killing our quotas.

Is there something wrong in the following code trying to filter issues?

  Sentry.init({
    dsn: '...',
    release: `${appConfig.releaseVersion}`,
    beforeSend(event, hint) {
      // https://docs.sentry.io/platforms/javascript/configuration/filtering/
      const error = hint?.originalException
      // checkEventFilter is just a regex that checks for words like 'ResizeObserver' under the hood and fully tested.
      if (error instanceof Error && checkEventFilter(error.message)) {
        return null
      }
      return event
    }
  })