1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00

add version dimension to metrics event (#8419)

* add version dimension to metrics event

* mock global.platform.getVersion

Co-authored-by: Erik Marks <rekmarks@protonmail.com>
This commit is contained in:
Jenny Pollack 2020-05-05 06:40:36 -07:00 committed by GitHub
parent fda4c94670
commit e00982aa58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 2 deletions

View File

@ -62,6 +62,11 @@ function updateQueryParams (newView) {
// MetaMask Controller // MetaMask Controller
// //
// some extension platform APIs must be mocked
function mockPlatformApis () {
global.platform.getVersion = () => '0.0.0'
}
const controller = new MetamaskController({ const controller = new MetamaskController({
// User confirmation callbacks: // User confirmation callbacks:
showUnconfirmedMessage: noop, showUnconfirmedMessage: noop,
@ -72,6 +77,7 @@ const controller = new MetamaskController({
}) })
global.metamaskController = controller global.metamaskController = controller
global.platform = new ExtensionPlatform() global.platform = new ExtensionPlatform()
mockPlatformApis()
// //
// User Interface // User Interface

View File

@ -39,6 +39,7 @@ All metrics events send the following data when called:
- accountType - accountType
- numberOfTokens - numberOfTokens
- numberOfAccounts - numberOfAccounts
- version
These are added to the metrics event via the metametrics provider. These are added to the metrics event via the metametrics provider.

View File

@ -32,6 +32,7 @@ class MetaMetricsProvider extends Component {
numberOfTokens: PropTypes.number, numberOfTokens: PropTypes.number,
numberOfAccounts: PropTypes.number, numberOfAccounts: PropTypes.number,
participateInMetaMetrics: PropTypes.bool, participateInMetaMetrics: PropTypes.bool,
version: PropTypes.string,
} }
static childContextTypes = { static childContextTypes = {
@ -66,6 +67,7 @@ class MetaMetricsProvider extends Component {
metaMetricsSendCount, metaMetricsSendCount,
numberOfTokens, numberOfTokens,
numberOfAccounts, numberOfAccounts,
version,
} = this.props } = this.props
const { previousPath, currentPath } = this.state const { previousPath, currentPath } = this.state
@ -86,6 +88,7 @@ class MetaMetricsProvider extends Component {
metaMetricsId, metaMetricsId,
numberOfTokens, numberOfTokens,
numberOfAccounts, numberOfAccounts,
version,
...config, ...config,
previousPath, previousPath,
currentPath, currentPath,
@ -116,6 +119,7 @@ const mapStateToProps = (state) => {
metaMetricsSendCount: state.metamask.metaMetricsSendCount, metaMetricsSendCount: state.metamask.metaMetricsSendCount,
numberOfTokens: getNumberOfTokens(state), numberOfTokens: getNumberOfTokens(state),
numberOfAccounts: getNumberOfAccounts(state), numberOfAccounts: getNumberOfAccounts(state),
version: global.platform.getVersion(),
} }
} }

View File

@ -13,7 +13,7 @@ const METAMETRICS_TRACKING_URL = inDevelopment
: 'http://www.metamask.io/metametrics-prod' : 'http://www.metamask.io/metametrics-prod'
/** ***************Custom variables*************** **/ /** ***************Custom variables*************** **/
// Custon variable declarations // Custom variable declarations
const METAMETRICS_CUSTOM_GAS_LIMIT_CHANGE = 'gasLimitChange' const METAMETRICS_CUSTOM_GAS_LIMIT_CHANGE = 'gasLimitChange'
const METAMETRICS_CUSTOM_GAS_PRICE_CHANGE = 'gasPriceChange' const METAMETRICS_CUSTOM_GAS_PRICE_CHANGE = 'gasPriceChange'
const METAMETRICS_CUSTOM_FUNCTION_TYPE = 'functionType' 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_ACCOUNT_TYPE = 'accountType'
const METAMETRICS_CUSTOM_NUMBER_OF_TOKENS = 'numberOfTokens' const METAMETRICS_CUSTOM_NUMBER_OF_TOKENS = 'numberOfTokens'
const METAMETRICS_CUSTOM_NUMBER_OF_ACCOUNTS = 'numberOfAccounts' const METAMETRICS_CUSTOM_NUMBER_OF_ACCOUNTS = 'numberOfAccounts'
const METAMETRICS_CUSTOM_VERSION = 'version'
const customDimensionsNameIdMap = { const customDimensionsNameIdMap = {
[METAMETRICS_CUSTOM_NETWORK]: 5, [METAMETRICS_CUSTOM_NETWORK]: 5,
@ -64,6 +64,7 @@ const customDimensionsNameIdMap = {
[METAMETRICS_CUSTOM_ACCOUNT_TYPE]: 8, [METAMETRICS_CUSTOM_ACCOUNT_TYPE]: 8,
[METAMETRICS_CUSTOM_NUMBER_OF_TOKENS]: 9, [METAMETRICS_CUSTOM_NUMBER_OF_TOKENS]: 9,
[METAMETRICS_CUSTOM_NUMBER_OF_ACCOUNTS]: 10, [METAMETRICS_CUSTOM_NUMBER_OF_ACCOUNTS]: 10,
[METAMETRICS_CUSTOM_VERSION]: 11,
} }
function composeUrlRefParamAddition (previousPath, confirmTransactionOrigin) { function composeUrlRefParamAddition (previousPath, confirmTransactionOrigin) {
@ -130,6 +131,7 @@ function composeUrl (config) {
accountType, accountType,
numberOfTokens, numberOfTokens,
numberOfAccounts, numberOfAccounts,
version,
previousPath = '', previousPath = '',
currentPath, currentPath,
metaMetricsId, metaMetricsId,
@ -156,6 +158,7 @@ function composeUrl (config) {
environmentType, environmentType,
activeCurrency, activeCurrency,
accountType, accountType,
version,
numberOfTokens: (customVariables && customVariables.numberOfTokens) || numberOfTokens, numberOfTokens: (customVariables && customVariables.numberOfTokens) || numberOfTokens,
numberOfAccounts: (customVariables && customVariables.numberOfAccounts) || numberOfAccounts, numberOfAccounts: (customVariables && customVariables.numberOfAccounts) || numberOfAccounts,
}) : '' }) : ''