Skip to content

Commit 76cc560

Browse files
authored
fix: Prevent InboundFilters mergeOptions method from breaking users code (#3458)
* fix: Prevent InboundFilters mergeOptions method from breaking users code
1 parent e5a1771 commit 76cc560

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

packages/browser/rollup.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ const terserInstance = terser({
1717
reserved: ['captureException', 'captureMessage', 'sentryWrapped'],
1818
properties: {
1919
regex: /^_[^_]/,
20+
// This exclusion prevents most of the occurrences of the bug linked below:
21+
// https://github.com/getsentry/sentry-javascript/issues/2622
22+
// The bug is caused by multiple SDK instances, where one is minified and one is using non-mangled code.
23+
// Unfortunatelly we cannot fix it reliably (thus `typeof` check in the `InboundFilters` code),
24+
// as we cannot force people using multiple instances in their apps to sync SDK versions.
25+
reserved: ['_mergeOptions'],
2026
},
2127
},
2228
});

packages/core/src/integrations/inboundfilters.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,16 @@ export class InboundFilters implements Integration {
4646
if (self) {
4747
const client = hub.getClient();
4848
const clientOptions = client ? client.getOptions() : {};
49-
const options = self._mergeOptions(clientOptions);
50-
if (self._shouldDropEvent(event, options)) {
51-
return null;
49+
// This checks prevents most of the occurrences of the bug linked below:
50+
// https://github.com/getsentry/sentry-javascript/issues/2622
51+
// The bug is caused by multiple SDK instances, where one is minified and one is using non-mangled code.
52+
// Unfortunatelly we cannot fix it reliably (thus reserved property in rollup's terser config),
53+
// as we cannot force people using multiple instances in their apps to sync SDK versions.
54+
const options = typeof self._mergeOptions === 'function' ? self._mergeOptions(clientOptions) : {};
55+
if (typeof self._shouldDropEvent !== 'function') {
56+
return event;
5257
}
58+
return self._shouldDropEvent(event, options) ? null : event;
5359
}
5460
return event;
5561
});

0 commit comments

Comments
 (0)