Skip to content

feat: serve the landing page from a Cloudflare Worker, with analytics - #47

Merged
devchaudhary24k merged 3 commits into
mainfrom
feat/landing-worker
Oct 26, 2026
Merged

devchaudhary24k merged 3 commits into
mainfrom
feat/landing-worker

Conversation

@devchaudhary24k

Copy link
Copy Markdown
Member

What

  • The landing page counts its visitors by the Site's rules. Same regions, banner, Only basic / Allow all levels and masking as the Site, its own /ingest that 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.
  • It is served by a Cloudflare Worker (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. Without POSTHOG_KEY it serves the page as it is.
  • One copy of the rules. The analytics config and the PostHog proxy move to 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 on commitscape.com holds on app.commitscape.com (once the Site's PUBLIC_LANDING_URL is set).
  • fix: a repository built before the Builder kept its Report's meta on the row, whose files are gone from R2, showed "No Report of this repository yet" while its new Build ran. The Site now clears a pointer that leads nowhere and the page waits for the Build.

DEPLOY.md section 7, the READMEs and the privacy page describe the Worker in place of Pages.

Checks

  • packages/data: typecheck, lint, 80 tests
  • apps/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 files

After merging

  1. Cloudflare: Workers & Pages, Create, Import a repository, pixelactstudio/commitscape, project name commitscape-landing, deploy command pnpm --filter @commitscape/landing exec wrangler deploy (the rest in DEPLOY.md section 7).
  2. Set the Worker's POSTHOG_KEY, attach commitscape.com, and set the Site's PUBLIC_LANDING_URL=https://commitscape.com.
  3. Redeploy the Site for the fix.

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.
@devchaudhary24k
devchaudhary24k merged commit bca9cd9 into main Oct 26, 2026
19 checks 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.

1 participant