From 6a107e584aec622f21c96fd8423631064cad0d73 Mon Sep 17 00:00:00 2001 From: Kelly Innes Date: Tue, 26 Mar 2019 12:06:38 -0400 Subject: [PATCH 1/2] Only track users who have accepted GA tracking - add util.ga.js file with functions for getting and setting a value for the user's choice to accept or reject cookies and starting tracking if and only if a user has explicitly accepted the tracking code - add util.ga.tests.js file with tests for localstorage - update GDPRNotification component to use utility functions - conditionally call tracking code in GDPRNotification's componentDidMount method if and only if a user has already clicked the Accept link in the GDPRNotification snackbar - update cookie opt out Snackbar message with approved text - set link to TOS & privacy policy Connects #265 - send TRACKING_CONSENT event to Google Analytics prior to each pageview - add moment library for date parsing and comparison - store date user decided in localstorage - expire date after one year - don't track if date is expired --- src/app/package.json | 1 + src/app/public/index.html | 26 ++- src/app/src/__tests__/util.ga.tests.js | 91 ++++++++++ src/app/src/components/GDPRNotification.jsx | 73 +++++--- src/app/src/util/util.ga.js | 175 ++++++++++++++++++++ src/app/yarn.lock | 5 + 6 files changed, 341 insertions(+), 30 deletions(-) create mode 100644 src/app/src/__tests__/util.ga.tests.js create mode 100644 src/app/src/util/util.ga.js diff --git a/src/app/package.json b/src/app/package.json index a5542860a..7733c6a60 100644 --- a/src/app/package.json +++ b/src/app/package.json @@ -15,6 +15,7 @@ "google-map-react": "1.1.2", "immutability-helper": "2.9.0", "lodash": "4.17.11", + "moment": "2.24.0", "prop-types": "15.6.2", "react": "16.7.0", "react-copy-to-clipboard": "5.0.1", diff --git a/src/app/public/index.html b/src/app/public/index.html index 6a90f3277..2eeade6df 100644 --- a/src/app/public/index.html +++ b/src/app/public/index.html @@ -8,7 +8,7 @@ - + @@ -32,15 +32,25 @@ Open Apparel Registry (beta) - + +