aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorDan J Miller <danjm.com@gmail.com>2019-05-21 01:32:26 +0800
committerWhymarrh Whitby <whymarrh.whitby@gmail.com>2019-05-21 01:32:26 +0800
commit32547383603b24849db8f83103ec72c0b3dc29ed (patch)
treee3bb2c166fd8e02494c164d2433f0259d84bb67b /ui
parentcfee7e8bb4ebccc6806ec766b09a4edae81133ee (diff)
downloadtangerine-wallet-browser-32547383603b24849db8f83103ec72c0b3dc29ed.tar
tangerine-wallet-browser-32547383603b24849db8f83103ec72c0b3dc29ed.tar.gz
tangerine-wallet-browser-32547383603b24849db8f83103ec72c0b3dc29ed.tar.bz2
tangerine-wallet-browser-32547383603b24849db8f83103ec72c0b3dc29ed.tar.lz
tangerine-wallet-browser-32547383603b24849db8f83103ec72c0b3dc29ed.tar.xz
tangerine-wallet-browser-32547383603b24849db8f83103ec72c0b3dc29ed.tar.zst
tangerine-wallet-browser-32547383603b24849db8f83103ec72c0b3dc29ed.zip
MetaMetrics documentation (#6624)
Diffstat (limited to 'ui')
-rw-r--r--ui/app/helpers/utils/metametrics.util.js53
1 files changed, 44 insertions, 9 deletions
diff --git a/ui/app/helpers/utils/metametrics.util.js b/ui/app/helpers/utils/metametrics.util.js
index cafbd5c07..50270c6a8 100644
--- a/ui/app/helpers/utils/metametrics.util.js
+++ b/ui/app/helpers/utils/metametrics.util.js
@@ -12,6 +12,8 @@ const METAMETRICS_TRACKING_URL = inDevelopment
? 'http://www.metamask.io/metametrics'
: 'http://www.metamask.io/metametrics-prod'
+/** ***************Custom variables*************** **/
+// Custon variable declarations
const METAMETRICS_CUSTOM_GAS_LIMIT_CHANGE = 'gasLimitChange'
const METAMETRICS_CUSTOM_GAS_PRICE_CHANGE = 'gasPriceChange'
const METAMETRICS_CUSTOM_FUNCTION_TYPE = 'functionType'
@@ -24,13 +26,7 @@ const METAMETRICS_CUSTOM_ERROR_MESSAGE = 'errorMessage'
const METAMETRICS_CUSTOM_RPC_NETWORK_ID = 'networkId'
const METAMETRICS_CUSTOM_RPC_CHAIN_ID = 'chainId'
const METAMETRICS_CUSTOM_GAS_CHANGED = 'gasChanged'
-
-const METAMETRICS_CUSTOM_NETWORK = 'network'
-const METAMETRICS_CUSTOM_ENVIRONMENT_TYPE = 'environmentType'
-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_ASSET_SELECTED = 'assetSelected'
const customVariableNameIdMap = {
[METAMETRICS_CUSTOM_FUNCTION_TYPE]: 1,
@@ -38,14 +34,28 @@ const customVariableNameIdMap = {
[METAMETRICS_CUSTOM_CONFIRM_SCREEN_ORIGIN]: 3,
[METAMETRICS_CUSTOM_GAS_LIMIT_CHANGE]: 4,
[METAMETRICS_CUSTOM_GAS_PRICE_CHANGE]: 5,
+
[METAMETRICS_CUSTOM_FROM_NETWORK]: 1,
[METAMETRICS_CUSTOM_TO_NETWORK]: 2,
+
[METAMETRICS_CUSTOM_RPC_NETWORK_ID]: 1,
[METAMETRICS_CUSTOM_RPC_CHAIN_ID]: 2,
- [METAMETRICS_CUSTOM_ERROR_FIELD]: 1,
- [METAMETRICS_CUSTOM_ERROR_MESSAGE]: 2,
+
+ [METAMETRICS_CUSTOM_ERROR_FIELD]: 3,
+ [METAMETRICS_CUSTOM_ERROR_MESSAGE]: 4,
+
[METAMETRICS_CUSTOM_GAS_CHANGED]: 1,
+ [METAMETRICS_CUSTOM_ASSET_SELECTED]: 2,
}
+/** ********************************************************** **/
+
+const METAMETRICS_CUSTOM_NETWORK = 'network'
+const METAMETRICS_CUSTOM_ENVIRONMENT_TYPE = 'environmentType'
+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 customDimensionsNameIdMap = {
[METAMETRICS_CUSTOM_NETWORK]: 5,
@@ -61,6 +71,7 @@ function composeUrlRefParamAddition (previousPath, confirmTransactionOrigin) {
return `&urlref=${externalOrigin ? 'EXTERNAL' : encodeURIComponent(previousPath.replace(/chrome-extension:\/\/\w+/, METAMETRICS_TRACKING_URL))}`
}
+// composes query params of the form &dimension[0-999]=[value]
function composeCustomDimensionParamAddition (customDimensions) {
const customDimensionParamStrings = Object.keys(customDimensions).reduce((acc, name) => {
return [...acc, `dimension${customDimensionsNameIdMap[name]}=${customDimensions[name]}`]
@@ -68,6 +79,8 @@ function composeCustomDimensionParamAddition (customDimensions) {
return `&${customDimensionParamStrings.join('&')}`
}
+// composes query params in form: &cvar={[id]:[[name],[value]]}
+// Example: &cvar={"1":["OS","iphone 5.0"],"2":["Matomo Mobile Version","1.6.2"],"3":["Locale","en::en"],"4":["Num Accounts","2"]}
function composeCustomVarParamAddition (customVariables) {
const customVariableIdValuePairs = Object.keys(customVariables).reduce((acc, name) => {
return {
@@ -84,6 +97,28 @@ function composeParamAddition (paramValue, paramName) {
: `&${paramName}=${paramValue}`
}
+/**
+ * @name composeUrl
+ * @param {Object} config - configuration object for composing the metametrics url
+ * @property {object} config.eventOpts Object containing event category, action and name descriptors
+ * @property {object} config.customVariables Object containing custom properties with values relevant to a specific event
+ * @property {object} config.pageOpts Objects containing information about a page/route the event is dispatched from
+ * @property {number} config.network The selected network of the user when the event occurs
+ * @property {string} config.environmentType The "environment" the user is using the app from: 'popup', 'notification' or 'fullscreen'
+ * @property {string} config.activeCurrency The current the user has select as their primary currency at the time of the event
+ * @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.previousPath The location path the user was on prior to the path they are on at the time of the event
+ * @property {string} config.currentPath The location path 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
+ * @property {string} config.confirmTransactionOrigin The origin on a transaction
+ * @property {string} config.url The url to track an event at. Overrides `currentPath`
+ * @property {boolean} config.excludeMetaMetricsId Whether or not the tracked event data should be associated with a metametrics id
+ * @property {boolean} config.isNewVisit Whether or not the event should be tracked as a new visit/user sessions
+ * @returns {String} Returns a url to be passed to fetch to make the appropriate request to matomo.
+ * Example: https://chromeextensionmm.innocraft.cloud/piwik.php?idsite=1&rec=1&apiv=1&e_c=Navigation&e_a=Home&e_n=Clicked%20Send:%20Eth&urlref=http%3A%2F%2Fwww.metamask.io%2Fmetametrics%2Fhome.html%23send&dimension5=3&dimension6=fullscreen&dimension7=ETH&dimension8=default&dimension9=0&dimension10=3&url=http%3A%2F%2Fwww.metamask.io%2Fmetametrics%2Fhome.html%23&_id=49c10aff19795e9a&rand=7906028754863992&pv_id=53acad&uid=49c1
+ */
function composeUrl (config) {
const {
eventOpts = {},