From 7d64ec2d55ed2f14ca924ae4ce6dedc879621cfe Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 16 May 2019 11:39:25 +0200 Subject: [PATCH] fix react-ga initialization --- client/src/hoc/withTracker.tsx | 10 +++++----- client/src/routes/Details/AssetFile.test.tsx | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/client/src/hoc/withTracker.tsx b/client/src/hoc/withTracker.tsx index f5a74b2..272b8dc 100644 --- a/client/src/hoc/withTracker.tsx +++ b/client/src/hoc/withTracker.tsx @@ -3,15 +3,15 @@ import ReactGA, { FieldsObject } from 'react-ga' import { RouteComponentProps } from 'react-router-dom' import { analyticsId } from '../config' +ReactGA.initialize(analyticsId, { + testMode: process.env.NODE_ENV === 'test', + debug: false +}) + const withTracker =

( WrappedComponent: any, options: FieldsObject = {} ) => { - ReactGA.initialize(analyticsId, { - testMode: process.env.NODE_ENV === 'test', - debug: false - }) - const trackPage = (page: string) => { options.isWeb3 = window.web3 !== undefined diff --git a/client/src/routes/Details/AssetFile.test.tsx b/client/src/routes/Details/AssetFile.test.tsx index 2b866d6..5b135b7 100644 --- a/client/src/routes/Details/AssetFile.test.tsx +++ b/client/src/routes/Details/AssetFile.test.tsx @@ -4,6 +4,7 @@ import React from 'react' import { render, fireEvent } from 'react-testing-library' import { DDO } from '@oceanprotocol/squid' import { StateMock } from '@react-mock/state' +import ReactGA from 'react-ga' import { User } from '../../context' import AssetFile from './AssetFile' @@ -31,6 +32,8 @@ const contextConnectedMock = { message: '' } +ReactGA.initialize('foo', { testMode: true }) + describe('AssetFile', () => { it('renders without crashing', () => { const { container } = render()