Description
We are developing a large independent React module for a large site. The site itself has a quite default Sentry installation with its own Sentry DSN etc. We want/wanted to add an independent Sentry to our module, as we have our own Sentry (DSN) and some requirements of our own.
We managed this quite well with @sentry/browser
6.13.x. A (very) simplified version of our implementation goes like this:
import * as Sentry from '@sentry/browser'
class SentryService {
private client?: Sentry.BrowserClient
private hub?: Sentry.Hub
public init(options?: Sentry.BrowserOptions) {
this.client = new Sentry.BrowserClient({
dsn: process.env.OUR_DSN,
...options,
})
this.hub = new Sentry.Hub(this.client)
if (!this.hub.getScope()) {
this.hub.pushScope()
}
window.addEventListener('error', (errorEvent) => {
this.hub?.run((hub) => {
hub.withScope((scope) => {
scope.setTag('our-custom-tag', 'some-value')
hub.captureException(errorEvent.error)
})
})
})
}
}
And this has been fulfilling our needs (although there has been some glue code required here and there).
Now, I was doing an update to a newer version of @sentry/browser
and noticed the 6.14.0 had brought a big blockade for us in the form of exception recapturing prevention (pull request #4067).
What this means for us is that if and when the default Sentry installation of the site we are part of captures the exception before us, ours (hub.captureException(errorEvent.error)
) will not go forward anymore because of the __sentry_captured__ flag. (BTW: The fact that the main site ALSO sends our exception to their DSN does not bother us, we just tell them to ignore them and both are fine with it).
My first thought was to just disable the flag before doing our capture, eg.
if (errorEvent.error.__sentry_captured__) {
errorEvent.error.__sentry_captured__ = false
}
hub.captureException(errorEvent.error)
but I soon realised that is not possible as it is set using Object.defineProperty
using default descriptor, and default descriptor means that both configurable
and writable
are false
.
Would it be possible to get an option to skip the check? So that I could do something like:
hub.captureException(errorEvent.error, { allowRecapturing: true })
or if not, would it at least be possible to set the __sentry_captured__
property so that configurable
and/or writable
would be set true
and leave us some leeway?