mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-25 11:28:51 +01:00
507c2cb475
* Capture Sentry errors prior to initialization Sentry errors captured before/during the wallet initialization are currently not captured because we don't have the controller state yet to determine whether the user has consented. The Sentry setup has been updated to check the persisted state for whether the user has consented, as a fallback in case the controller state hasn't been initialized yet. This ensures that we capture errors during initialization if the user has opted in. * Always await async check for whether the user has opted in * Remove unused import * Update JSDoc return type * Remove unused driver method * Fix metametrics controller unit tests * Fix e2e tests * Fix e2e test on Firefox * Start session upon install rather than toggle
29 lines
850 B
JavaScript
29 lines
850 B
JavaScript
import setupSentry from './lib/setupSentry';
|
|
|
|
// The root compartment will populate this with hooks
|
|
global.stateHooks = {};
|
|
|
|
// setup sentry error reporting
|
|
global.sentry = setupSentry({
|
|
release: process.env.METAMASK_VERSION,
|
|
getState: () => global.stateHooks?.getSentryState?.() || {},
|
|
});
|
|
|
|
/**
|
|
* As soon as state is available via getSentryState we can start automatic
|
|
* session tracking.
|
|
*/
|
|
async function waitForStateHooks() {
|
|
if (global.stateHooks.getSentryState) {
|
|
// sentry is not defined in dev mode, so if sentry doesn't exist at this
|
|
// point it means that we are in dev mode and do not need to toggle the
|
|
// session. Using optional chaining is sufficient to prevent the error in
|
|
// development.
|
|
await global.sentry?.startSession();
|
|
} else {
|
|
setTimeout(waitForStateHooks, 100);
|
|
}
|
|
}
|
|
|
|
waitForStateHooks();
|