From c9baf39c4da063a7f1722fc11ca009ec67fcbf73 Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Fri, 19 Nov 2021 14:07:50 -0330 Subject: [PATCH] Ensure that metametrics error related to anonymousId is not sent to sentry (#12763) --- app/scripts/controllers/metametrics.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/scripts/controllers/metametrics.js b/app/scripts/controllers/metametrics.js index 28e84d7b0..9e6ecfff7 100644 --- a/app/scripts/controllers/metametrics.js +++ b/app/scripts/controllers/metametrics.js @@ -15,6 +15,10 @@ const defaultCaptureException = (err) => { }); }; +const exceptionsToFilter = { + [`You must pass either an "anonymousId" or a "userId".`]: true, +}; + /** * @typedef {import('../../../shared/constants/metametrics').MetaMetricsContext} MetaMetricsContext * @typedef {import('../../../shared/constants/metametrics').MetaMetricsEventPayload} MetaMetricsEventPayload @@ -61,7 +65,13 @@ export default class MetaMetricsController { initState, captureException = defaultCaptureException, }) { - this._captureException = captureException; + this._captureException = (err) => { + // This is a temporary measure. Currently there are errors flooding sentry due to a problem in how we are tracking anonymousId + // We intend on removing this as soon as we understand how to correctly solve that problem. + if (!exceptionsToFilter[err.message]) { + captureException(err); + } + }; const prefState = preferencesStore.getState(); this.chainId = getCurrentChainId(); this.network = getNetworkIdentifier();