mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-22 09:23:21 +01:00
refactor sentryHooks object (#16435)
This commit is contained in:
parent
25bb6ef861
commit
6cca9892b2
@ -79,7 +79,7 @@ const localStore = inTest ? new ReadOnlyNetworkStore() : new LocalStore();
|
||||
let versionedData;
|
||||
|
||||
if (inTest || process.env.METAMASK_DEBUG) {
|
||||
global.metamaskGetState = localStore.get.bind(localStore);
|
||||
global.stateHooks.metamaskGetState = localStore.get.bind(localStore);
|
||||
}
|
||||
|
||||
const phishingPageUrl = new URL(process.env.PHISHING_WARNING_PAGE_URL);
|
||||
@ -753,7 +753,7 @@ browser.runtime.onInstalled.addListener(({ reason }) => {
|
||||
});
|
||||
|
||||
function setupSentryGetStateGlobal(store) {
|
||||
global.sentryHooks.getSentryState = function () {
|
||||
global.stateHooks.getSentryState = function () {
|
||||
const fullState = store.getState();
|
||||
const debugState = maskObject({ metamask: fullState }, SENTRY_STATE);
|
||||
return {
|
||||
|
@ -1,10 +1,10 @@
|
||||
import setupSentry from './lib/setupSentry';
|
||||
|
||||
// The root compartment will populate this with hooks
|
||||
global.sentryHooks = {};
|
||||
global.stateHooks = {};
|
||||
|
||||
// setup sentry error reporting
|
||||
global.sentry = setupSentry({
|
||||
release: process.env.METAMASK_VERSION,
|
||||
getState: () => global.sentryHooks?.getSentryState?.() || {},
|
||||
getState: () => global.stateHooks?.getSentryState?.() || {},
|
||||
});
|
||||
|
@ -4,12 +4,12 @@ Fixture data can be generated by following these steps:
|
||||
|
||||
1. Load the unpacked extension in development or test mode
|
||||
2. Inspecting the background context of the extension
|
||||
3. Call `metamaskGetState`, then call [`copy`][1] on the results
|
||||
3. Call `stateHooks.metamaskGetState`, then call [`copy`][1] on the results
|
||||
|
||||
You can then paste the contents directly in your fixture file.
|
||||
|
||||
```js
|
||||
copy(await metamaskGetState())
|
||||
copy(await stateHooks.metamaskGetState())
|
||||
```
|
||||
|
||||
|
||||
|
@ -405,7 +405,9 @@ class Driver {
|
||||
const htmlSource = await this.driver.getPageSource();
|
||||
await fs.writeFile(`${filepathBase}-dom.html`, htmlSource);
|
||||
const uiState = await this.driver.executeScript(
|
||||
() => window.getCleanAppState && window.getCleanAppState(),
|
||||
() =>
|
||||
window.stateHooks.getCleanAppState &&
|
||||
window.stateHooks.getCleanAppState(),
|
||||
);
|
||||
await fs.writeFile(
|
||||
`${filepathBase}-state.json`,
|
||||
|
@ -164,7 +164,7 @@ async function startApp(metamaskState, backgroundConnection, opts) {
|
||||
}
|
||||
|
||||
function setupDebuggingHelpers(store) {
|
||||
window.getCleanAppState = async function () {
|
||||
window.stateHooks.getCleanAppState = async function () {
|
||||
const state = clone(store.getState());
|
||||
state.version = global.platform.getVersion();
|
||||
state.browser = window.navigator.userAgent;
|
||||
@ -173,7 +173,7 @@ function setupDebuggingHelpers(store) {
|
||||
});
|
||||
return state;
|
||||
};
|
||||
window.sentryHooks.getSentryState = function () {
|
||||
window.stateHooks.getSentryState = function () {
|
||||
const fullState = store.getState();
|
||||
const debugState = maskObject(fullState, SENTRY_STATE);
|
||||
return {
|
||||
@ -185,7 +185,7 @@ function setupDebuggingHelpers(store) {
|
||||
}
|
||||
|
||||
window.logStateString = async function (cb) {
|
||||
const state = await window.getCleanAppState();
|
||||
const state = await window.stateHooks.getCleanAppState();
|
||||
browser.runtime
|
||||
.getPlatformInfo()
|
||||
.then((platform) => {
|
||||
|
Loading…
Reference in New Issue
Block a user