Skip to content

Add x-cf-pages-analytics header when Web Analytics token is injected #9817

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

Merged
merged 1 commit into from
Jul 9, 2025

Conversation

GregBrimble
Copy link
Contributor

@GregBrimble GregBrimble commented Jul 2, 2025

Fixes WC-3619.

  • Emit x-cf-pages-analytics: 1 header when analytics script is added to HTML responses
  • Add comprehensive tests covering HTML with/without body, non-HTML responses, and missing analytics config
  • Header indicates when analytics injection is attempted regardless of HTMLRewriter success

  • Tests
    • Tests included
    • Tests not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: internal change
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because: not wrangler

@GregBrimble GregBrimble requested review from a team as code owners July 2, 2025 01:28
Copy link

changeset-bot bot commented Jul 2, 2025

🦋 Changeset detected

Latest commit: 31a413e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cloudflare/pages-shared Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Jul 2, 2025
@GregBrimble GregBrimble added the blocked Blocked on other work label Jul 2, 2025
@GregBrimble
Copy link
Contributor Author

Ready for review, but cannot be merged yet.

Copy link

pkg-pr-new bot commented Jul 2, 2025

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@9817

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@9817

miniflare

npm i https://pkg.pr.new/miniflare@9817

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@9817

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@9817

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@9817

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@9817

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@9817

wrangler

npm i https://pkg.pr.new/wrangler@9817

commit: 31a413e

@GregBrimble GregBrimble force-pushed the add-web-analytics-header branch from 551cd4c to f181d39 Compare July 2, 2025 01:35
@GregBrimble GregBrimble changed the title Add x-cf-pages-analytics header when Web Analytics token is injected Add x-cf-pages-analytics header when Web Analytics token is injected Jul 2, 2025
Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

A couple of nits

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Jul 2, 2025
@GregBrimble GregBrimble force-pushed the add-web-analytics-header branch from f181d39 to 4da5a0d Compare July 9, 2025 00:08
@GregBrimble GregBrimble enabled auto-merge July 9, 2025 00:10
@GregBrimble GregBrimble disabled auto-merge July 9, 2025 00:29
- Emit `x-cf-pages-analytics: 1` header when analytics script is added to HTML responses
- Add comprehensive tests covering HTML with/without body, non-HTML responses, and missing analytics config
- Header indicates when analytics injection is attempted regardless of HTMLRewriter success
@GregBrimble GregBrimble force-pushed the add-web-analytics-header branch from 4da5a0d to 31a413e Compare July 9, 2025 00:40
@GregBrimble GregBrimble removed the blocked Blocked on other work label Jul 9, 2025
@GregBrimble GregBrimble enabled auto-merge July 9, 2025 00:57
@GregBrimble GregBrimble added this pull request to the merge queue Jul 9, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 9, 2025
@GregBrimble GregBrimble added this pull request to the merge queue Jul 9, 2025
github-merge-queue bot pushed a commit that referenced this pull request Jul 9, 2025
#9817)

- Emit `x-cf-pages-analytics: 1` header when analytics script is added to HTML responses
- Add comprehensive tests covering HTML with/without body, non-HTML responses, and missing analytics config
- Header indicates when analytics injection is attempted regardless of HTMLRewriter success
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 9, 2025
@GregBrimble GregBrimble added this pull request to the merge queue Jul 9, 2025
github-merge-queue bot pushed a commit that referenced this pull request Jul 9, 2025
#9817)

- Emit `x-cf-pages-analytics: 1` header when analytics script is added to HTML responses
- Add comprehensive tests covering HTML with/without body, non-HTML responses, and missing analytics config
- Header indicates when analytics injection is attempted regardless of HTMLRewriter success
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 9, 2025
@GregBrimble GregBrimble added this pull request to the merge queue Jul 9, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 9, 2025
@GregBrimble GregBrimble added this pull request to the merge queue Jul 9, 2025
@GregBrimble GregBrimble removed this pull request from the merge queue due to a manual request Jul 9, 2025
@GregBrimble GregBrimble added this pull request to the merge queue Jul 9, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 9, 2025
@GregBrimble GregBrimble added this pull request to the merge queue Jul 9, 2025
Merged via the queue into main with commit 6a0d990 Jul 9, 2025
36 of 40 checks passed
@GregBrimble GregBrimble deleted the add-web-analytics-header branch July 9, 2025 04:59
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Jul 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants