Refactor Analytics so that calls to ReactGA are all in a single module, combining the provider type util function, moving GA id to configs and using utils.onPageLoadAsync

This commit is contained in:
Fabio Berger
2018-03-10 16:53:42 +01:00
parent fc7e7d9331
commit cea8dcae3d
10 changed files with 83 additions and 82 deletions

View File

@@ -5,7 +5,6 @@ import * as _ from 'lodash';
import Dialog from 'material-ui/Dialog';
import Divider from 'material-ui/Divider';
import * as React from 'react';
import * as ReactGA from 'react-ga';
import { Blockchain } from 'ts/blockchain';
import { ExpirationInput } from 'ts/components/inputs/expiration_input';
import { HashInput } from 'ts/components/inputs/hash_input';
@@ -23,6 +22,7 @@ import { validator } from 'ts/schemas/validator';
import { AlertTypes, BlockchainErrs, HashData, Side, SideToAssetToken, Token, TokenByAddress } from 'ts/types';
import { constants } from 'ts/utils/constants';
import { errorReporter } from 'ts/utils/error_reporter';
import { analytics } from 'ts/utils/analytics';
import { utils } from 'ts/utils/utils';
enum SigningState {
@@ -255,12 +255,7 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G
if (didSignSuccessfully) {
const networkName = sharedConstants.NETWORK_NAME_BY_ID[this.props.networkId];
const eventLabel = `${this.props.tokenByAddress[debitToken.address].symbol}-${networkName}`;
ReactGA.event({
category: 'Portal',
action: 'Sign Order Success',
label: eventLabel,
value: debitToken.amount.toNumber(),
});
analytics.logEvent('Portal', 'Sign Order Success', eventLabel, debitToken.amount.toNumber());
this.setState({
globalErrMsg: '',
shouldShowIncompleteErrs: false,
@@ -273,11 +268,7 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G
globalErrMsg = 'You must enable wallet communication';
this.props.dispatcher.updateShouldBlockchainErrDialogBeOpen(true);
}
ReactGA.event({
category: 'Portal',
action: 'Sign Order Failure',
label: globalErrMsg,
});
analytics.logEvent('Portal', 'Sign Order Failure', globalErrMsg);
this.setState({
globalErrMsg,
shouldShowIncompleteErrs: true,