aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/redux
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-11-22 04:30:52 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-11-22 04:30:52 +0800
commit31d1b4ba670d25c4cd4ed93d32d12718b4804e5d (patch)
treed07f9efd4c431883d06346a1e5913eebee3397b2 /packages/instant/src/redux
parent351e0e6f5f2add25c4d779356a8cfd4aefb305cb (diff)
downloaddexon-sol-tools-31d1b4ba670d25c4cd4ed93d32d12718b4804e5d.tar
dexon-sol-tools-31d1b4ba670d25c4cd4ed93d32d12718b4804e5d.tar.gz
dexon-sol-tools-31d1b4ba670d25c4cd4ed93d32d12718b4804e5d.tar.bz2
dexon-sol-tools-31d1b4ba670d25c4cd4ed93d32d12718b4804e5d.tar.lz
dexon-sol-tools-31d1b4ba670d25c4cd4ed93d32d12718b4804e5d.tar.xz
dexon-sol-tools-31d1b4ba670d25c4cd4ed93d32d12718b4804e5d.tar.zst
dexon-sol-tools-31d1b4ba670d25c4cd4ed93d32d12718b4804e5d.zip
chore(instant): refactor account tracking logic in middleware to be more readable
Diffstat (limited to 'packages/instant/src/redux')
-rw-r--r--packages/instant/src/redux/analytics_middleware.ts16
1 files changed, 8 insertions, 8 deletions
diff --git a/packages/instant/src/redux/analytics_middleware.ts b/packages/instant/src/redux/analytics_middleware.ts
index 893844f5d..889cc875e 100644
--- a/packages/instant/src/redux/analytics_middleware.ts
+++ b/packages/instant/src/redux/analytics_middleware.ts
@@ -21,17 +21,17 @@ export const analyticsMiddleware: Middleware = store => next => middlewareAction
switch (nextAction.type) {
case ActionTypes.SET_ACCOUNT_STATE_READY:
- if (prevAccount.state !== AccountState.Ready && curAccount.state === AccountState.Ready) {
- // if we are moving from account not ready to account ready, update the current address and track `Account - Ready`
+ if (curAccount.state === AccountState.Ready) {
+ const didJustTurnReady = prevAccount.state !== AccountState.Ready;
+ const didJustUpdateAddress =
+ prevAccount.state === AccountState.Ready && prevAccount.address !== curAccount.address;
const ethAddress = curAccount.address;
- analytics.addUserProperties({ ethAddress });
- analytics.trackAccountReady(ethAddress);
- } else if (prevAccount.state === AccountState.Ready && curAccount.state === AccountState.Ready) {
- if (prevAccount.address !== curAccount.address) {
- // if our account state was already ready and our address has changed, update the current address and track `Account - Address Changed`
- const ethAddress = curAccount.address;
+ if (didJustTurnReady) {
+ analytics.trackAccountReady(ethAddress);
analytics.addUserProperties({ ethAddress });
+ } else if (didJustUpdateAddress) {
analytics.trackAccountAddressChanged(ethAddress);
+ analytics.addUserProperties({ ethAddress });
}
}
break;