diff --git a/package.json b/package.json index 8ec5458..350c6ac 100644 --- a/package.json +++ b/package.json @@ -13,13 +13,13 @@ "dependencies": { "apollo-client": "^0.7.2", "auth0-lock": "^10.7.2", - "autotrack": "^1.0.3", "graphql-anywhere": "^2.0.0", "graphql-tag": "^1.1.2", "next": "^2.0.0-beta", "nprogress": "^0.2.0", "path-match": "^1.2.4", "react-apollo": "^0.8.1", + "react-ga": "^2.1.2", "react-player": "^0.14.1", "smooch": "^3.9.3", "uuid": "^3.0.1" diff --git a/util/analytics.js b/util/analytics.js index 75e8505..afc93a6 100644 --- a/util/analytics.js +++ b/util/analytics.js @@ -1,28 +1,21 @@ import { ANALYTICS_TRACKING_ID } from '../config'; import { IS_BROWSER } from '../util/website'; +let ReactGA; +if (IS_BROWSER) { + ReactGA = require('react-ga'); // eslint-disable-line global-require +} + export function configureAnalytics() { if (IS_BROWSER) { - // eslint-disable-next-line - window.ga = window.ga || function () {(ga.q = ga.q || []).push(arguments)};ga.l = +new Date; - /* global ga: true */ - ga('create', ANALYTICS_TRACKING_ID, 'auto'); - ga('require', 'urlChangeTracker'); - /* eslint-disable global-require */ - require('autotrack/lib/plugins/clean-url-tracker'); - ga('require', 'cleanUrlTracker'); - require('autotrack/lib/plugins/outbound-form-tracker'); - ga('require', 'outboundFormTracker'); - require('autotrack/lib/plugins/outbound-link-tracker'); - /* eslint-enable global-require */ - ga('require', 'outboundLinkTracker'); + ReactGA.initialize(ANALYTICS_TRACKING_ID); } } export function pageView() { if (IS_BROWSER) { const page = window.location.pathname; - ga('set', 'page', page); - ga('send', 'pageview'); + ReactGA.set({ page }); + ReactGA.pageview(page); } } diff --git a/yarn.lock b/yarn.lock index f9749cc..9872efc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -249,14 +249,6 @@ auth0-lock@^10.7.2: trim "0.0.1" url-join "^1.1.0" -autotrack@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/autotrack/-/autotrack-1.0.3.tgz#9caef961eb9899cfe369e43d4340655233c4ac15" - dependencies: - debounce "^1.0.0" - dom-utils "^0.4.0" - object-assign "^4.1.0" - aws-sign2@~0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" @@ -1251,20 +1243,10 @@ dashdash@^1.12.0: dependencies: assert-plus "^1.0.0" -date-now@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/date-now/-/date-now-1.0.1.tgz#bb7d086438debe4182a485fb3df3fbfb99d6153c" - date-now@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b" -debounce@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/debounce/-/debounce-1.0.0.tgz#0948af513d2e4ce407916f8506a423d3f9cf72d8" - dependencies: - date-now "1.0.1" - debug@2.2.0, debug@^2.1.1, debug@^2.1.3, debug@^2.2.0, debug@~2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" @@ -1354,10 +1336,6 @@ doctrine@1.5.0, doctrine@^1.2.2: esutils "^2.0.2" isarray "^1.0.0" -dom-utils@^0.4.0: - version "0.4.1" - resolved "https://registry.yarnpkg.com/dom-utils/-/dom-utils-0.4.1.tgz#22f1dbaf5fddecfc0525f2c07e92695744054f5d" - dom-walk@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/dom-walk/-/dom-walk-0.1.1.tgz#672226dc74c8f799ad35307df936aba11acd6018" @@ -2452,20 +2430,13 @@ isobject@^2.0.0: dependencies: isarray "1.0.0" -isomorphic-fetch@2.2.0: +isomorphic-fetch@2.2.0, isomorphic-fetch@^2.1.1: version "2.2.0" resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.0.tgz#8a834c42f415535285651ff9742dde64f3ab532d" dependencies: node-fetch "^1.0.1" whatwg-fetch ">=0.10.0" -isomorphic-fetch@^2.1.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9" - dependencies: - node-fetch "^1.0.1" - whatwg-fetch ">=0.10.0" - isstream@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" @@ -3570,6 +3541,12 @@ react-dom@15.4.2, "react-dom@^15.0.0 || ^16.0.0": loose-envify "^1.1.0" object-assign "^4.1.0" +react-ga@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/react-ga/-/react-ga-2.1.2.tgz#7af206c5e8761d7176e15773fe826acdb70ac653" + dependencies: + object-assign "^4.0.1" + react-hot-loader@3.0.0-beta.6: version "3.0.0-beta.6" resolved "https://registry.yarnpkg.com/react-hot-loader/-/react-hot-loader-3.0.0-beta.6.tgz#463fac0bfc8b63a8385258af20c91636abce75f4" @@ -4453,7 +4430,7 @@ util@0.10.3, util@^0.10.3: dependencies: inherits "2.0.1" -uuid@2.0.1: +uuid@2.0.1, uuid@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/uuid/-/uuid-2.0.1.tgz#c2a30dedb3e535d72ccf82e343941a50ba8533ac" @@ -4461,10 +4438,6 @@ uuid@3.0.1, uuid@^3.0.0, uuid@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1" -uuid@^2.0.1: - version "2.0.3" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-2.0.3.tgz#67e2e863797215530dff318e5bf9dcebfd47b21a" - validate-npm-package-license@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz#2804babe712ad3379459acfbe24746ab2c303fbc"