Repository navigation
feat: serve the landing page from a Cloudflare Worker, with analytics - #47
Merged
Merged
Conversation
A repository built before the Builder kept its Report's meta on the row points at an index in R2. When those files are gone (an emptied or new bucket), the page said "No Report of this repository yet" while its new Build ran. The Site now looks for the index, clears a pointer that leads nowhere, and the page waits for the Build instead. An index it finds is remembered for an hour.
The landing page counts its visitors by the same rules as the Site: the same regions, banner and levels, its own /ingest that trims the visitor's address, and three moments (a lookup, an install command copied, the theme changed). A small Worker runs only for the page, to write in the visitor's region and choice from Cloudflare's country, and for /ingest; every other file is a static asset. PostHog loads once the page is idle. The analytics config and the PostHog proxy move to packages/data so the Site and the landing page share one copy, and the visitor's choice is kept on the parent domain both share. DEPLOY.md, the READMEs and the privacy page describe the Worker in place of Pages.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
/ingestthat trims the visitor's address the same way, and three moments:lookup submitted,install command copied,theme changed. PostHog loads once the page is idle.apps/landing/wrangler.jsonc,apps/landing/worker/). The Worker runs only for the page, to write in the visitor's region and choice from Cloudflare's country, and for/ingest/*; every other file is a static asset. WithoutPOSTHOG_KEYit serves the page as it is.packages/data(@commitscape/data/analytics,@commitscape/data/posthog), used by the Site and the landing page. A visitor's choice is kept on the parent domain both share, so choosing once oncommitscape.comholds onapp.commitscape.com(once the Site'sPUBLIC_LANDING_URLis set).DEPLOY.mdsection 7, the READMEs and the privacy page describe the Worker in place of Pages.Checks
packages/data: typecheck, lint, 80 testsapps/site: typecheck, lint, every test (new: a Report whose files are gone, and one whose index is still stored)apps/landing: typecheck (page and Worker), lint, build, 8 tests (new: the Worker writes each visitor's settings, never caches them, and passes the page through without a key)wrangler deploy --dry-run: the Worker bundles (10 KiB) with 33 static filesAfter merging
pixelactstudio/commitscape, project namecommitscape-landing, deploy commandpnpm --filter @commitscape/landing exec wrangler deploy(the rest inDEPLOY.mdsection 7).POSTHOG_KEY, attachcommitscape.com, and set the Site'sPUBLIC_LANDING_URL=https://commitscape.com.