aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/website/ts/components/fill_order.tsx3
-rw-r--r--packages/website/ts/components/forms/subscribe_form.tsx3
-rw-r--r--packages/website/ts/components/generate_order/generate_order_form.tsx6
-rw-r--r--packages/website/ts/components/inputs/allowance_toggle.tsx6
-rw-r--r--packages/website/ts/components/onboarding/portal_onboarding_flow.tsx6
-rw-r--r--packages/website/ts/components/portal/portal.tsx3
-rw-r--r--packages/website/ts/components/relayer_index/relayer_grid_tile.tsx3
-rw-r--r--packages/website/ts/components/relayer_index/relayer_top_tokens.tsx3
-rw-r--r--packages/website/ts/components/wallet/wallet.tsx6
-rw-r--r--packages/website/ts/components/wallet/wrap_ether_item.tsx12
-rw-r--r--packages/website/ts/redux/analyticsMiddleware.ts15
-rw-r--r--packages/website/ts/utils/analytics.ts47
-rw-r--r--packages/website/ts/utils/utils.ts2
13 files changed, 44 insertions, 71 deletions
diff --git a/packages/website/ts/components/fill_order.tsx b/packages/website/ts/components/fill_order.tsx
index e4838bc0f..ff63410c3 100644
--- a/packages/website/ts/components/fill_order.tsx
+++ b/packages/website/ts/components/fill_order.tsx
@@ -508,8 +508,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
}
private _trackOrderEvent(eventName: string): void {
const parsedOrder = this.state.parsedOrder;
- // tslint:disable-next-line:no-floating-promises
- analytics.trackOrderEventAsync(eventName, parsedOrder);
+ analytics.trackOrderEvent(eventName, parsedOrder);
}
private async _onFillOrderClickFireAndForgetAsync(): Promise<void> {
if (this.props.blockchainErr !== BlockchainErrs.NoError || _.isEmpty(this.props.userAddress)) {
diff --git a/packages/website/ts/components/forms/subscribe_form.tsx b/packages/website/ts/components/forms/subscribe_form.tsx
index be0468b6f..ef19af644 100644
--- a/packages/website/ts/components/forms/subscribe_form.tsx
+++ b/packages/website/ts/components/forms/subscribe_form.tsx
@@ -114,8 +114,7 @@ export class SubscribeForm extends React.Component<SubscribeFormProps, Subscribe
const response = await backendClient.subscribeToNewsletterAsync(this.state.emailText);
const status = response.status === 200 ? SubscribeFormStatus.Success : SubscribeFormStatus.Error;
if (status === SubscribeFormStatus.Success) {
- // tslint:disable-next-line:no-floating-promises
- analytics.indentifyAsync(this.state.emailText, 'email');
+ analytics.indentify(this.state.emailText, 'email');
}
this.setState({ status, emailText: '' });
} catch (error) {
diff --git a/packages/website/ts/components/generate_order/generate_order_form.tsx b/packages/website/ts/components/generate_order/generate_order_form.tsx
index 524960aa7..c14ee8659 100644
--- a/packages/website/ts/components/generate_order/generate_order_form.tsx
+++ b/packages/website/ts/components/generate_order/generate_order_form.tsx
@@ -268,8 +268,7 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G
const signedOrder = await this._signTransactionAsync();
const doesSignedOrderExist = !_.isUndefined(signedOrder);
if (doesSignedOrderExist) {
- // tslint:disable-next-line:no-floating-promises
- analytics.trackOrderEventAsync('Sign Order Success', signedOrder);
+ analytics.trackOrderEvent('Sign Order Success', signedOrder);
this.setState({
globalErrMsg: '',
shouldShowIncompleteErrs: false,
@@ -282,8 +281,7 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G
globalErrMsg = 'You must enable wallet communication';
this.props.dispatcher.updateShouldBlockchainErrDialogBeOpen(true);
}
- // tslint:disable-next-line:no-floating-promises
- analytics.trackAsync('Sign Order Failure', {
+ analytics.track('Sign Order Failure', {
makerTokenAmount: debitToken.amount.toString(),
makerToken: this.props.tokenByAddress[debitToken.address].symbol,
takerTokenAmount: receiveToken.amount.toString(),
diff --git a/packages/website/ts/components/inputs/allowance_toggle.tsx b/packages/website/ts/components/inputs/allowance_toggle.tsx
index 6f4ffa320..c444d79b7 100644
--- a/packages/website/ts/components/inputs/allowance_toggle.tsx
+++ b/packages/website/ts/components/inputs/allowance_toggle.tsx
@@ -117,12 +117,10 @@ export class AllowanceToggle extends React.Component<AllowanceToggleProps, Allow
};
try {
await this.props.blockchain.setProxyAllowanceAsync(this.props.token, newAllowanceAmountInBaseUnits);
- // tslint:disable-next-line:no-floating-promises
- analytics.trackAsync('Set Allowances Success', logData);
+ analytics.track('Set Allowances Success', logData);
await this.props.refetchTokenStateAsync();
} catch (err) {
- // tslint:disable-next-line:no-floating-promises
- analytics.trackAsync('Set Allowance Failure', logData);
+ analytics.track('Set Allowance Failure', logData);
this.setState({
isSpinnerVisible: false,
});
diff --git a/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx b/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx
index e051d86d9..94a6338ee 100644
--- a/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx
+++ b/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx
@@ -224,8 +224,7 @@ class PlainPortalOnboardingFlow extends React.Component<PortalOnboardingFlowProp
(this.props.stepIndex === 0 && !this.props.isRunning && this.props.blockchainIsLoaded) ||
(!this.props.isRunning && !this.props.hasBeenClosed && this.props.blockchainIsLoaded)
) {
- // tslint:disable-next-line:no-floating-promises
- analytics.trackAsync('Onboarding Started', {
+ analytics.track('Onboarding Started', {
reason: 'automatic',
stepIndex: this.props.stepIndex,
});
@@ -237,8 +236,7 @@ class PlainPortalOnboardingFlow extends React.Component<PortalOnboardingFlowProp
}
private _closeOnboarding(): void {
this.props.updateIsRunning(false);
- // tslint:disable-next-line:no-floating-promises
- analytics.trackAsync('OnboardingClosed', {
+ analytics.track('OnboardingClosed', {
stepIndex: this.props.stepIndex,
});
}
diff --git a/packages/website/ts/components/portal/portal.tsx b/packages/website/ts/components/portal/portal.tsx
index fbaa419d8..ea821d038 100644
--- a/packages/website/ts/components/portal/portal.tsx
+++ b/packages/website/ts/components/portal/portal.tsx
@@ -389,8 +389,7 @@ export class Portal extends React.Component<PortalProps, PortalState> {
);
}
private _startOnboarding(): void {
- // tslint:disable-next-line:no-floating-promises
- analytics.trackAsync('Onboarding Started', {
+ analytics.track('Onboarding Started', {
reason: 'manual',
stepIndex: this.props.portalOnboardingStep,
});
diff --git a/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx b/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx
index 475b79f8f..193dd237a 100644
--- a/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx
+++ b/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx
@@ -65,8 +65,7 @@ export const RelayerGridTile: React.StatelessComponent<RelayerGridTileProps> = (
const topTokens = props.relayerInfo.topTokens;
const weeklyTxnVolume = props.relayerInfo.weeklyTxnVolume;
const onClick = () => {
- // tslint:disable-next-line:no-floating-promises
- analytics.trackAsync('Relayer Click', {
+ analytics.track('Relayer Click', {
name: props.relayerInfo.name,
});
utils.openUrl(link);
diff --git a/packages/website/ts/components/relayer_index/relayer_top_tokens.tsx b/packages/website/ts/components/relayer_index/relayer_top_tokens.tsx
index 33783b406..f3787bd27 100644
--- a/packages/website/ts/components/relayer_index/relayer_top_tokens.tsx
+++ b/packages/website/ts/components/relayer_index/relayer_top_tokens.tsx
@@ -43,8 +43,7 @@ class TokenLink extends React.Component<TokenLinkProps, TokenLinkState> {
public render(): React.ReactNode {
const onClick = (event: React.MouseEvent<HTMLElement>) => {
event.stopPropagation();
- // tslint:disable-next-line:no-floating-promises
- analytics.trackAsync('Token Click', {
+ analytics.track('Token Click', {
tokenSymbol: this.props.tokenInfo.symbol,
});
const tokenLink = this._tokenLinkFromToken(this.props.tokenInfo, this.props.networkId);
diff --git a/packages/website/ts/components/wallet/wallet.tsx b/packages/website/ts/components/wallet/wallet.tsx
index 8523b819a..e462ab3e0 100644
--- a/packages/website/ts/components/wallet/wallet.tsx
+++ b/packages/website/ts/components/wallet/wallet.tsx
@@ -490,8 +490,7 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
private _openWrappedEtherActionRow(wrappedEtherDirection: Side): void {
const action =
wrappedEtherDirection === Side.Deposit ? 'Wallet - Wrap ETH Opened' : 'Wallet - Unwrap WETH Opened';
- // tslint:disable-next-line:no-floating-promises
- analytics.trackAsync(action);
+ analytics.track(action);
this.setState({
wrappedEtherDirection,
});
@@ -499,8 +498,7 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
private _closeWrappedEtherActionRow(wrappedEtherDirection: Side): void {
const action =
wrappedEtherDirection === Side.Deposit ? 'Wallet - Wrap ETH Closed' : 'Wallet - Unwrap WETH Closed';
- // tslint:disable-next-line:no-floating-promises
- analytics.trackAsync(action);
+ analytics.track(action);
this.setState({
wrappedEtherDirection: undefined,
});
diff --git a/packages/website/ts/components/wallet/wrap_ether_item.tsx b/packages/website/ts/components/wallet/wrap_ether_item.tsx
index 9e3d06817..2b85b69be 100644
--- a/packages/website/ts/components/wallet/wrap_ether_item.tsx
+++ b/packages/website/ts/components/wallet/wrap_ether_item.tsx
@@ -196,15 +196,13 @@ export class WrapEtherItem extends React.Component<WrapEtherItemProps, WrapEther
if (this.props.direction === Side.Deposit) {
await this.props.blockchain.convertEthToWrappedEthTokensAsync(etherToken.address, amountToConvert);
this.props.dispatcher.showFlashMessage(`Successfully wrapped ${ethAmount} ETH to WETH`);
- // tslint:disable-next-line:no-floating-promises
- analytics.trackAsync('Wrap ETH Success', {
+ analytics.track('Wrap ETH Success', {
amount: ethAmount,
});
} else {
await this.props.blockchain.convertWrappedEthTokensToEthAsync(etherToken.address, amountToConvert);
this.props.dispatcher.showFlashMessage(`Successfully unwrapped ${tokenAmount} WETH to ETH`);
- // tslint:disable-next-line:no-floating-promises
- analytics.trackAsync('Unwrap WETH Success', {
+ analytics.track('Unwrap WETH Success', {
amount: tokenAmount,
});
}
@@ -219,14 +217,12 @@ export class WrapEtherItem extends React.Component<WrapEtherItemProps, WrapEther
logUtils.log(err.stack);
if (this.props.direction === Side.Deposit) {
this.props.dispatcher.showFlashMessage('Failed to wrap your ETH. Please try again.');
- // tslint:disable-next-line:no-floating-promises
- analytics.trackAsync('Wrap ETH Failure', {
+ analytics.track('Wrap ETH Failure', {
amount: ethAmount,
});
} else {
this.props.dispatcher.showFlashMessage('Failed to unwrap your WETH. Please try again.');
- // tslint:disable-next-line:no-floating-promises
- analytics.trackAsync('Unwrap WETH Failed', {
+ analytics.track('Unwrap WETH Failed', {
amount: tokenAmount,
});
}
diff --git a/packages/website/ts/redux/analyticsMiddleware.ts b/packages/website/ts/redux/analyticsMiddleware.ts
index e848ca3fd..1ef9b6ad7 100644
--- a/packages/website/ts/redux/analyticsMiddleware.ts
+++ b/packages/website/ts/redux/analyticsMiddleware.ts
@@ -8,34 +8,29 @@ export const analyticsMiddleware: Middleware = store => next => action => {
const nextState = (store.getState() as any) as State;
switch (action.type) {
case ActionTypes.UpdateInjectedProviderName:
- // tslint:disable-next-line:no-floating-promises
- analytics.addEventPropertiesAsync({
+ analytics.addEventProperties({
injectedProviderName: nextState.injectedProviderName,
});
break;
case ActionTypes.UpdateNetworkId:
- // tslint:disable-next-line:no-floating-promises
- analytics.addEventPropertiesAsync({
+ analytics.addEventProperties({
networkId: nextState.networkId,
});
break;
case ActionTypes.UpdateUserAddress:
- // tslint:disable-next-line:no-floating-promises
- analytics.addUserPropertiesAsync({
+ analytics.addUserProperties({
ethAddress: nextState.userAddress,
});
break;
case ActionTypes.UpdateUserEtherBalance:
if (nextState.userEtherBalanceInWei) {
- // tslint:disable-next-line:no-floating-promises
- analytics.addUserPropertiesAsync({
+ analytics.addUserProperties({
ethBalance: nextState.userEtherBalanceInWei.toString(),
});
}
break;
case ActionTypes.UpdatePortalOnboardingStep:
- // tslint:disable-next-line:no-floating-promises
- analytics.trackAsync('Update Onboarding Step', {
+ analytics.track('Update Onboarding Step', {
stepIndex: nextState.portalOnboardingStep,
});
break;
diff --git a/packages/website/ts/utils/analytics.ts b/packages/website/ts/utils/analytics.ts
index 2ff9f8918..e39998d7a 100644
--- a/packages/website/ts/utils/analytics.ts
+++ b/packages/website/ts/utils/analytics.ts
@@ -12,7 +12,6 @@ export interface HeapAnalytics {
removeEventProperty(property: string): void;
clearEventProperties(): void;
}
-
export class Analytics {
private _heap: HeapAnalytics;
public static init(): Analytics {
@@ -29,45 +28,39 @@ export class Analytics {
constructor(heap: HeapAnalytics) {
this._heap = heap;
}
+ // tslint:disable:no-floating-promises
// HeapAnalytics Wrappers
- public async indentifyAsync(id: string, idType: string): Promise<void> {
- await this._heapLoadedGuardAsync();
- this._heap.indentify(id, idType);
+ public indentify(id: string, idType: string): void {
+ this._heapLoadedGuardAsync(() => this._heap.indentify(id, idType));
}
- public async trackAsync(eventName: string, eventProperties?: ObjectMap<string | number>): Promise<void> {
- await this._heapLoadedGuardAsync();
- this._heap.track(eventName, eventProperties);
+ public track(eventName: string, eventProperties?: ObjectMap<string | number>): void {
+ this._heapLoadedGuardAsync(() => this._heap.track(eventName, eventProperties));
}
- public async resetIdentityAsync(): Promise<void> {
- await this._heapLoadedGuardAsync();
- this._heap.resetIdentity();
+ public resetIdentity(): void {
+ this._heapLoadedGuardAsync(() => this._heap.resetIdentity());
}
- public async addUserPropertiesAsync(properties: ObjectMap<string | number>): Promise<void> {
- await this._heapLoadedGuardAsync();
- this._heap.addUserProperties(properties);
+ public addUserProperties(properties: ObjectMap<string | number>): void {
+ this._heapLoadedGuardAsync(() => this._heap.addUserProperties(properties));
}
- public async addEventPropertiesAsync(properties: ObjectMap<string | number>): Promise<void> {
- await this._heapLoadedGuardAsync();
- this._heap.addEventProperties(properties);
+ public addEventProperties(properties: ObjectMap<string | number>): void {
+ this._heapLoadedGuardAsync(() => this._heap.addEventProperties(properties));
}
- public async removeEventPropertyAsync(property: string): Promise<void> {
- await this._heapLoadedGuardAsync();
- this._heap.removeEventProperty(property);
+ public removeEventProperty(property: string): void {
+ this._heapLoadedGuardAsync(() => this._heap.removeEventProperty(property));
}
- public async clearEventPropertiesAsync(): Promise<void> {
- await this._heapLoadedGuardAsync();
- this._heap.clearEventProperties();
+ public clearEventProperties(): void {
+ this._heapLoadedGuardAsync(() => this._heap.clearEventProperties());
}
+ // tslint:enable:no-floating-promises
// Custom methods
- public async trackOrderEventAsync(eventName: string, order: Order): Promise<void> {
+ public trackOrderEvent(eventName: string, order: Order): void {
const orderLoggingData = {
takerTokenAmount: order.signedOrder.takerTokenAmount,
makeTokenAmount: order.signedOrder.makerTokenAmount,
takerToken: order.metadata.takerToken.symbol,
makerToken: order.metadata.makerToken.symbol,
};
- // tslint:disable-next-line:no-floating-promises
- this.trackAsync(eventName, orderLoggingData);
+ this.track(eventName, orderLoggingData);
}
/**
* Heap is not available as a UMD module, and additionally has the strange property of replacing itself with
@@ -75,13 +68,15 @@ export class Analytics {
* Instead of having an await call before every analytics use, we opt to have the awaiting logic in here by
* guarding every API call with the guard below.
*/
- private async _heapLoadedGuardAsync(): Promise<void> {
+ private async _heapLoadedGuardAsync(callback: () => void): Promise<void> {
if (this._heap.loaded) {
+ callback();
return undefined;
}
await utils.onPageLoadPromise;
// HACK: Reset heap to loaded heap
this._heap = (window as any).heap;
+ callback();
}
}
diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts
index bd6a57eea..9c5e12ec7 100644
--- a/packages/website/ts/utils/utils.ts
+++ b/packages/website/ts/utils/utils.ts
@@ -318,7 +318,7 @@ export const utils = {
resolve();
return;
}
- window.onload = () => resolve();
+ window.onload = resolve;
}),
getProviderType(provider: Provider): Providers | string {
const constructorName = provider.constructor.name;