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?

    dsn: '...',
    release: `${appConfig.releaseVersion}`,
    beforeSend(event, hint) {
      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