1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 03:12:42 +02:00

Split Sentry mask into UI and background masks (#20426)

The state mask used to anonymize the Sentry state snapshots has been
split into UI and background masks. This was done to simplify later
refactors. There should be no functional changes.
This commit is contained in:
Mark Stacey 2023-08-16 14:40:44 -02:30 committed by Dan Miller
parent 83c8a6be99
commit d610aad2fd
3 changed files with 64 additions and 56 deletions

View File

@ -41,7 +41,7 @@ import Migrator from './lib/migrator';
import ExtensionPlatform from './platforms/extension'; import ExtensionPlatform from './platforms/extension';
import LocalStore from './lib/local-store'; import LocalStore from './lib/local-store';
import ReadOnlyNetworkStore from './lib/network-store'; import ReadOnlyNetworkStore from './lib/network-store';
import { SENTRY_STATE } from './lib/setupSentry'; import { SENTRY_BACKGROUND_STATE } from './lib/setupSentry';
import createStreamSink from './lib/createStreamSink'; import createStreamSink from './lib/createStreamSink';
import NotificationManager, { import NotificationManager, {
@ -876,11 +876,14 @@ browser.runtime.onInstalled.addListener(({ reason }) => {
function setupSentryGetStateGlobal(store) { function setupSentryGetStateGlobal(store) {
global.stateHooks.getSentryState = function () { global.stateHooks.getSentryState = function () {
const fullState = store.getState(); const backgroundState = store.getState();
const debugState = maskObject({ metamask: fullState }, SENTRY_STATE); const maskedBackgroundState = maskObject(
backgroundState,
SENTRY_BACKGROUND_STATE,
);
return { return {
browser: window.navigator.userAgent, browser: window.navigator.userAgent,
store: debugState, store: { metamask: maskedBackgroundState },
version: platform.getVersion(), version: platform.getVersion(),
}; };
}; };

View File

@ -23,13 +23,10 @@ export const ERROR_URL_ALLOWLIST = {
SEGMENT: 'segment.io', SEGMENT: 'segment.io',
}; };
// This describes the subset of Redux state attached to errors sent to Sentry // This describes the subset of background controller state attached to errors
// These properties have some potential to be useful for debugging, and they do // sent to Sentry These properties have some potential to be useful for
// not contain any identifiable information. // debugging, and they do not contain any identifiable information.
export const SENTRY_STATE = { export const SENTRY_BACKGROUND_STATE = {
gas: true,
history: true,
metamask: {
alertEnabledness: true, alertEnabledness: true,
completedOnboarding: true, completedOnboarding: true,
connectedStatusPopoverHasBeenShown: true, connectedStatusPopoverHasBeenShown: true,
@ -75,7 +72,15 @@ export const SENTRY_STATE = {
useNonceField: true, useNonceField: true,
usePhishDetect: true, usePhishDetect: true,
welcomeScreenSeen: true, welcomeScreenSeen: true,
}, };
// This describes the subset of Redux state attached to errors sent to Sentry
// These properties have some potential to be useful for debugging, and they do
// not contain any identifiable information.
export const SENTRY_UI_STATE = {
gas: true,
history: true,
metamask: SENTRY_BACKGROUND_STATE,
unconnectedAccount: true, unconnectedAccount: true,
}; };

View File

@ -8,7 +8,7 @@ import browser from 'webextension-polyfill';
import { getEnvironmentType } from '../app/scripts/lib/util'; import { getEnvironmentType } from '../app/scripts/lib/util';
import { AlertTypes } from '../shared/constants/alerts'; import { AlertTypes } from '../shared/constants/alerts';
import { maskObject } from '../shared/modules/object.utils'; import { maskObject } from '../shared/modules/object.utils';
import { SENTRY_STATE } from '../app/scripts/lib/setupSentry'; import { SENTRY_UI_STATE } from '../app/scripts/lib/setupSentry';
import { ENVIRONMENT_TYPE_POPUP } from '../shared/constants/app'; import { ENVIRONMENT_TYPE_POPUP } from '../shared/constants/app';
import switchDirection from '../shared/lib/switch-direction'; import switchDirection from '../shared/lib/switch-direction';
import { setupLocale } from '../shared/lib/error-utils'; import { setupLocale } from '../shared/lib/error-utils';
@ -234,11 +234,11 @@ function setupStateHooks(store) {
return state; return state;
}; };
window.stateHooks.getSentryState = function () { window.stateHooks.getSentryState = function () {
const fullState = store.getState(); const reduxState = store.getState();
const debugState = maskObject(fullState, SENTRY_STATE); const maskedReduxState = maskObject(reduxState, SENTRY_UI_STATE);
return { return {
browser: window.navigator.userAgent, browser: window.navigator.userAgent,
store: debugState, store: maskedReduxState,
version: global.platform.getVersion(), version: global.platform.getVersion(),
}; };
}; };