Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build local copy of Digital Analytics Program #11097

Merged
merged 24 commits into from
Aug 20, 2024
Merged

Build local copy of Digital Analytics Program #11097

merged 24 commits into from
Aug 20, 2024

Conversation

aduth
Copy link
Member

@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
785d785
< var piiRegex = [];
900c900
< piiRegex.forEach(function (pii) {
---
> window.piiRegex.forEach(function (pii) {
Copy link
Member Author

Choose a reason for hiding this comment

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

app/helpers/script_helper.rb Outdated Show resolved Hide resolved
aduth added a commit that referenced this pull request Aug 16, 2024
See: #11097 (comment)

Co-authored-by: Zach Margolis <zachmargolis@users.noreply.github.com>
@aduth aduth marked this pull request as ready for review August 16, 2024 19:09
@aduth
Copy link
Member 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"
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
2 checks passed
@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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants