Skip to content

Build local copy of Digital Analytics Program#11097

Merged
aduth merged 24 commits intomainfrom
aduth-dap-local
Aug 20, 2024
Merged

Build local copy of Digital Analytics Program#11097
aduth merged 24 commits intomainfrom
aduth-dap-local

Conversation

@aduth
Copy link
Contributor

@aduth aduth commented Aug 16, 2024

🛠 Summary of changes

Updates usage of Digital Analytics Program to build and serve a local copy of the script.

Why?

📜 Testing Plan

Add to config/application.yml:

participate_in_dap: true

Verify analytics script loads successfully:

  1. Go to http://localhost:3000
  2. Verify on errors in local console, and that Google Analytics loads successfully. You should see some warnings about Third-party cookies being blocked in future versions of Chrome

Comment on lines 3 to 8
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aduth aduth marked this pull request as ready for review August 16, 2024 19:09
@aduth aduth requested a review from mitchellhenke August 16, 2024 19:09
@aduth
Copy link
Contributor Author

aduth commented Aug 16, 2024

We can also benefit from our Brotli compression, compared to Gzip used with the hosted version.

Before:

curl --silent "https://dap.digitalgov.gov/Universal-Federated-Analytics-Min.js?agency=GSA&subagency=TTS" | gzip-size

8.24 kB

After:

NODE_ENV=production yarn build && brotli-size public/packs/digital-analytics-program*.js

6.78 kB

Diff: -1.46kb (-17.6%)

@aduth aduth marked this pull request as draft August 19, 2024 14:33
aduth and others added 17 commits August 20, 2024 14:49
changelog: Internal, Performance, Optimize loading of Digital Analytics Program script
DAP script has too many side effects and manipulates DOM in a way that's hard to clean up. Absent some other way to create an isolated DOM, at least check that the script can be evaluated without syntax errors.
See: #11097 (comment)

Co-authored-by: Zach Margolis <zachmargolis@users.noreply.github.com>
Co-authored-by: Zach Margolis <zachmargolis@users.noreply.github.com>
In production environments, `yarn install --production` won't make workspaces available, so trying to use `yarn workspace ...` will fail. This achieves the same effect without relying on the workspace being "installed"
aduth added 7 commits August 20, 2024 14:49
In CI Dockerfile, app files aren't available at  time of install. This also aligns closer to how browsers.json is generated
Defer to sub-process to decide what needs to be done
Avoid dependency on package code existing during install step
@aduth aduth marked this pull request as ready for review August 20, 2024 19:27
@aduth aduth merged commit 85df0cf into main Aug 20, 2024
@aduth aduth deleted the aduth-dap-local branch August 20, 2024 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants