aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant
diff options
context:
space:
mode:
authorXianny <8582774+xianny@users.noreply.github.com>2019-01-12 02:04:30 +0800
committerGitHub <noreply@github.com>2019-01-12 02:04:30 +0800
commit943c378309a84ed142852c6584b53958df7817c8 (patch)
tree43536b7812b11f3a83db4208bfa5640643cfd6e8 /packages/instant
parentcf3787edbb9e8acf7160ab93b903b54c63bdffda (diff)
downloaddexon-sol-tools-943c378309a84ed142852c6584b53958df7817c8.tar
dexon-sol-tools-943c378309a84ed142852c6584b53958df7817c8.tar.gz
dexon-sol-tools-943c378309a84ed142852c6584b53958df7817c8.tar.bz2
dexon-sol-tools-943c378309a84ed142852c6584b53958df7817c8.tar.lz
dexon-sol-tools-943c378309a84ed142852c6584b53958df7817c8.tar.xz
dexon-sol-tools-943c378309a84ed142852c6584b53958df7817c8.tar.zst
dexon-sol-tools-943c378309a84ed142852c6584b53958df7817c8.zip
Implement tslint enum-naming to enforce PascalCase on enum members (#1474)
Diffstat (limited to 'packages/instant')
-rw-r--r--packages/instant/CHANGELOG.json9
-rw-r--r--packages/instant/src/redux/actions.ts93
-rw-r--r--packages/instant/src/redux/analytics_middleware.ts16
-rw-r--r--packages/instant/src/redux/reducer.ts46
-rw-r--r--packages/instant/src/style/theme.ts2
-rw-r--r--packages/instant/src/types.ts8
-rw-r--r--packages/instant/src/util/analytics.ts130
7 files changed, 156 insertions, 148 deletions
diff --git a/packages/instant/CHANGELOG.json b/packages/instant/CHANGELOG.json
index db187140f..537670584 100644
--- a/packages/instant/CHANGELOG.json
+++ b/packages/instant/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "2.0.0",
+ "changes": [
+ {
+ "note": "Renamed ActionTypes enum members to PascalCase to conform with tslint enum-naming rule",
+ "pr": 1474
+ }
+ ]
+ },
+ {
"timestamp": 1542821676,
"version": "1.0.1",
"changes": [
diff --git a/packages/instant/src/redux/actions.ts b/packages/instant/src/redux/actions.ts
index 9d7a61fc7..ca0be543b 100644
--- a/packages/instant/src/redux/actions.ts
+++ b/packages/instant/src/redux/actions.ts
@@ -21,57 +21,56 @@ function createAction<T extends string, P>(type: T, data?: P): PlainAction<T> |
}
export enum ActionTypes {
- SET_ACCOUNT_STATE_LOADING = 'SET_ACCOUNT_STATE_LOADING',
- SET_ACCOUNT_STATE_LOCKED = 'SET_ACCOUNT_STATE_LOCKED',
- SET_ACCOUNT_STATE_READY = 'SET_ACCOUNT_STATE_READY',
- UPDATE_ACCOUNT_ETH_BALANCE = 'UPDATE_ACCOUNT_ETH_BALANCE',
- UPDATE_ETH_USD_PRICE = 'UPDATE_ETH_USD_PRICE',
- UPDATE_SELECTED_ASSET_UNIT_AMOUNT = 'UPDATE_SELECTED_ASSET_UNIT_AMOUNT',
- SET_BUY_ORDER_STATE_NONE = 'SET_BUY_ORDER_STATE_NONE',
- SET_BUY_ORDER_STATE_VALIDATING = 'SET_BUY_ORDER_STATE_VALIDATING',
- SET_BUY_ORDER_STATE_PROCESSING = 'SET_BUY_ORDER_STATE_PROCESSING',
- SET_BUY_ORDER_STATE_FAILURE = 'SET_BUY_ORDER_STATE_FAILURE',
- SET_BUY_ORDER_STATE_SUCCESS = 'SET_BUY_ORDER_STATE_SUCCESS',
- UPDATE_LATEST_BUY_QUOTE = 'UPDATE_LATEST_BUY_QUOTE',
- UPDATE_SELECTED_ASSET = 'UPDATE_SELECTED_ASSET',
- SET_AVAILABLE_ASSETS = 'SET_AVAILABLE_ASSETS',
- SET_QUOTE_REQUEST_STATE_PENDING = 'SET_QUOTE_REQUEST_STATE_PENDING',
- SET_QUOTE_REQUEST_STATE_FAILURE = 'SET_QUOTE_REQUEST_STATE_FAILURE',
- SET_ERROR_MESSAGE = 'SET_ERROR_MESSAGE',
- HIDE_ERROR = 'HIDE_ERROR',
- CLEAR_ERROR = 'CLEAR_ERROR',
- RESET_AMOUNT = 'RESET_AMOUNT',
- OPEN_STANDARD_SLIDING_PANEL = 'OPEN_STANDARD_SLIDING_PANEL',
- CLOSE_STANDARD_SLIDING_PANEL = 'CLOSE_STANDARD_SLIDING_PANEL',
- UPDATE_BASE_CURRENCY = 'UPDATE_BASE_CURRENCY',
+ SetAccountStateLoading = 'SET_ACCOUNT_STATE_LOADING',
+ SetAccountStateLocked = 'SET_ACCOUNT_STATE_LOCKED',
+ SetAccountStateReady = 'SET_ACCOUNT_STATE_READY',
+ UpdateAccountEthBalance = 'UPDATE_ACCOUNT_ETH_BALANCE',
+ UpdateEthUsdPrice = 'UPDATE_ETH_USD_PRICE',
+ UpdateSelectedAssetUnitAmount = 'UPDATE_SELECTED_ASSET_UNIT_AMOUNT',
+ SetBuyOrderStateNone = 'SET_BUY_ORDER_STATE_NONE',
+ SetBuyOrderStateValidating = 'SET_BUY_ORDER_STATE_VALIDATING',
+ SetBuyOrderStateProcessing = 'SET_BUY_ORDER_STATE_PROCESSING',
+ SetBuyOrderStateFailure = 'SET_BUY_ORDER_STATE_FAILURE',
+ SetBuyOrderStateSuccess = 'SET_BUY_ORDER_STATE_SUCCESS',
+ UpdateLatestBuyQuote = 'UPDATE_LATEST_BUY_QUOTE',
+ UpdateSelectedAsset = 'UPDATE_SELECTED_ASSET',
+ SetAvailableAssets = 'SET_AVAILABLE_ASSETS',
+ SetQuoteRequestStatePending = 'SET_QUOTE_REQUEST_STATE_PENDING',
+ SetQuoteRequestStateFailure = 'SET_QUOTE_REQUEST_STATE_FAILURE',
+ SetErrorMessage = 'SET_ERROR_MESSAGE',
+ HideError = 'HIDE_ERROR',
+ ClearError = 'CLEAR_ERROR',
+ ResetAmount = 'RESET_AMOUNT',
+ OpenStandardSlidingPanel = 'OPEN_STANDARD_SLIDING_PANEL',
+ CloseStandardSlidingPanel = 'CLOSE_STANDARD_SLIDING_PANEL',
+ UpdateBaseCurrency = 'UPDATE_BASE_CURRENCY',
}
export const actions = {
- setAccountStateLoading: () => createAction(ActionTypes.SET_ACCOUNT_STATE_LOADING),
- setAccountStateLocked: () => createAction(ActionTypes.SET_ACCOUNT_STATE_LOCKED),
- setAccountStateReady: (address: string) => createAction(ActionTypes.SET_ACCOUNT_STATE_READY, address),
+ setAccountStateLoading: () => createAction(ActionTypes.SetAccountStateLoading),
+ setAccountStateLocked: () => createAction(ActionTypes.SetAccountStateLocked),
+ setAccountStateReady: (address: string) => createAction(ActionTypes.SetAccountStateReady, address),
updateAccountEthBalance: (addressAndBalance: AddressAndEthBalanceInWei) =>
- createAction(ActionTypes.UPDATE_ACCOUNT_ETH_BALANCE, addressAndBalance),
- updateEthUsdPrice: (price?: BigNumber) => createAction(ActionTypes.UPDATE_ETH_USD_PRICE, price),
- updateSelectedAssetAmount: (amount?: BigNumber) =>
- createAction(ActionTypes.UPDATE_SELECTED_ASSET_UNIT_AMOUNT, amount),
- setBuyOrderStateNone: () => createAction(ActionTypes.SET_BUY_ORDER_STATE_NONE),
- setBuyOrderStateValidating: () => createAction(ActionTypes.SET_BUY_ORDER_STATE_VALIDATING),
+ createAction(ActionTypes.UpdateAccountEthBalance, addressAndBalance),
+ updateEthUsdPrice: (price?: BigNumber) => createAction(ActionTypes.UpdateEthUsdPrice, price),
+ updateSelectedAssetAmount: (amount?: BigNumber) => createAction(ActionTypes.UpdateSelectedAssetUnitAmount, amount),
+ setBuyOrderStateNone: () => createAction(ActionTypes.SetBuyOrderStateNone),
+ setBuyOrderStateValidating: () => createAction(ActionTypes.SetBuyOrderStateValidating),
setBuyOrderStateProcessing: (txHash: string, startTimeUnix: number, expectedEndTimeUnix: number) =>
- createAction(ActionTypes.SET_BUY_ORDER_STATE_PROCESSING, { txHash, startTimeUnix, expectedEndTimeUnix }),
- setBuyOrderStateFailure: (txHash: string) => createAction(ActionTypes.SET_BUY_ORDER_STATE_FAILURE, txHash),
- setBuyOrderStateSuccess: (txHash: string) => createAction(ActionTypes.SET_BUY_ORDER_STATE_SUCCESS, txHash),
- updateLatestBuyQuote: (buyQuote?: BuyQuote) => createAction(ActionTypes.UPDATE_LATEST_BUY_QUOTE, buyQuote),
- updateSelectedAsset: (asset: Asset) => createAction(ActionTypes.UPDATE_SELECTED_ASSET, asset),
- setAvailableAssets: (availableAssets: Asset[]) => createAction(ActionTypes.SET_AVAILABLE_ASSETS, availableAssets),
- setQuoteRequestStatePending: () => createAction(ActionTypes.SET_QUOTE_REQUEST_STATE_PENDING),
- setQuoteRequestStateFailure: () => createAction(ActionTypes.SET_QUOTE_REQUEST_STATE_FAILURE),
- setErrorMessage: (errorMessage: string) => createAction(ActionTypes.SET_ERROR_MESSAGE, errorMessage),
- hideError: () => createAction(ActionTypes.HIDE_ERROR),
- clearError: () => createAction(ActionTypes.CLEAR_ERROR),
- resetAmount: () => createAction(ActionTypes.RESET_AMOUNT),
+ createAction(ActionTypes.SetBuyOrderStateProcessing, { txHash, startTimeUnix, expectedEndTimeUnix }),
+ setBuyOrderStateFailure: (txHash: string) => createAction(ActionTypes.SetBuyOrderStateFailure, txHash),
+ setBuyOrderStateSuccess: (txHash: string) => createAction(ActionTypes.SetBuyOrderStateSuccess, txHash),
+ updateLatestBuyQuote: (buyQuote?: BuyQuote) => createAction(ActionTypes.UpdateLatestBuyQuote, buyQuote),
+ updateSelectedAsset: (asset: Asset) => createAction(ActionTypes.UpdateSelectedAsset, asset),
+ setAvailableAssets: (availableAssets: Asset[]) => createAction(ActionTypes.SetAvailableAssets, availableAssets),
+ setQuoteRequestStatePending: () => createAction(ActionTypes.SetQuoteRequestStatePending),
+ setQuoteRequestStateFailure: () => createAction(ActionTypes.SetQuoteRequestStateFailure),
+ setErrorMessage: (errorMessage: string) => createAction(ActionTypes.SetErrorMessage, errorMessage),
+ hideError: () => createAction(ActionTypes.HideError),
+ clearError: () => createAction(ActionTypes.ClearError),
+ resetAmount: () => createAction(ActionTypes.ResetAmount),
openStandardSlidingPanel: (content: StandardSlidingPanelContent) =>
- createAction(ActionTypes.OPEN_STANDARD_SLIDING_PANEL, content),
- closeStandardSlidingPanel: () => createAction(ActionTypes.CLOSE_STANDARD_SLIDING_PANEL),
- updateBaseCurrency: (baseCurrency: BaseCurrency) => createAction(ActionTypes.UPDATE_BASE_CURRENCY, baseCurrency),
+ createAction(ActionTypes.OpenStandardSlidingPanel, content),
+ closeStandardSlidingPanel: () => createAction(ActionTypes.CloseStandardSlidingPanel),
+ updateBaseCurrency: (baseCurrency: BaseCurrency) => createAction(ActionTypes.UpdateBaseCurrency, baseCurrency),
};
diff --git a/packages/instant/src/redux/analytics_middleware.ts b/packages/instant/src/redux/analytics_middleware.ts
index a86a16b1a..4b4d30213 100644
--- a/packages/instant/src/redux/analytics_middleware.ts
+++ b/packages/instant/src/redux/analytics_middleware.ts
@@ -21,7 +21,7 @@ export const analyticsMiddleware: Middleware = store => next => middlewareAction
const curAccount = curState.providerState.account;
switch (nextAction.type) {
- case ActionTypes.SET_ACCOUNT_STATE_READY:
+ case ActionTypes.SetAccountStateReady:
if (curAccount.state === AccountState.Ready) {
const didJustTurnReady = prevAccount.state !== AccountState.Ready;
const didJustUpdateAddress =
@@ -38,13 +38,13 @@ export const analyticsMiddleware: Middleware = store => next => middlewareAction
}
}
break;
- case ActionTypes.SET_ACCOUNT_STATE_LOCKED:
+ case ActionTypes.SetAccountStateLocked:
if (prevAccount.state !== AccountState.Locked && curAccount.state === AccountState.Locked) {
// if we are moving from account not locked to account locked, track `Account - Locked`
analytics.trackAccountLocked();
}
break;
- case ActionTypes.UPDATE_ACCOUNT_ETH_BALANCE:
+ case ActionTypes.UpdateAccountEthBalance:
if (
curAccount.state === AccountState.Ready &&
curAccount.ethBalanceInWei &&
@@ -58,7 +58,7 @@ export const analyticsMiddleware: Middleware = store => next => middlewareAction
analytics.addEventProperties({ ethBalanceInUnitAmount });
}
break;
- case ActionTypes.UPDATE_SELECTED_ASSET:
+ case ActionTypes.UpdateSelectedAsset:
const selectedAsset = curState.selectedAsset;
if (selectedAsset) {
const assetName = selectedAsset.metaData.name;
@@ -79,7 +79,7 @@ export const analyticsMiddleware: Middleware = store => next => middlewareAction
analytics.addEventProperties(selectedAssetEventProperties);
}
break;
- case ActionTypes.SET_AVAILABLE_ASSETS:
+ case ActionTypes.SetAvailableAssets:
const availableAssets = curState.availableAssets;
if (availableAssets) {
analytics.addEventProperties({
@@ -87,19 +87,19 @@ export const analyticsMiddleware: Middleware = store => next => middlewareAction
});
}
break;
- case ActionTypes.OPEN_STANDARD_SLIDING_PANEL:
+ case ActionTypes.OpenStandardSlidingPanel:
const openSlidingContent = curState.standardSlidingPanelSettings.content;
if (openSlidingContent === StandardSlidingPanelContent.InstallWallet) {
analytics.trackInstallWalletModalOpened();
}
break;
- case ActionTypes.CLOSE_STANDARD_SLIDING_PANEL:
+ case ActionTypes.CloseStandardSlidingPanel:
const closeSlidingContent = curState.standardSlidingPanelSettings.content;
if (closeSlidingContent === StandardSlidingPanelContent.InstallWallet) {
analytics.trackInstallWalletModalClosed();
}
break;
- case ActionTypes.UPDATE_BASE_CURRENCY:
+ case ActionTypes.UpdateBaseCurrency:
analytics.trackBaseCurrencyChanged(curState.baseCurrency);
analytics.addEventProperties({ baseCurrency: curState.baseCurrency });
}
diff --git a/packages/instant/src/redux/reducer.ts b/packages/instant/src/redux/reducer.ts
index 8c13c9c72..0d8bb4b05 100644
--- a/packages/instant/src/redux/reducer.ts
+++ b/packages/instant/src/redux/reducer.ts
@@ -72,11 +72,11 @@ export const DEFAULT_STATE: DefaultState = {
export const createReducer = (initialState: State) => {
const reducer = (state: State = initialState, action: Action): State => {
switch (action.type) {
- case ActionTypes.SET_ACCOUNT_STATE_LOADING:
+ case ActionTypes.SetAccountStateLoading:
return reduceStateWithAccount(state, LOADING_ACCOUNT);
- case ActionTypes.SET_ACCOUNT_STATE_LOCKED:
+ case ActionTypes.SetAccountStateLocked:
return reduceStateWithAccount(state, LOCKED_ACCOUNT);
- case ActionTypes.SET_ACCOUNT_STATE_READY: {
+ case ActionTypes.SetAccountStateReady: {
const address = action.data;
let newAccount: AccountReady = {
state: AccountState.Ready,
@@ -91,7 +91,7 @@ export const createReducer = (initialState: State) => {
}
return reduceStateWithAccount(state, newAccount);
}
- case ActionTypes.UPDATE_ACCOUNT_ETH_BALANCE: {
+ case ActionTypes.UpdateAccountEthBalance: {
const { address, ethBalanceInWei } = action.data;
const currentAccount = state.providerState.account;
if (currentAccount.state !== AccountState.Ready || currentAccount.address !== address) {
@@ -104,17 +104,17 @@ export const createReducer = (initialState: State) => {
return reduceStateWithAccount(state, newAccount);
}
}
- case ActionTypes.UPDATE_ETH_USD_PRICE:
+ case ActionTypes.UpdateEthUsdPrice:
return {
...state,
ethUsdPrice: action.data,
};
- case ActionTypes.UPDATE_SELECTED_ASSET_UNIT_AMOUNT:
+ case ActionTypes.UpdateSelectedAssetUnitAmount:
return {
...state,
selectedAssetUnitAmount: action.data,
};
- case ActionTypes.UPDATE_LATEST_BUY_QUOTE:
+ case ActionTypes.UpdateLatestBuyQuote:
const newBuyQuoteIfExists = action.data;
const shouldUpdate =
_.isUndefined(newBuyQuoteIfExists) || doesBuyQuoteMatchState(newBuyQuoteIfExists, state);
@@ -127,29 +127,29 @@ export const createReducer = (initialState: State) => {
} else {
return state;
}
- case ActionTypes.SET_QUOTE_REQUEST_STATE_PENDING:
+ case ActionTypes.SetQuoteRequestStatePending:
return {
...state,
latestBuyQuote: undefined,
quoteRequestState: AsyncProcessState.Pending,
};
- case ActionTypes.SET_QUOTE_REQUEST_STATE_FAILURE:
+ case ActionTypes.SetQuoteRequestStateFailure:
return {
...state,
latestBuyQuote: undefined,
quoteRequestState: AsyncProcessState.Failure,
};
- case ActionTypes.SET_BUY_ORDER_STATE_NONE:
+ case ActionTypes.SetBuyOrderStateNone:
return {
...state,
buyOrderState: { processState: OrderProcessState.None },
};
- case ActionTypes.SET_BUY_ORDER_STATE_VALIDATING:
+ case ActionTypes.SetBuyOrderStateValidating:
return {
...state,
buyOrderState: { processState: OrderProcessState.Validating },
};
- case ActionTypes.SET_BUY_ORDER_STATE_PROCESSING:
+ case ActionTypes.SetBuyOrderStateProcessing:
const processingData = action.data;
const { startTimeUnix, expectedEndTimeUnix } = processingData;
return {
@@ -163,7 +163,7 @@ export const createReducer = (initialState: State) => {
},
},
};
- case ActionTypes.SET_BUY_ORDER_STATE_FAILURE:
+ case ActionTypes.SetBuyOrderStateFailure:
const failureTxHash = action.data;
if ('txHash' in state.buyOrderState) {
if (state.buyOrderState.txHash === failureTxHash) {
@@ -179,7 +179,7 @@ export const createReducer = (initialState: State) => {
}
}
return state;
- case ActionTypes.SET_BUY_ORDER_STATE_SUCCESS:
+ case ActionTypes.SetBuyOrderStateSuccess:
const successTxHash = action.data;
if ('txHash' in state.buyOrderState) {
if (state.buyOrderState.txHash === successTxHash) {
@@ -195,29 +195,29 @@ export const createReducer = (initialState: State) => {
}
}
return state;
- case ActionTypes.SET_ERROR_MESSAGE:
+ case ActionTypes.SetErrorMessage:
return {
...state,
latestErrorMessage: action.data,
latestErrorDisplayStatus: DisplayStatus.Present,
};
- case ActionTypes.HIDE_ERROR:
+ case ActionTypes.HideError:
return {
...state,
latestErrorDisplayStatus: DisplayStatus.Hidden,
};
- case ActionTypes.CLEAR_ERROR:
+ case ActionTypes.ClearError:
return {
...state,
latestErrorMessage: undefined,
latestErrorDisplayStatus: DisplayStatus.Hidden,
};
- case ActionTypes.UPDATE_SELECTED_ASSET:
+ case ActionTypes.UpdateSelectedAsset:
return {
...state,
selectedAsset: action.data,
};
- case ActionTypes.RESET_AMOUNT:
+ case ActionTypes.ResetAmount:
return {
...state,
latestBuyQuote: undefined,
@@ -225,12 +225,12 @@ export const createReducer = (initialState: State) => {
buyOrderState: { processState: OrderProcessState.None },
selectedAssetUnitAmount: undefined,
};
- case ActionTypes.SET_AVAILABLE_ASSETS:
+ case ActionTypes.SetAvailableAssets:
return {
...state,
availableAssets: action.data,
};
- case ActionTypes.OPEN_STANDARD_SLIDING_PANEL:
+ case ActionTypes.OpenStandardSlidingPanel:
return {
...state,
standardSlidingPanelSettings: {
@@ -238,7 +238,7 @@ export const createReducer = (initialState: State) => {
animationState: 'slidIn',
},
};
- case ActionTypes.CLOSE_STANDARD_SLIDING_PANEL:
+ case ActionTypes.CloseStandardSlidingPanel:
return {
...state,
standardSlidingPanelSettings: {
@@ -246,7 +246,7 @@ export const createReducer = (initialState: State) => {
animationState: 'slidOut',
},
};
- case ActionTypes.UPDATE_BASE_CURRENCY:
+ case ActionTypes.UpdateBaseCurrency:
return {
...state,
baseCurrency: action.data,
diff --git a/packages/instant/src/style/theme.ts b/packages/instant/src/style/theme.ts
index fd3f03c3f..49f3c81e6 100644
--- a/packages/instant/src/style/theme.ts
+++ b/packages/instant/src/style/theme.ts
@@ -11,7 +11,7 @@ const {
} = styledComponents;
export type Theme = { [key in ColorOption]: string };
-
+// tslint:disable:enum-naming
export enum ColorOption {
primaryColor = 'primaryColor',
black = 'black',
diff --git a/packages/instant/src/types.ts b/packages/instant/src/types.ts
index f07a407da..606294c93 100644
--- a/packages/instant/src/types.ts
+++ b/packages/instant/src/types.ts
@@ -27,8 +27,8 @@ export enum QuoteFetchOrigin {
}
export enum BaseCurrency {
- USD = 'USD',
- ETH = 'ETH',
+ USD = 'USD', // tslint:disable-line:enum-naming
+ ETH = 'ETH', // tslint:disable-line:enum-naming
}
export interface SimulatedProgress {
@@ -95,7 +95,7 @@ export enum Network {
export enum ZeroExInstantError {
AssetMetaDataNotAvailable = 'ASSET_META_DATA_NOT_AVAILABLE',
- InsufficientETH = 'INSUFFICIENT_ETH',
+ InsufficientETH = 'INSUFFICIENT_ETH', // tslint:disable-line:enum-naming
CouldNotSubmitTransaction = 'COULD_NOT_SUBMIT_TRANSACTION',
}
@@ -168,7 +168,7 @@ export enum WalletSuggestion {
export enum OperatingSystem {
Android = 'ANDROID',
- iOS = 'IOS',
+ iOS = 'IOS', // tslint:disable-line:enum-naming
Mac = 'MAC',
Windows = 'WINDOWS',
WindowsPhone = 'WINDOWS_PHONE',
diff --git a/packages/instant/src/util/analytics.ts b/packages/instant/src/util/analytics.ts
index 4faeaaf5a..fa8a72a2c 100644
--- a/packages/instant/src/util/analytics.ts
+++ b/packages/instant/src/util/analytics.ts
@@ -31,38 +31,38 @@ export const evaluateIfEnabled = (fnCall: () => void) => {
};
enum EventNames {
- INSTANT_OPENED = 'Instant - Opened',
- INSTANT_CLOSED = 'Instant - Closed',
- ACCOUNT_LOCKED = 'Account - Locked',
- ACCOUNT_READY = 'Account - Ready',
- ACCOUNT_UNLOCK_REQUESTED = 'Account - Unlock Requested',
- ACCOUNT_UNLOCK_DENIED = 'Account - Unlock Denied',
- ACCOUNT_ADDRESS_CHANGED = 'Account - Address Changed',
- BASE_CURRENCY_CHANGED = 'Base Currency - Changed',
- PAYMENT_METHOD_DROPDOWN_OPENED = 'Payment Method - Dropdown Opened',
- PAYMENT_METHOD_OPENED_ETHERSCAN = 'Payment Method - Opened Etherscan',
- PAYMENT_METHOD_COPIED_ADDRESS = 'Payment Method - Copied Address',
- BUY_NOT_ENOUGH_ETH = 'Buy - Not Enough Eth',
- BUY_STARTED = 'Buy - Started',
- BUY_SIGNATURE_DENIED = 'Buy - Signature Denied',
- BUY_SIMULATION_FAILED = 'Buy - Simulation Failed',
- BUY_UNKNOWN_ERROR = 'Buy - Unknown Error',
- BUY_TX_SUBMITTED = 'Buy - Tx Submitted',
- BUY_TX_SUCCEEDED = 'Buy - Tx Succeeded',
- BUY_TX_FAILED = 'Buy - Tx Failed',
- USD_PRICE_FETCH_FAILED = 'USD Price - Fetch Failed',
- INSTALL_WALLET_CLICKED = 'Install Wallet - Clicked',
- INSTALL_WALLET_MODAL_OPENED = 'Install Wallet - Modal - Opened',
- INSTALL_WALLET_MODAL_CLICKED_EXPLANATION = 'Install Wallet - Modal - Clicked Explanation',
- INSTALL_WALLET_MODAL_CLICKED_GET = 'Install Wallet - Modal - Clicked Get',
- INSTALL_WALLET_MODAL_CLOSED = 'Install Wallet - Modal - Closed',
- TOKEN_SELECTOR_OPENED = 'Token Selector - Opened',
- TOKEN_SELECTOR_CLOSED = 'Token Selector - Closed',
- TOKEN_SELECTOR_CHOSE = 'Token Selector - Chose',
- TOKEN_SELECTOR_SEARCHED = 'Token Selector - Searched',
- TRANSACTION_VIEWED = 'Transaction - Viewed',
- QUOTE_FETCHED = 'Quote - Fetched',
- QUOTE_ERROR = 'Quote - Error',
+ InstantOpened = 'Instant - Opened',
+ InstantClosed = 'Instant - Closed',
+ AccountLocked = 'Account - Locked',
+ AccountReady = 'Account - Ready',
+ AccountUnlockRequested = 'Account - Unlock Requested',
+ AccountUnlockDenied = 'Account - Unlock Denied',
+ AccountAddressChanged = 'Account - Address Changed',
+ BaseCurrencyChanged = 'Base Currency - Changed',
+ PaymentMethodDropdownOpened = 'Payment Method - Dropdown Opened',
+ PaymentMethodOpenedEtherscan = 'Payment Method - Opened Etherscan',
+ PaymentMethodCopiedAddress = 'Payment Method - Copied Address',
+ BuyNotEnoughEth = 'Buy - Not Enough Eth',
+ BuyStarted = 'Buy - Started',
+ BuySignatureDenied = 'Buy - Signature Denied',
+ BuySimulationFailed = 'Buy - Simulation Failed',
+ BuyUnknownError = 'Buy - Unknown Error',
+ BuyTxSubmitted = 'Buy - Tx Submitted',
+ BuyTxSucceeded = 'Buy - Tx Succeeded',
+ BuyTxFailed = 'Buy - Tx Failed',
+ UsdPriceFetchFailed = 'USD Price - Fetch Failed',
+ InstallWalletClicked = 'Install Wallet - Clicked',
+ InstallWalletModalOpened = 'Install Wallet - Modal - Opened',
+ InstallWalletModalClickedExplanation = 'Install Wallet - Modal - Clicked Explanation',
+ InstallWalletModalClickedGet = 'Install Wallet - Modal - Clicked Get',
+ InstallWalletModalClosed = 'Install Wallet - Modal - Closed',
+ TokenSelectorOpened = 'Token Selector - Opened',
+ TokenSelectorClosed = 'Token Selector - Closed',
+ TokenSelectorChose = 'Token Selector - Chose',
+ TokenSelectorSearched = 'Token Selector - Searched',
+ TransactionViewed = 'Transaction - Viewed',
+ QuoteFetched = 'Quote - Fetched',
+ QuoteError = 'Quote - Error',
}
const track = (eventName: EventNames, eventProperties: EventProperties = {}): void => {
@@ -125,7 +125,7 @@ export interface AnalyticsEventOptions {
baseCurrency?: string;
}
export enum TokenSelectorClosedVia {
- ClickedX = 'Clicked X',
+ ClickedX = 'Clicked X', // tslint:disable-line:enum-naming
TokenChose = 'Token Chose',
}
export const analytics = {
@@ -169,80 +169,80 @@ export const analytics = {
};
return eventOptions;
},
- trackInstantOpened: trackingEventFnWithoutPayload(EventNames.INSTANT_OPENED),
- trackInstantClosed: trackingEventFnWithoutPayload(EventNames.INSTANT_CLOSED),
- trackAccountLocked: trackingEventFnWithoutPayload(EventNames.ACCOUNT_LOCKED),
- trackAccountReady: (address: string) => trackingEventFnWithPayload(EventNames.ACCOUNT_READY)({ address }),
- trackAccountUnlockRequested: trackingEventFnWithoutPayload(EventNames.ACCOUNT_UNLOCK_REQUESTED),
- trackAccountUnlockDenied: trackingEventFnWithoutPayload(EventNames.ACCOUNT_UNLOCK_DENIED),
+ trackInstantOpened: trackingEventFnWithoutPayload(EventNames.InstantOpened),
+ trackInstantClosed: trackingEventFnWithoutPayload(EventNames.InstantClosed),
+ trackAccountLocked: trackingEventFnWithoutPayload(EventNames.AccountLocked),
+ trackAccountReady: (address: string) => trackingEventFnWithPayload(EventNames.AccountReady)({ address }),
+ trackAccountUnlockRequested: trackingEventFnWithoutPayload(EventNames.AccountUnlockRequested),
+ trackAccountUnlockDenied: trackingEventFnWithoutPayload(EventNames.AccountUnlockDenied),
trackAccountAddressChanged: (address: string) =>
- trackingEventFnWithPayload(EventNames.ACCOUNT_ADDRESS_CHANGED)({ address }),
+ trackingEventFnWithPayload(EventNames.AccountAddressChanged)({ address }),
trackBaseCurrencyChanged: (currencyChangedTo: BaseCurrency) =>
- trackingEventFnWithPayload(EventNames.BASE_CURRENCY_CHANGED)({ currencyChangedTo }),
- trackPaymentMethodDropdownOpened: trackingEventFnWithoutPayload(EventNames.PAYMENT_METHOD_DROPDOWN_OPENED),
- trackPaymentMethodOpenedEtherscan: trackingEventFnWithoutPayload(EventNames.PAYMENT_METHOD_OPENED_ETHERSCAN),
- trackPaymentMethodCopiedAddress: trackingEventFnWithoutPayload(EventNames.PAYMENT_METHOD_COPIED_ADDRESS),
+ trackingEventFnWithPayload(EventNames.BaseCurrencyChanged)({ currencyChangedTo }),
+ trackPaymentMethodDropdownOpened: trackingEventFnWithoutPayload(EventNames.PaymentMethodDropdownOpened),
+ trackPaymentMethodOpenedEtherscan: trackingEventFnWithoutPayload(EventNames.PaymentMethodOpenedEtherscan),
+ trackPaymentMethodCopiedAddress: trackingEventFnWithoutPayload(EventNames.PaymentMethodCopiedAddress),
trackBuyNotEnoughEth: (buyQuote: BuyQuote) =>
- trackingEventFnWithPayload(EventNames.BUY_NOT_ENOUGH_ETH)(buyQuoteEventProperties(buyQuote)),
+ trackingEventFnWithPayload(EventNames.BuyNotEnoughEth)(buyQuoteEventProperties(buyQuote)),
trackBuyStarted: (buyQuote: BuyQuote) =>
- trackingEventFnWithPayload(EventNames.BUY_STARTED)(buyQuoteEventProperties(buyQuote)),
+ trackingEventFnWithPayload(EventNames.BuyStarted)(buyQuoteEventProperties(buyQuote)),
trackBuySignatureDenied: (buyQuote: BuyQuote) =>
- trackingEventFnWithPayload(EventNames.BUY_SIGNATURE_DENIED)(buyQuoteEventProperties(buyQuote)),
+ trackingEventFnWithPayload(EventNames.BuySignatureDenied)(buyQuoteEventProperties(buyQuote)),
trackBuySimulationFailed: (buyQuote: BuyQuote) =>
- trackingEventFnWithPayload(EventNames.BUY_SIMULATION_FAILED)(buyQuoteEventProperties(buyQuote)),
+ trackingEventFnWithPayload(EventNames.BuySimulationFailed)(buyQuoteEventProperties(buyQuote)),
trackBuyUnknownError: (buyQuote: BuyQuote, errorMessage: string) =>
- trackingEventFnWithPayload(EventNames.BUY_UNKNOWN_ERROR)({
+ trackingEventFnWithPayload(EventNames.BuyUnknownError)({
...buyQuoteEventProperties(buyQuote),
errorMessage,
}),
trackBuyTxSubmitted: (buyQuote: BuyQuote, txHash: string, startTimeUnix: number, expectedEndTimeUnix: number) =>
- trackingEventFnWithPayload(EventNames.BUY_TX_SUBMITTED)({
+ trackingEventFnWithPayload(EventNames.BuyTxSubmitted)({
...buyQuoteEventProperties(buyQuote),
txHash,
expectedTxTimeMs: expectedEndTimeUnix - startTimeUnix,
}),
trackBuyTxSucceeded: (buyQuote: BuyQuote, txHash: string, startTimeUnix: number, expectedEndTimeUnix: number) =>
- trackingEventFnWithPayload(EventNames.BUY_TX_SUCCEEDED)({
+ trackingEventFnWithPayload(EventNames.BuyTxSucceeded)({
...buyQuoteEventProperties(buyQuote),
txHash,
expectedTxTimeMs: expectedEndTimeUnix - startTimeUnix,
actualTxTimeMs: new Date().getTime() - startTimeUnix,
}),
trackBuyTxFailed: (buyQuote: BuyQuote, txHash: string, startTimeUnix: number, expectedEndTimeUnix: number) =>
- trackingEventFnWithPayload(EventNames.BUY_TX_FAILED)({
+ trackingEventFnWithPayload(EventNames.BuyTxFailed)({
...buyQuoteEventProperties(buyQuote),
txHash,
expectedTxTimeMs: expectedEndTimeUnix - startTimeUnix,
actualTxTimeMs: new Date().getTime() - startTimeUnix,
}),
trackInstallWalletClicked: (walletSuggestion: WalletSuggestion) =>
- trackingEventFnWithPayload(EventNames.INSTALL_WALLET_CLICKED)({ walletSuggestion }),
+ trackingEventFnWithPayload(EventNames.InstallWalletClicked)({ walletSuggestion }),
trackInstallWalletModalClickedExplanation: trackingEventFnWithoutPayload(
- EventNames.INSTALL_WALLET_MODAL_CLICKED_EXPLANATION,
+ EventNames.InstallWalletModalClickedExplanation,
),
- trackInstallWalletModalClickedGet: trackingEventFnWithoutPayload(EventNames.INSTALL_WALLET_MODAL_CLICKED_GET),
- trackInstallWalletModalOpened: trackingEventFnWithoutPayload(EventNames.INSTALL_WALLET_MODAL_OPENED),
- trackInstallWalletModalClosed: trackingEventFnWithoutPayload(EventNames.INSTALL_WALLET_MODAL_CLOSED),
- trackTokenSelectorOpened: trackingEventFnWithoutPayload(EventNames.TOKEN_SELECTOR_OPENED),
+ trackInstallWalletModalClickedGet: trackingEventFnWithoutPayload(EventNames.InstallWalletModalClickedGet),
+ trackInstallWalletModalOpened: trackingEventFnWithoutPayload(EventNames.InstallWalletModalOpened),
+ trackInstallWalletModalClosed: trackingEventFnWithoutPayload(EventNames.InstallWalletModalClosed),
+ trackTokenSelectorOpened: trackingEventFnWithoutPayload(EventNames.TokenSelectorOpened),
trackTokenSelectorClosed: (closedVia: TokenSelectorClosedVia) =>
- trackingEventFnWithPayload(EventNames.TOKEN_SELECTOR_CLOSED)({ closedVia }),
+ trackingEventFnWithPayload(EventNames.TokenSelectorClosed)({ closedVia }),
trackTokenSelectorChose: (payload: { assetName: string; assetData: string }) =>
- trackingEventFnWithPayload(EventNames.TOKEN_SELECTOR_CHOSE)(payload),
+ trackingEventFnWithPayload(EventNames.TokenSelectorChose)(payload),
trackTokenSelectorSearched: (searchText: string) =>
- trackingEventFnWithPayload(EventNames.TOKEN_SELECTOR_SEARCHED)({ searchText }),
+ trackingEventFnWithPayload(EventNames.TokenSelectorSearched)({ searchText }),
trackTransactionViewed: (orderProcesState: OrderProcessState) =>
- trackingEventFnWithPayload(EventNames.TRANSACTION_VIEWED)({ orderState: orderProcesState }),
+ trackingEventFnWithPayload(EventNames.TransactionViewed)({ orderState: orderProcesState }),
trackQuoteFetched: (buyQuote: BuyQuote, fetchOrigin: QuoteFetchOrigin) =>
- trackingEventFnWithPayload(EventNames.QUOTE_FETCHED)({
+ trackingEventFnWithPayload(EventNames.QuoteFetched)({
...buyQuoteEventProperties(buyQuote),
fetchOrigin,
}),
trackQuoteError: (errorMessage: string, assetBuyAmount: BigNumber, fetchOrigin: QuoteFetchOrigin) => {
- trackingEventFnWithPayload(EventNames.QUOTE_ERROR)({
+ trackingEventFnWithPayload(EventNames.QuoteError)({
errorMessage,
assetBuyAmount: assetBuyAmount.toString(),
fetchOrigin,
});
},
- trackUsdPriceFailed: trackingEventFnWithoutPayload(EventNames.USD_PRICE_FETCH_FAILED),
+ trackUsdPriceFailed: trackingEventFnWithoutPayload(EventNames.UsdPriceFetchFailed),
};