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

A Cloudflare Worker to handle requests to static.pantsbuild.org. #18685

Merged
merged 2 commits into from
Apr 6, 2023

Conversation

benjyw
Copy link
Sponsor Contributor

@benjyw benjyw commented Apr 5, 2023

The worker logs the requests with both Google Analytics 4 and Universal Analytics, and then redirects to pantsbuild.github.io.

The UA code is the current code we've been using for the last few years, but which we previously didn't check in to the repo.

Google is phasing out UA, which is why we now add GA4 support. Once both have overlapped successfully for a while, we'll shut down the UA side.

I've manually tested this code and verified that requests show up in both GA4 and UA as expected, and that the right content is returned.

The worker logs the requests with both Google Analytics 4 and
Universal Analytics, and then redirects to pantsbuild.github.io.

The UA code is the current code we've been using for the last few
years, but which we previously didn't check in to the repo.

Google is phasing out UA, which is why we now add GA4 support.
Once both have overlapped successfully for a while, we'll shut
down the UA side.

I've manually tested this code and verified that requests show up
in both GA4 and UA as expected, and that the right content
is returned.
@benjyw benjyw added the category:internal CI, fixes for not-yet-released features, etc. label Apr 5, 2023
}

// UA is being phased out in mid-2023, so we'll delete this once we have GA4 set up properly.
function sendToUA(headers, host, path) {
Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

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

The repetition, or near-repetition, is by design, so that we can easily delete this function after a suitable period of overlap.

userAgent = "" // GA accepts an empty user agent, go figure.
}

data = {
Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

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

The GA4 protocol is very different from the UA one, but we've been using UA for a long time, and I've verified that the GA version is correct.

@tobni
Copy link
Contributor

tobni commented Apr 5, 2023

You can add a javascript_sources target generator to get prettierjs formatting, if you'd like?

@benjyw
Copy link
Sponsor Contributor Author

benjyw commented Apr 5, 2023

Oh, excellent idea!

@benjyw
Copy link
Sponsor Contributor Author

benjyw commented Apr 5, 2023

Done

@benjyw benjyw merged commit 0689381 into pantsbuild:main Apr 6, 2023
@benjyw benjyw deleted the ga4 branch April 6, 2023 21:20
illicitonion added a commit to illicitonion/pants that referenced this pull request Apr 10, 2023
Internal changes:

* refactor `package_python_dist` rule so most of the logic can be reused ([pantsbuild#18701](pantsbuild#18701))

* A Cloudflare Worker to handle requests to static.pantsbuild.org. ([pantsbuild#18685](pantsbuild#18685))

* No need to use lambda when setting help text for ruff ([pantsbuild#18690](pantsbuild#18690))

* Lint fixes - suggested by ruff and flake8 ([pantsbuild#18681](pantsbuild#18681))

* Skip flaky pantsd integration tests. ([pantsbuild#18665](pantsbuild#18665))

* Add types-beautifulsoup4 to default module mapping ([pantsbuild#18647](pantsbuild#18647))

* Prepare the 2.16.0rc0 release. ([pantsbuild#18645](pantsbuild#18645))

* Prepare the 2.14.2rc1 release. ([pantsbuild#18646](pantsbuild#18646))

* Prepare the 2.15.1rc1 release. ([pantsbuild#18644](pantsbuild#18644))
illicitonion added a commit that referenced this pull request Apr 10, 2023
Internal changes:

* refactor `package_python_dist` rule so most of the logic can be reused
([#18701](#18701))

* A Cloudflare Worker to handle requests to static.pantsbuild.org.
([#18685](#18685))

* No need to use lambda when setting help text for ruff
([#18690](#18690))

* Lint fixes - suggested by ruff and flake8
([#18681](#18681))

* Skip flaky pantsd integration tests.
([#18665](#18665))

* Add types-beautifulsoup4 to default module mapping
([#18647](#18647))

* Prepare the 2.16.0rc0 release.
([#18645](#18645))

* Prepare the 2.14.2rc1 release.
([#18646](#18646))

* Prepare the 2.15.1rc1 release.
([#18644](#18644))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:internal CI, fixes for not-yet-released features, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants