Skip to content

Inherit crossorigin on the injected web-vitals script#195

Merged
sanason merged 1 commit into
digital-analytics-program:developfrom
arpitjain099:chore/web-vitals-inherit-crossorigin
Jun 24, 2026
Merged

Inherit crossorigin on the injected web-vitals script#195
sanason merged 1 commit into
digital-analytics-program:developfrom
arpitjain099:chore/web-vitals-inherit-crossorigin

Conversation

@arpitjain099

Copy link
Copy Markdown
Contributor

Fixes #167.

On a page that sets Cross-Origin-Embedder-Policy: require-corp, the DAP tag can be given a crossorigin attribute so its response satisfies the policy. That works for Universal-Federated-Analytics-Min.js itself, but the web-vitals script that the analytics code injects dynamically (web-vitals.attribution.iife.js) never received the attribute, so it was blocked from loading (screenshot in the issue).

This reads the crossorigin value from the DAP script tag (#_fed_an_ua_tag, already referenced elsewhere in the file) and applies it to the injected web-vitals <script> element when present. When the page does not set crossorigin, nothing changes.

Universal-Federated-Analytics.js is the source; I regenerated Universal-Federated-Analytics-Min.js (and its map) with the repo's own npm run minify (terser + terser.config.json). Both files pass node --check.

@sanason sanason self-requested a review June 23, 2026 13:57
@sanason

sanason commented Jun 23, 2026

Copy link
Copy Markdown
Member

@arpitjain099 Could I ask you to rebase this? I had to make some unrelated changes to get the tests running again.

On pages that set Cross-Origin-Embedder-Policy: require-corp, the DAP tag
can carry a crossorigin attribute so its response satisfies the policy. The
dynamically injected web-vitals script never received that attribute, so it
was blocked from loading on such pages.

Read the crossorigin value from the DAP script tag (#_fed_an_ua_tag) and
apply it to the web-vitals script element when present. Regenerated the
minified bundle with the project's terser config.

Fixes #167

Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
@arpitjain099 arpitjain099 force-pushed the chore/web-vitals-inherit-crossorigin branch from 1ef99c0 to cb7f95b Compare June 24, 2026 00:43
@arpitjain099

Copy link
Copy Markdown
Contributor Author

Rebased onto develop - thanks for getting the tests green again. Should be good for another look.

@sanason sanason left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thank you, @arpitjain099 !

@sanason sanason merged commit 900f4bb into digital-analytics-program:develop Jun 24, 2026
1 check passed
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.

web-vitals.attribution.iife.js does not inherit crossorigin attribute from parent Universal-Federated-Analytics-Min.js script

2 participants