From 62d5e47bcbea6853be0b8a9ed30434e1204b3970 Mon Sep 17 00:00:00 2001 From: Whymarrh Whitby Date: Fri, 13 Dec 2019 12:03:50 -0330 Subject: [PATCH] Remove unused DiagnosticsReporter class (#7701) --- app/scripts/lib/diagnostics-reporter.js | 71 ------------------------- 1 file changed, 71 deletions(-) delete mode 100644 app/scripts/lib/diagnostics-reporter.js diff --git a/app/scripts/lib/diagnostics-reporter.js b/app/scripts/lib/diagnostics-reporter.js deleted file mode 100644 index 569eb3268..000000000 --- a/app/scripts/lib/diagnostics-reporter.js +++ /dev/null @@ -1,71 +0,0 @@ -class DiagnosticsReporter { - - constructor ({ firstTimeInfo, version }) { - this.firstTimeInfo = firstTimeInfo - this.version = version - } - - async reportOrphans (orphans) { - try { - return await this.submit({ - accounts: Object.keys(orphans), - metadata: { - type: 'orphans', - }, - }) - } catch (err) { - console.error('DiagnosticsReporter - "reportOrphans" encountered an error:') - console.error(err) - } - } - - async reportMultipleKeyrings (rawKeyrings) { - try { - const keyrings = await Promise.all(rawKeyrings.map(async (keyring, index) => { - return { - index, - type: keyring.type, - accounts: await keyring.getAccounts(), - } - })) - return await this.submit({ - accounts: [], - metadata: { - type: 'keyrings', - keyrings, - }, - }) - } catch (err) { - console.error('DiagnosticsReporter - "reportMultipleKeyrings" encountered an error:') - console.error(err) - } - } - - async submit (message) { - try { - // add metadata - message.metadata.version = this.version - message.metadata.firstTimeInfo = this.firstTimeInfo - return await postData(message) - } catch (err) { - console.error('DiagnosticsReporter - "submit" encountered an error:') - throw err - } - } - -} - -function postData (data) { - const uri = 'https://diagnostics.metamask.io/v1/orphanedAccounts' - return fetch(uri, { - body: JSON.stringify(data), // must match 'Content-Type' header - credentials: 'same-origin', // include, same-origin, *omit - headers: { - 'content-type': 'application/json', - }, - method: 'POST', // *GET, POST, PUT, DELETE, etc. - mode: 'cors', // no-cors, cors, *same-origin - }) -} - -module.exports = DiagnosticsReporter