From e00982aa58362833bc19cc0dfdb400ab66c88b77 Mon Sep 17 00:00:00 2001 From: Jenny Pollack Date: Tue, 5 May 2020 06:40:36 -0700 Subject: [PATCH] add version dimension to metrics event (#8419) * add version dimension to metrics event * mock global.platform.getVersion Co-authored-by: Erik Marks --- development/mock-dev.js | 6 ++++++ docs/creating-metrics-events.md | 1 + .../metametrics/metametrics.provider.js | 4 ++++ ui/app/helpers/utils/metametrics.util.js | 7 +++++-- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/development/mock-dev.js b/development/mock-dev.js index d3524c467..6e3da391f 100644 --- a/development/mock-dev.js +++ b/development/mock-dev.js @@ -62,6 +62,11 @@ function updateQueryParams (newView) { // MetaMask Controller // +// some extension platform APIs must be mocked +function mockPlatformApis () { + global.platform.getVersion = () => '0.0.0' +} + const controller = new MetamaskController({ // User confirmation callbacks: showUnconfirmedMessage: noop, @@ -72,6 +77,7 @@ const controller = new MetamaskController({ }) global.metamaskController = controller global.platform = new ExtensionPlatform() +mockPlatformApis() // // User Interface diff --git a/docs/creating-metrics-events.md b/docs/creating-metrics-events.md index 7e7f2d77d..26fd8a6bb 100644 --- a/docs/creating-metrics-events.md +++ b/docs/creating-metrics-events.md @@ -39,6 +39,7 @@ All metrics events send the following data when called: - accountType - numberOfTokens - numberOfAccounts +- version These are added to the metrics event via the metametrics provider. diff --git a/ui/app/helpers/higher-order-components/metametrics/metametrics.provider.js b/ui/app/helpers/higher-order-components/metametrics/metametrics.provider.js index caacf7b12..e67ab9a21 100644 --- a/ui/app/helpers/higher-order-components/metametrics/metametrics.provider.js +++ b/ui/app/helpers/higher-order-components/metametrics/metametrics.provider.js @@ -32,6 +32,7 @@ class MetaMetricsProvider extends Component { numberOfTokens: PropTypes.number, numberOfAccounts: PropTypes.number, participateInMetaMetrics: PropTypes.bool, + version: PropTypes.string, } static childContextTypes = { @@ -66,6 +67,7 @@ class MetaMetricsProvider extends Component { metaMetricsSendCount, numberOfTokens, numberOfAccounts, + version, } = this.props const { previousPath, currentPath } = this.state @@ -86,6 +88,7 @@ class MetaMetricsProvider extends Component { metaMetricsId, numberOfTokens, numberOfAccounts, + version, ...config, previousPath, currentPath, @@ -116,6 +119,7 @@ const mapStateToProps = (state) => { metaMetricsSendCount: state.metamask.metaMetricsSendCount, numberOfTokens: getNumberOfTokens(state), numberOfAccounts: getNumberOfAccounts(state), + version: global.platform.getVersion(), } } diff --git a/ui/app/helpers/utils/metametrics.util.js b/ui/app/helpers/utils/metametrics.util.js index 16b964d19..07d47dd57 100644 --- a/ui/app/helpers/utils/metametrics.util.js +++ b/ui/app/helpers/utils/metametrics.util.js @@ -13,7 +13,7 @@ const METAMETRICS_TRACKING_URL = inDevelopment : 'http://www.metamask.io/metametrics-prod' /** ***************Custom variables*************** **/ -// Custon variable declarations +// Custom variable declarations const METAMETRICS_CUSTOM_GAS_LIMIT_CHANGE = 'gasLimitChange' const METAMETRICS_CUSTOM_GAS_PRICE_CHANGE = 'gasPriceChange' const METAMETRICS_CUSTOM_FUNCTION_TYPE = 'functionType' @@ -55,7 +55,7 @@ const METAMETRICS_CUSTOM_ACTIVE_CURRENCY = 'activeCurrency' const METAMETRICS_CUSTOM_ACCOUNT_TYPE = 'accountType' const METAMETRICS_CUSTOM_NUMBER_OF_TOKENS = 'numberOfTokens' const METAMETRICS_CUSTOM_NUMBER_OF_ACCOUNTS = 'numberOfAccounts' - +const METAMETRICS_CUSTOM_VERSION = 'version' const customDimensionsNameIdMap = { [METAMETRICS_CUSTOM_NETWORK]: 5, @@ -64,6 +64,7 @@ const customDimensionsNameIdMap = { [METAMETRICS_CUSTOM_ACCOUNT_TYPE]: 8, [METAMETRICS_CUSTOM_NUMBER_OF_TOKENS]: 9, [METAMETRICS_CUSTOM_NUMBER_OF_ACCOUNTS]: 10, + [METAMETRICS_CUSTOM_VERSION]: 11, } function composeUrlRefParamAddition (previousPath, confirmTransactionOrigin) { @@ -130,6 +131,7 @@ function composeUrl (config) { accountType, numberOfTokens, numberOfAccounts, + version, previousPath = '', currentPath, metaMetricsId, @@ -156,6 +158,7 @@ function composeUrl (config) { environmentType, activeCurrency, accountType, + version, numberOfTokens: (customVariables && customVariables.numberOfTokens) || numberOfTokens, numberOfAccounts: (customVariables && customVariables.numberOfAccounts) || numberOfAccounts, }) : ''