Merge pull request #1371 from 0xProject/feature/instant/log-decimals-and-add-event-properties
feat(instant): More event properties for tracking
This commit is contained in:
commit
4e7031e96d
BIN
packages/instant/.DS_Store
vendored
Normal file
BIN
packages/instant/.DS_Store
vendored
Normal file
Binary file not shown.
@ -1,10 +1,11 @@
|
|||||||
|
import { AssetProxyId } from '@0x/types';
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import { Middleware } from 'redux';
|
import { Middleware } from 'redux';
|
||||||
|
|
||||||
import { ETH_DECIMALS } from '../constants';
|
import { ETH_DECIMALS } from '../constants';
|
||||||
import { AccountState, StandardSlidingPanelContent } from '../types';
|
import { AccountState, StandardSlidingPanelContent } from '../types';
|
||||||
import { analytics } from '../util/analytics';
|
import { analytics, AnalyticsEventOptions } from '../util/analytics';
|
||||||
|
|
||||||
import { Action, ActionTypes } from './actions';
|
import { Action, ActionTypes } from './actions';
|
||||||
|
|
||||||
@ -29,9 +30,11 @@ export const analyticsMiddleware: Middleware = store => next => middlewareAction
|
|||||||
if (didJustTurnReady) {
|
if (didJustTurnReady) {
|
||||||
analytics.trackAccountReady(ethAddress);
|
analytics.trackAccountReady(ethAddress);
|
||||||
analytics.addUserProperties({ lastKnownEthAddress: ethAddress });
|
analytics.addUserProperties({ lastKnownEthAddress: ethAddress });
|
||||||
|
analytics.addEventProperties({ ethAddress });
|
||||||
} else if (didJustUpdateAddress) {
|
} else if (didJustUpdateAddress) {
|
||||||
analytics.trackAccountAddressChanged(ethAddress);
|
analytics.trackAccountAddressChanged(ethAddress);
|
||||||
analytics.addUserProperties({ lastKnownEthAddress: ethAddress });
|
analytics.addUserProperties({ lastKnownEthAddress: ethAddress });
|
||||||
|
analytics.addEventProperties({ ethAddress });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -51,7 +54,8 @@ export const analyticsMiddleware: Middleware = store => next => middlewareAction
|
|||||||
curAccount.ethBalanceInWei,
|
curAccount.ethBalanceInWei,
|
||||||
ETH_DECIMALS,
|
ETH_DECIMALS,
|
||||||
).toString();
|
).toString();
|
||||||
analytics.addUserProperties({ ethBalanceInUnitAmount });
|
analytics.addUserProperties({ lastEthBalanceInUnitAmount: ethBalanceInUnitAmount });
|
||||||
|
analytics.addEventProperties({ ethBalanceInUnitAmount });
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ActionTypes.UPDATE_SELECTED_ASSET:
|
case ActionTypes.UPDATE_SELECTED_ASSET:
|
||||||
@ -63,10 +67,16 @@ export const analyticsMiddleware: Middleware = store => next => middlewareAction
|
|||||||
assetName,
|
assetName,
|
||||||
assetData,
|
assetData,
|
||||||
});
|
});
|
||||||
analytics.addEventProperties({
|
|
||||||
|
const selectedAssetEventProperties: AnalyticsEventOptions = {
|
||||||
selectedAssetName: assetName,
|
selectedAssetName: assetName,
|
||||||
selectedAssetData: assetData,
|
selectedAssetData: assetData,
|
||||||
});
|
};
|
||||||
|
if (selectedAsset.metaData.assetProxyId === AssetProxyId.ERC20) {
|
||||||
|
selectedAssetEventProperties.selectedAssetDecimals = selectedAsset.metaData.decimals;
|
||||||
|
selectedAssetEventProperties.selectedAssetSymbol = selectedAsset.metaData.symbol;
|
||||||
|
}
|
||||||
|
analytics.addEventProperties(selectedAssetEventProperties);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ActionTypes.SET_AVAILABLE_ASSETS:
|
case ActionTypes.SET_AVAILABLE_ASSETS:
|
||||||
|
@ -97,11 +97,13 @@ const buyQuoteEventProperties = (buyQuote: BuyQuote) => {
|
|||||||
|
|
||||||
export interface AnalyticsUserOptions {
|
export interface AnalyticsUserOptions {
|
||||||
lastKnownEthAddress?: string;
|
lastKnownEthAddress?: string;
|
||||||
ethBalanceInUnitAmount?: string;
|
lastEthBalanceInUnitAmount?: string;
|
||||||
}
|
}
|
||||||
export interface AnalyticsEventOptions {
|
export interface AnalyticsEventOptions {
|
||||||
embeddedHost?: string;
|
embeddedHost?: string;
|
||||||
embeddedUrl?: string;
|
embeddedUrl?: string;
|
||||||
|
ethBalanceInUnitAmount?: string;
|
||||||
|
ethAddress?: string;
|
||||||
networkId?: number;
|
networkId?: number;
|
||||||
providerName?: string;
|
providerName?: string;
|
||||||
gitSha?: string;
|
gitSha?: string;
|
||||||
@ -112,7 +114,9 @@ export interface AnalyticsEventOptions {
|
|||||||
affiliateFeePercent?: number;
|
affiliateFeePercent?: number;
|
||||||
numberAvailableAssets?: number;
|
numberAvailableAssets?: number;
|
||||||
selectedAssetName?: string;
|
selectedAssetName?: string;
|
||||||
|
selectedAssetSymbol?: string;
|
||||||
selectedAssetData?: string;
|
selectedAssetData?: string;
|
||||||
|
selectedAssetDecimals?: number;
|
||||||
}
|
}
|
||||||
export enum TokenSelectorClosedVia {
|
export enum TokenSelectorClosedVia {
|
||||||
ClickedX = 'Clicked X',
|
ClickedX = 'Clicked X',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user