From cea8dcae3dac2265d3780c95d6581fe48e9b94a4 Mon Sep 17 00:00:00 2001
From: Fabio Berger <me@fabioberger.com>
Date: Sat, 10 Mar 2018 16:53:42 +0100
Subject: 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

---
 packages/website/ts/components/fill_order.tsx | 30 +++++----------------------
 1 file changed, 5 insertions(+), 25 deletions(-)

(limited to 'packages/website/ts/components/fill_order.tsx')

diff --git a/packages/website/ts/components/fill_order.tsx b/packages/website/ts/components/fill_order.tsx
index e9127288d..11b756d8e 100644
--- a/packages/website/ts/components/fill_order.tsx
+++ b/packages/website/ts/components/fill_order.tsx
@@ -7,7 +7,6 @@ import { Card, CardHeader, CardText } from 'material-ui/Card';
 import Divider from 'material-ui/Divider';
 import RaisedButton from 'material-ui/RaisedButton';
 import * as React from 'react';
-import * as ReactGA from 'react-ga';
 import { Link } from 'react-router-dom';
 import { Blockchain } from 'ts/blockchain';
 import { TrackTokenConfirmationDialog } from 'ts/components/dialogs/track_token_confirmation_dialog';
@@ -24,6 +23,7 @@ import { validator } from 'ts/schemas/validator';
 import { AlertTypes, BlockchainErrs, Order, Token, TokenByAddress, WebsitePaths } 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';
 
 interface FillOrderProps {
@@ -544,12 +544,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
                 signedOrder,
                 this.props.orderFillAmount,
             );
-            ReactGA.event({
-                category: 'Portal',
-                action: 'Fill Order Success',
-                label: eventLabel,
-                value: parsedOrder.signedOrder.takerTokenAmount,
-            });
+            analytics.logEvent('Portal', 'Fill Order Success', eventLabel, parsedOrder.signedOrder.takerTokenAmount);
             // After fill completes, let's force fetch the token balances
             this.props.dispatcher.forceTokenStateRefetch();
             this.setState({
@@ -563,12 +558,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
             this.setState({
                 isFilling: false,
             });
-            ReactGA.event({
-                category: 'Portal',
-                action: 'Fill Order Failure',
-                label: eventLabel,
-                value: parsedOrder.signedOrder.takerTokenAmount,
-            });
+            analytics.logEvent('Portal', 'Fill Order Failure', eventLabel, parsedOrder.signedOrder.takerTokenAmount);
             const errMsg = `${err}`;
             if (utils.didUserDenyWeb3Request(errMsg)) {
                 return;
@@ -633,12 +623,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
                 globalErrMsg: '',
                 unavailableTakerAmount: takerTokenAmount,
             });
-            ReactGA.event({
-                category: 'Portal',
-                action: 'Cancel Order Success',
-                label: eventLabel,
-                value: parsedOrder.signedOrder.makerTokenAmount,
-            });
+            analytics.logEvent('Portal', 'Cancel Order Success', eventLabel, parsedOrder.signedOrder.makerTokenAmount);
             return;
         } catch (err) {
             this.setState({
@@ -648,12 +633,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
             if (utils.didUserDenyWeb3Request(errMsg)) {
                 return;
             }
-            ReactGA.event({
-                category: 'Portal',
-                action: 'Cancel Order Failure',
-                label: eventLabel,
-                value: parsedOrder.signedOrder.makerTokenAmount,
-            });
+            analytics.logEvent('Portal', 'Cancel Order Failure', eventLabel, parsedOrder.signedOrder.makerTokenAmount);
             globalErrMsg = 'Failed to cancel order, please refresh and try again';
             utils.consoleLog(`${err}`);
             this.setState({
-- 
cgit v1.2.3

