From 4d499cc39e024319e16b440a47c3c58fb9f4abcc Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Mon, 10 Aug 2020 12:10:30 -0300 Subject: [PATCH 1/6] Add `version` dimension to background metrics (#9167) The background metrics were missing the `version` custom dimension. It has now been added to all background metric events. --- app/scripts/lib/background-metametrics.js | 3 ++- app/scripts/metamask-controller.js | 17 +++++++++++------ ui/app/helpers/utils/metametrics.util.js | 1 + 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/scripts/lib/background-metametrics.js b/app/scripts/lib/background-metametrics.js index 9905e115b..a9baa79b7 100644 --- a/app/scripts/lib/background-metametrics.js +++ b/app/scripts/lib/background-metametrics.js @@ -1,7 +1,7 @@ import { getBackgroundMetaMetricState } from '../../../ui/app/selectors' import { sendMetaMetricsEvent } from '../../../ui/app/helpers/utils/metametrics.util' -export default function backgroundMetaMetricsEvent (metaMaskState, eventData) { +export default function backgroundMetaMetricsEvent (metaMaskState, version, eventData) { eventData.eventOpts['category'] = 'Background' @@ -10,6 +10,7 @@ export default function backgroundMetaMetricsEvent (metaMaskState, eventData) { sendMetaMetricsEvent({ ...stateEventData, ...eventData, + version, currentPath: '/background', }) } diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index f9821e822..b0866ce08 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -1842,13 +1842,18 @@ export default class MetamaskController extends EventEmitter { } const metamaskState = await this.getState() - backgroundMetaMetricsEvent(metamaskState, { - customVariables, - eventOpts: { - action, - name, + const version = this.platform.getVersion() + backgroundMetaMetricsEvent( + metamaskState, + version, + { + customVariables, + eventOpts: { + action, + name, + }, }, - }) + ) } //============================================================================= diff --git a/ui/app/helpers/utils/metametrics.util.js b/ui/app/helpers/utils/metametrics.util.js index cf9f15720..0ffe856bf 100644 --- a/ui/app/helpers/utils/metametrics.util.js +++ b/ui/app/helpers/utils/metametrics.util.js @@ -115,6 +115,7 @@ function composeParamAddition (paramValue, paramName) { * @property {string} config.accountType The account type being used at the time of the event: 'hardware', 'imported' or 'default' * @property {number} config.numberOfTokens The number of tokens that the user has added at the time of the event * @property {number} config.numberOfAccounts The number of accounts the user has added at the time of the event + * @property {string} config.version The current version of the MetaMask extension * @property {string} config.previousPath The pathname of the URL the user was on prior to the URL they are on at the time of the event * @property {string} config.currentPath The pathname of the URL the user is on at the time of the event * @property {string} config.metaMetricsId A random id assigned to a user at the time of opting in to metametrics. A hexadecimal number From 74decc3407e852cc9eb8940e7e520797d2835580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20=C5=81ucka?= Date: Thu, 13 Aug 2020 18:21:31 +0200 Subject: [PATCH 2/6] Fix Etherscan redirect on notification click (#9211) --- app/scripts/platforms/extension.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/scripts/platforms/extension.js b/app/scripts/platforms/extension.js index f62ef98e4..11340c8cc 100644 --- a/app/scripts/platforms/extension.js +++ b/app/scripts/platforms/extension.js @@ -223,7 +223,7 @@ export default class ExtensionPlatform { } _viewOnEtherscan (txId) { - if (txId.startsWith('http://')) { + if (txId.startsWith('https://')) { extension.tabs.create({ url: txId }) } } From d49c44426fb98dcd95e76659bca39e6c76e87a6f Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Fri, 14 Aug 2020 19:15:21 -0300 Subject: [PATCH 3/6] Send web3 usage metrics once per origin/property (#9237) The usage metrics for the injected web3 instance were being sent upon each use, which exceeded the limits of our Matomo plan. These metrics are now only being sent upon the first usage, for each origin and property. --- app/scripts/lib/createMethodMiddleware.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/app/scripts/lib/createMethodMiddleware.js b/app/scripts/lib/createMethodMiddleware.js index 308cf0a99..a2b466be1 100644 --- a/app/scripts/lib/createMethodMiddleware.js +++ b/app/scripts/lib/createMethodMiddleware.js @@ -1,3 +1,6 @@ + +const recordedWeb3Usage = {} + /** * Returns a middleware that implements the following RPC methods: * - metamask_logInjectedWeb3Usage @@ -15,11 +18,17 @@ export default function createMethodMiddleware ({ origin, sendMetrics }) { const { action, name } = req.params[0] - sendMetrics({ - action, - name, - customVariables: { origin }, - }) + if (!recordedWeb3Usage[origin]) { + recordedWeb3Usage[origin] = {} + } + if (!recordedWeb3Usage[origin][name]) { + recordedWeb3Usage[origin][name] = true + sendMetrics({ + action, + name, + customVariables: { origin }, + }) + } res.result = true break From e47774d3e4ae758c4bd28cdffdc139bd8d761483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20=C5=81ucka?= Date: Sat, 15 Aug 2020 00:18:46 +0200 Subject: [PATCH 4/6] Permit all-caps addresses (#9227) * permit all-caps addresses * handle empty address --- ui/app/helpers/utils/util.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/app/helpers/utils/util.js b/ui/app/helpers/utils/util.js index 7643519a8..a6726cdba 100644 --- a/ui/app/helpers/utils/util.js +++ b/ui/app/helpers/utils/util.js @@ -62,11 +62,11 @@ export function addressSummary (address, firstSegLength = 10, lastSegLength = 4, } export function isValidAddress (address) { - const prefixed = ethUtil.addHexPrefix(address) - if (address === '0x0000000000000000000000000000000000000000') { + if (!address || address === '0x0000000000000000000000000000000000000000') { return false } - return (isAllOneCase(prefixed) && ethUtil.isValidAddress(prefixed)) || ethUtil.isValidChecksumAddress(prefixed) + const prefixed = address.startsWith('0X') ? address : ethUtil.addHexPrefix(address) + return (isAllOneCase(prefixed.slice(2)) && ethUtil.isValidAddress(prefixed)) || ethUtil.isValidChecksumAddress(prefixed) } export function isValidDomainName (address) { From 5db866bc880c86974429bc6473c00c96032278ad Mon Sep 17 00:00:00 2001 From: MetaMask Bot Date: Fri, 14 Aug 2020 22:38:18 +0000 Subject: [PATCH 5/6] Version v8.0.8 --- CHANGELOG.md | 2 ++ app/manifest/_base.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c77b4b186..318d07be5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Current Develop Branch +## 8.0.8 Fri Aug 14 2020 + ## 8.0.7 Fri Aug 07 2020 - [#9065](https://github.com/MetaMask/metamask-extension/pull/9065): Change title of "Reveal Seed Words" page to "Reveal Seed Phrase" - [#8974](https://github.com/MetaMask/metamask-extension/pull/8974): Add tooltip to copy button for contacts and seed phrase diff --git a/app/manifest/_base.json b/app/manifest/_base.json index 962500a78..07f92b3b4 100644 --- a/app/manifest/_base.json +++ b/app/manifest/_base.json @@ -1,7 +1,7 @@ { "name": "__MSG_appName__", "short_name": "__MSG_appName__", - "version": "8.0.7", + "version": "8.0.8", "manifest_version": 2, "author": "https://metamask.io", "description": "__MSG_appDescription__", From e8a468a5ec23d6356cf0829bbd316b2976d1b9de Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Fri, 14 Aug 2020 20:05:14 -0300 Subject: [PATCH 6/6] Update v8.0.8 changelog (#9241) --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 318d07be5..8da4dd1ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ ## Current Develop Branch ## 8.0.8 Fri Aug 14 2020 +- [#9211](https://github.com/MetaMask/metamask-extension/pull/9211): Fix Etherscan redirect on notification click +- [#9237](https://github.com/MetaMask/metamask-extension/pull/9237): Reduce volume of web3 usage metrics +- [#9227](https://github.com/MetaMask/metamask-extension/pull/9227): Permit all-caps addresses ## 8.0.7 Fri Aug 07 2020 - [#9065](https://github.com/MetaMask/metamask-extension/pull/9065): Change title of "Reveal Seed Words" page to "Reveal Seed Phrase"