diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-07-12 06:39:12 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-07-12 06:39:12 +0800 |
commit | 098322c56475581df5bd80e12cb6c511963e4daf (patch) | |
tree | bed34b4b9b9be4ea124a7a3247db02e8e39d7ba2 /packages/website/ts/redux/analyticsMiddleware.ts | |
parent | 9131a72a47690912db9b536186d05120daabd115 (diff) | |
download | dexon-0x-contracts-098322c56475581df5bd80e12cb6c511963e4daf.tar.gz dexon-0x-contracts-098322c56475581df5bd80e12cb6c511963e4daf.tar.zst dexon-0x-contracts-098322c56475581df5bd80e12cb6c511963e4daf.zip |
Integrate heap analytics
Diffstat (limited to 'packages/website/ts/redux/analyticsMiddleware.ts')
-rw-r--r-- | packages/website/ts/redux/analyticsMiddleware.ts | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/packages/website/ts/redux/analyticsMiddleware.ts b/packages/website/ts/redux/analyticsMiddleware.ts new file mode 100644 index 000000000..2778445e7 --- /dev/null +++ b/packages/website/ts/redux/analyticsMiddleware.ts @@ -0,0 +1,41 @@ +import { Middleware } from 'redux'; +import { State } from 'ts/redux/reducer'; +import { ActionTypes } from 'ts/types'; +import { analytics } from 'ts/utils/analytics'; + +export const analyticsMiddleware: Middleware = store => next => action => { + const nextAction = next(action); + const nextState = (store.getState() as any) as State; + switch (action.type) { + case ActionTypes.UpdateInjectedProviderName: + analytics.addEventPropertiesAsync({ + injectedProviderName: nextState.injectedProviderName, + }); + break; + case ActionTypes.UpdateNetworkId: + analytics.addEventPropertiesAsync({ + networkId: nextState.networkId, + }); + break; + case ActionTypes.UpdateUserAddress: + analytics.addUserPropertiesAsync({ + ethAddress: nextState.userAddress, + }); + break; + case ActionTypes.UpdateUserEtherBalance: + if (nextState.userEtherBalanceInWei) { + analytics.addUserPropertiesAsync({ + ethBalance: nextState.userEtherBalanceInWei.toString(), + }); + } + break; + case ActionTypes.UpdatePortalOnboardingStep: + analytics.trackAsync('Update Onboarding Step', { + stepIndex: nextState.portalOnboardingStep, + }); + break; + default: + break; + } + return nextAction; +}; |