-
Notifications
You must be signed in to change notification settings - Fork 112
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
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
2df33e9
Build local copy of Digital Analytics Program
aduth 249fa5a
Remove CSP exceptions for DAP CDN
aduth 8cf8e8f
Download and patch DAP as postinstall
aduth fb1e070
Consistently return string value from UriService#add_params
aduth 49948fa
Add spec to load DAP script
aduth cf3aa92
Update DAP script test to check syntax error on load
aduth b921c19
Add DAP script to ESLint ignore
aduth 028d6b0
Add test for url_params behavior
aduth 329cbed
Better coverage for combination url_params and attributes
aduth 5071007
Treat url_params as distinct property
aduth 272f969
Use conventional capitalization
aduth 38f68ba
Separate download and patch tasks to cache-bust by SHA
aduth 3f95f33
Ignore DAP script in TypeScript checks
aduth 843fdcd
Use more Makefile wizardry to generate compiled DAP
aduth ce88019
Run analytics postinstall using Yarn cwd
aduth bb8eb54
Try avoiding default NPM lifecycle script names
aduth a9afae0
Test using full install in cwd package
aduth af338d6
Try incorporating analytics tasks in build:js
aduth 7ca7d8a
Combine make tasks in build:js
aduth f9621b8
Force analytics task in top-level Makefile
aduth 4271a1f
Split install and build tasks for analytics
aduth 453ec58
Copy Makefile earlier in Docker images
aduth 6a71e47
Try complete build if folder available
aduth c626bf6
Revert to original postinstall approach
aduth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ public | |
vendor | ||
coverage | ||
doc | ||
app/javascript/packages/analytics/digital-analytics-program*.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
digital-analytics-program*.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
DAP_SHA ?= 7c14bb3 | ||
|
||
digital-analytics-program.js: digital-analytics-program-$(DAP_SHA).js digital-analytics-program.patch | ||
patch -p1 $^ --output $@ | ||
|
||
digital-analytics-program-$(DAP_SHA).js: | ||
curl https://raw.githubusercontent.com/digital-analytics-program/gov-wide-code/$(DAP_SHA)/Universal-Federated-Analytics.js --silent --output $@ | ||
|
||
clean: | ||
rm digital-analytics-program-$(DAP_SHA).js digital-analytics-program.js | ||
|
||
.PHONY: clean |
8 changes: 8 additions & 0 deletions
8
app/javascript/packages/analytics/digital-analytics-program.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
73a74 | ||
> GA4Object.async = true; | ||
785d785 | ||
< var piiRegex = []; | ||
900c900 | ||
< piiRegex.forEach(function (pii) { | ||
--- | ||
> window.piiRegex.forEach(function (pii) { | ||
26 changes: 26 additions & 0 deletions
26
app/javascript/packages/analytics/digital-analytics-program.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Worker } from 'node:worker_threads'; | ||
import { join } from 'node:path'; | ||
import { pathToFileURL } from 'node:url'; | ||
|
||
describe('digital analytics program', () => { | ||
it('parses without syntax error', async () => { | ||
// Future: Replace with Promise.withResolvers once supported | ||
// See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers | ||
let resolve; | ||
const promise = new Promise((_resolve) => { | ||
resolve = _resolve; | ||
}); | ||
|
||
// Reference: https://github.com/nodejs/node/issues/30682 | ||
const toDataURL = (source: string) => | ||
new URL(`data:text/javascript,${encodeURIComponent(source)}`); | ||
const url = pathToFileURL(join(__dirname, './digital-analytics-program.js')); | ||
const code = `await import(${JSON.stringify(url)});`; | ||
new Worker(toDataURL(code)).on('error', (error) => { | ||
expect(error).not.to.be.instanceOf(SyntaxError); | ||
resolve(); | ||
}); | ||
|
||
await promise; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import '@18f/identity-analytics/digital-analytics-program'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See: digital-analytics-program/gov-wide-code#118 (comment)