mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Persist lost identities to storage for later analysis
This commit is contained in:
parent
f5d4acf53b
commit
8fcaa2cf56
@ -28,6 +28,7 @@ class PreferencesController {
|
|||||||
featureFlags: {},
|
featureFlags: {},
|
||||||
currentLocale: opts.initLangCode,
|
currentLocale: opts.initLangCode,
|
||||||
identities: {},
|
identities: {},
|
||||||
|
lostIdentities: {},
|
||||||
}, opts.initState)
|
}, opts.initState)
|
||||||
this.store = new ObservableStore(initState)
|
this.store = new ObservableStore(initState)
|
||||||
}
|
}
|
||||||
@ -106,18 +107,19 @@ class PreferencesController {
|
|||||||
* @returns {Promise<string>} selectedAddress the selected address.
|
* @returns {Promise<string>} selectedAddress the selected address.
|
||||||
*/
|
*/
|
||||||
syncAddresses (addresses) {
|
syncAddresses (addresses) {
|
||||||
const identities = this.store.getState().identities
|
let { identities, lostIdentities } = this.store.getState()
|
||||||
|
|
||||||
Object.keys(identities).forEach((identity) => {
|
Object.keys(identities).forEach((identity) => {
|
||||||
if (!addresses.includes(identity)) {
|
if (!addresses.includes(identity)) {
|
||||||
delete identities[identity]
|
delete identities[identity]
|
||||||
|
lostIdentities[identity] = identities[identity]
|
||||||
|
|
||||||
// TODO: Report the bug to Sentry including the now-lost identity.
|
// TODO: Report the bug to Sentry including the now-lost identity.
|
||||||
alert('Error 4486: MetaMask has encountered a very strange error. Please open a support issue immediately at support@metamask.io.')
|
alert('Error 4486: MetaMask has encountered a very strange error. Please open a support issue immediately at support@metamask.io.')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
this.store.updateState({ identities })
|
this.store.updateState({ identities, lostIdentities })
|
||||||
this.addAddresses(addresses)
|
this.addAddresses(addresses)
|
||||||
|
|
||||||
let selected = this.getSelectedAddress()
|
let selected = this.getSelectedAddress()
|
||||||
|
29
app/scripts/lib/4486-notifier.js
Normal file
29
app/scripts/lib/4486-notifier.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
class BugNotifier {
|
||||||
|
notify (message) {
|
||||||
|
|
||||||
|
postData('http://example.com/answer', {answer: 42})
|
||||||
|
.then(data => console.log(data)) // JSON from `response.json()` call
|
||||||
|
.catch(error => console.error(error))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function postData(url, data) {
|
||||||
|
// Default options are marked with *
|
||||||
|
return fetch(url, {
|
||||||
|
body: JSON.stringify(data), // must match 'Content-Type' header
|
||||||
|
cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
|
||||||
|
credentials: 'same-origin', // include, same-origin, *omit
|
||||||
|
headers: {
|
||||||
|
'user-agent': 'Mozilla/4.0 MDN Example',
|
||||||
|
'content-type': 'application/json'
|
||||||
|
},
|
||||||
|
method: 'POST', // *GET, POST, PUT, DELETE, etc.
|
||||||
|
mode: 'cors', // no-cors, cors, *same-origin
|
||||||
|
redirect: 'follow', // manual, *follow, error
|
||||||
|
referrer: 'no-referrer', // *client, no-referrer
|
||||||
|
})
|
||||||
|
.then(response => response.json()) // parses response to JSON
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = BugNotifier
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user