2021-02-04 19:15:23 +01:00
|
|
|
import setupSentry from './lib/setupSentry';
|
2020-11-24 04:26:43 +01:00
|
|
|
|
2022-08-24 14:20:45 +02:00
|
|
|
// The root compartment will populate this with hooks
|
2022-11-09 20:28:32 +01:00
|
|
|
global.stateHooks = {};
|
2022-08-24 14:20:45 +02:00
|
|
|
|
2020-11-24 04:26:43 +01:00
|
|
|
// setup sentry error reporting
|
|
|
|
global.sentry = setupSentry({
|
|
|
|
release: process.env.METAMASK_VERSION,
|
2022-11-09 20:28:32 +01:00
|
|
|
getState: () => global.stateHooks?.getSentryState?.() || {},
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2023-07-26 14:13:28 +02:00
|
|
|
|
|
|
|
/**
|
2023-07-31 23:19:32 +02:00
|
|
|
* As soon as state is available via getSentryState we can start automatic
|
2023-07-26 14:13:28 +02:00
|
|
|
* session tracking.
|
|
|
|
*/
|
2023-07-31 23:19:32 +02:00
|
|
|
async function waitForStateHooks() {
|
2023-07-26 14:13:28 +02:00
|
|
|
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.
|
2023-07-31 23:19:32 +02:00
|
|
|
await global.sentry?.startSession();
|
2023-07-26 14:13:28 +02:00
|
|
|
} else {
|
|
|
|
setTimeout(waitForStateHooks, 100);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
waitForStateHooks();
|