diff options
author | Thomas Huang <tmashuang@users.noreply.github.com> | 2019-06-05 05:55:56 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-05 05:55:56 +0800 |
commit | be911711942914e7f6df535afff1a3ee87e23b6f (patch) | |
tree | bbd890e0a6a1bd72d2560e734ce66ed42a294722 /docs/creating-metrics-events.md | |
parent | 3d7bdd6ecb5e8e17cb8ccf83f56ad389971332c1 (diff) | |
parent | 28e030a11d75df81e16f3ebf726bfc59fcee679e (diff) | |
download | tangerine-wallet-browser-be911711942914e7f6df535afff1a3ee87e23b6f.tar tangerine-wallet-browser-be911711942914e7f6df535afff1a3ee87e23b6f.tar.gz tangerine-wallet-browser-be911711942914e7f6df535afff1a3ee87e23b6f.tar.bz2 tangerine-wallet-browser-be911711942914e7f6df535afff1a3ee87e23b6f.tar.lz tangerine-wallet-browser-be911711942914e7f6df535afff1a3ee87e23b6f.tar.xz tangerine-wallet-browser-be911711942914e7f6df535afff1a3ee87e23b6f.tar.zst tangerine-wallet-browser-be911711942914e7f6df535afff1a3ee87e23b6f.zip |
Merge pull request #6683 from MetaMask/develop
Merge dev to master
Diffstat (limited to 'docs/creating-metrics-events.md')
-rw-r--r-- | docs/creating-metrics-events.md | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/docs/creating-metrics-events.md b/docs/creating-metrics-events.md new file mode 100644 index 000000000..7e7f2d77d --- /dev/null +++ b/docs/creating-metrics-events.md @@ -0,0 +1,71 @@ +## Creating Metrics Events + +The `metricsEvent` method is made available to all components via context. This is done in `metamask-extension/ui/app/helpers/higher-order-components/metametrics/metametrics.provider.js`. As such, it can be called in all components by first adding it to the context proptypes: + +``` +static contextTypes = { + t: PropTypes.func, + metricsEvent: PropTypes.func, +} +``` + +and then accessing it on `this.context`. + +Below is an example of a metrics event call: + +``` +this.context.metricsEvent({ + eventOpts: { + category: 'Navigation', + action: 'Main Menu', + name: 'Switched Account', + }, +}) +``` + +### Base Schema + +Every `metricsEvent` call is passed an object that must have an `eventOpts` property. This property is an object that itself must have three properties: +- category: categorizes events according to the schema we have set up in our matomo.org instance +- action: usually describes the page on which the event takes place, or sometimes a significant subsections of a page +- name: a very specific descriptor of the event + +### Implicit properties + +All metrics events send the following data when called: +- network +- environmentType +- activeCurrency +- accountType +- numberOfTokens +- numberOfAccounts + +These are added to the metrics event via the metametrics provider. + +### Custom Variables + +Metrics events can include custom variables. These are included within the `customVariables` property that is a first-level property within first param passed to `metricsEvent`. + +For example: +``` +this.context.metricsEvent({ + eventOpts: { + category: 'Settings', + action: 'Custom RPC', + name: 'Error', + }, + customVariables: { + networkId: newRpc, + chainId, + }, +}) +``` + +Custom variables can have custom property names and values can be strings or numbers. + +**To include a custom variable, there are a set of necessary steps you must take.** + +1. First you must declare a constant equal to the desired name of the custom variable property in `metamask-extension/ui/app/helpers/utils/metametrics.util.js` under `//Custom Variable Declarations` +1. Then you must add that name to the `customVariableNameIdMap` declaration + 1. The id must be between 1 and 5 + 1. There can be no more than 5 custom variables assigned ids on a given url |