Closed jsoules closed 1 year ago
Merging #58 (c7a15e6) into main (a4458d5) will decrease coverage by
0.05%
. The diff coverage is0.00%
.
@@ Coverage Diff @@
## main #58 +/- ##
========================================
- Coverage 5.64% 5.59% -0.05%
========================================
Files 60 61 +1
Lines 5385 5431 +46
Branches 21 21
========================================
Hits 304 304
- Misses 5081 5127 +46
Flag | Coverage Δ | |
---|---|---|
gui_units | 6.78% <0.00%> (-0.08%) |
:arrow_down: |
svc_units | 2.30% <ø> (ø) |
Flags with carried forward coverage won't be shown. Click here to find out more.
Impacted Files | Coverage Δ | |
---|---|---|
src/App.tsx | 0.00% <0.00%> (ø) |
|
src/components/CookieLogic.tsx | 0.00% <0.00%> (ø) |
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more
This looks great. I think the message can be rephrased to be more positve. Right now it is:
This website uses an analytics cookie to count page views and estimate the size of the user base. No advertising information is collected, but you may opt out entirely if you wish.
Maybe just leave out the last phrase?
This website uses an analytics cookie to count page views and estimate the size of the user base. No advertising information is collected.
This PR introduces a couple of changes around supporting Google Analytics page tracking.
I've added dependencies on react-ga4 to interact with Google Analytics code, and react-cookie-consent to handle accounting for user tracking-cookie acceptance. Briefly considered vite-plugin-radar for the Google Analytics management, but the
react-ga4
package seems more popular and thus probably better supported.Then, largely following this guide (https://dev.to/ramonak/react-enable-google-analytics-after-a-user-grants-consent-5bg3), I've implemented cookie tracking, and per-page setup & hit counting via Google Analytics if the user has consented. Nothing should be tracked if the user does not opt in.
I also added an
.env
file to record the Google Analytics tag and inject it into the app where needed.On the Google Analytics administration side, I have created a new Property and Data Stream for my account. I've turned off most of the enhanced measurement and tracking (which we don't much care about, and tends to be more intrusive), as well as denying any data exposure for advertising purposes. This should pretty much just be tracking unique page views at this point.
These changes do not affect any tested code, and I haven't started adding coverage for React components yet, so I haven't added anything there. I did run the GUI under dev mode and confirm that consent cookies are set as expected, that the cookie-consent message shows as expected (i.e. with the right text and does not re-show if the user makes an affirmative allow/deny decision), and that appropriate console messages are printed (per cookie status) corresponding to tracker activation and page-hit event logging. The Analytics ID doesn't actually work for localhost URLs, so I think we'll need to actually publish something in order to start seeing data on the Analytics side; to that end, I've redeployed to the dev site at https://flatironinstitute.github.io/mcmc-monitor/dev/?s=https://lit-bayou-76056.herokuapp.com -- this should start displaying the consent banner and (hopefully) relaying page hit information to Google Analytics shortly.