diff --git a/packages/browser/rollup.config.js b/packages/browser/rollup.config.js index e7edf544134c..426dc49c233f 100644 --- a/packages/browser/rollup.config.js +++ b/packages/browser/rollup.config.js @@ -17,6 +17,12 @@ const terserInstance = terser({ reserved: ['captureException', 'captureMessage', 'sentryWrapped'], properties: { regex: /^_[^_]/, + // This exclusion prevents most of the occurrences of the bug linked below: + // https://github.com/getsentry/sentry-javascript/issues/2622 + // The bug is caused by multiple SDK instances, where one is minified and one is using non-mangled code. + // Unfortunatelly we cannot fix it reliably (thus `typeof` check in the `InboundFilters` code), + // as we cannot force people using multiple instances in their apps to sync SDK versions. + reserved: ['_mergeOptions'], }, }, }); diff --git a/packages/core/src/integrations/inboundfilters.ts b/packages/core/src/integrations/inboundfilters.ts index 106cc10caa0f..61dfad5f47fd 100644 --- a/packages/core/src/integrations/inboundfilters.ts +++ b/packages/core/src/integrations/inboundfilters.ts @@ -46,10 +46,16 @@ export class InboundFilters implements Integration { if (self) { const client = hub.getClient(); const clientOptions = client ? client.getOptions() : {}; - const options = self._mergeOptions(clientOptions); - if (self._shouldDropEvent(event, options)) { - return null; + // This checks prevents most of the occurrences of the bug linked below: + // https://github.com/getsentry/sentry-javascript/issues/2622 + // The bug is caused by multiple SDK instances, where one is minified and one is using non-mangled code. + // Unfortunatelly we cannot fix it reliably (thus reserved property in rollup's terser config), + // as we cannot force people using multiple instances in their apps to sync SDK versions. + const options = typeof self._mergeOptions === 'function' ? self._mergeOptions(clientOptions) : {}; + if (typeof self._shouldDropEvent !== 'function') { + return event; } + return self._shouldDropEvent(event, options) ? null : event; } return event; });