Skip to content

Add Brockville Food Help analytics, mirroring Kingston (1.36.0) - #10

Merged
truegoodcraft merged 1 commit into
mainfrom
brockville-bfh-analytics
Oct 10, 2026
Merged

truegoodcraft merged 1 commit into
mainfrom
brockville-bfh-analytics

Conversation

@truegoodcraft

@truegoodcraft truegoodcraft commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Before: Lighthouse only accepts the Kingston collector. Brockville Food Help has analytics disabled, and events from https://brockville.food-help.ca are dropped.

After: Brockville is a second aggregate-only community that mirrors Kingston: ingestion v3 from https://brockville.food-help.ca only, the same six events and the same labels, no product signals (resource_open and install_prompt are rejected). It has its own site key (brockville_food_help), tables and report (GET /report?view=bfh, exactly report 1.2). Kingston behavior, tables and view=kfh are unchanged.

How: kfhAnalytics.ts now takes a KfhProfile (site key, origins, tables, signals and legacy flags) with Kingston as the default, so Brockville reuses the parser, atomic batch, body and rate limits instead of copying them. isKfhReport(value, siteKey) makes the two reports mutually invalid, and Brockville accepts only 1.2. Brockville is excluded from raw-event storage, view=site, fleet and source-health like Kingston, and its CORS never allows credentials. The cron prunes each community independently at 400 days.

Files: src/kfhContract.ts, src/kfhAnalytics.ts, src/index.ts (tracked site and origin allowlist, view=bfh, ingest routing by origin, CORS, prune), migrations/0019_add_bfh_daily.sql, contracts/bfh-v1/{empty,sample,unavailable}.json, tests/bfh-analytics.test.mjs, tests/release-control.test.mjs (version pin), plus KFH_ANALYTICS_CONTRACT.md, SOT.md, CHANGELOG.md, OPERATIONS.md, README.md, package.json and package-lock.json (1.35.0 to 1.36.0).

Checks: npm run typecheck clean; npm test 228/228 (7 new Brockville tests: strict v3, key and origin isolation, signals rejected, rollback, no-store auth route, retention, fixture parity). No remote database, production request or deployment was made. The Workers Builds check on this branch uploads a non-promoting preview version only.

Migration 0019 is additive: bfh_daily and bfh_outreach_daily, same columns and constraints as 0016 and 0017. It is not applied. Migration 0017's production state is still unverified, and Kingston's v3 path depends on it.

Rollout, each step separately approved

  1. Merge and deploy Agent Smith 0.33.0 (truegoodcraft/Agent_Smith, branch brockville-bfh-command). /bfh reports unavailable until step 4.
  2. Confirm 0017 is applied in production D1. Apply 0018 as well if Lighthouse 1.35.0's signals are going live in the same promotion.
  3. Apply 0019.
  4. Merge this PR (uploads a version only), then dispatch the manual deploy workflow from main. An approved /bfh read should show no_observed_history with zero counts. Promoting before 0019 is safe: Brockville events are dropped and /bfh is unavailable, Kingston is unaffected.
  5. Only then merge the Food Help change below and move release/brockville.

Rollback: set Brockville analytics.enabled back to false and re-release the site, then redeploy Lighthouse 1.35.0 (or 1.34.1). Smith simply reports /bfh unavailable. Do not drop the additive tables.

Food Help block (later, not part of this PR). In deployments/brockville/site.json, replace "analytics": { "enabled": false } with:

"analytics": {
  "enabled": true,
  "endpoint": "https://lighthouse.buscore.ca/metrics/event",
  "collection_mode": "opt_out",
  "preference_key": "bfh-optional-analytics",
  "content_type": "text/plain;charset=UTF-8",
  "click_keepalive": true,
  "disclosure": "Optional aggregate analytics is on by default. You can turn it off below at any time. It counts connected Emergency food directory loads, broad call/directions/source-link clicks there, and supported-browser installation signals. Lighthouse, our measurement service, receives only fixed event types and public outreach labels. It never receives which provider you chose, searches, filters, location or visitor identifiers. Daily totals are kept for up to 400 days; no individual activity history is stored. Connection information is briefly used for abuse control, with rotating keyed minute counters kept for about two days and no raw IP retained in analytics. Your yes/no choice is saved in this browser on this website, without an analytics cookie or identifier. Global Privacy Control, Do Not Track and local suppression settings keep collection off. Offline activity is never queued or replayed. Clicks do not establish that anyone received help.",
  "constants": { "site_key": "brockville_food_help", "contract_version": 3, "collection_mode": "opt_out", "page": "directory" },
  "event_payloads": {
    "page_start": { "event_name": "page_view" },
    "call": { "event_name": "contact_click", "event_value": "resource_call" },
    "help": { "event_name": "contact_click", "event_value": "help_211" },
    "directions": { "event_name": "outbound_click", "event_value": "directions" },
    "source": { "event_name": "outbound_click", "event_value": "official_source" },
    "install": { "event_name": "pwa_install" }
  },
  "attribution": {
    "events": ["page_start", "call", "help", "directions", "source"],
    "sources": ["direct_unknown", "facebook", "community", "search", "other", "reddit"],
    "campaigns": ["none", "launch_2026_09", "outreach_2026_09"],
    "contents": ["none", "post_01", "poster_01", "post_02"],
    "internal_hosts": ["brockville.food-help.ca"],
    "referrers": [
      { "host": "facebook.com", "source": "facebook", "include_subdomains": true },
      { "host": "reddit.com", "source": "reddit", "include_subdomains": true },
      { "host": "www.google.com", "source": "search" },
      { "host": "www.google.ca", "source": "search" },
      { "host": "www.bing.com", "source": "search" },
      { "host": "duckduckgo.com", "source": "search" }
    ]
  }
}

It omits the three optional signal payloads, so none are sent. Release step: after the Food Help PR is reviewed and merged, npm run release -- --site deployments/brockville --publish moves only release/brockville (separate approval). Add a Food Help test that imports this parser and asserts every emitted Brockville payload parses. Verify with a local collector first: a live test view is permanently counted and cannot be removed by identity.

https://brockville.food-help.ca serves publicly today (page title "Brockville Food Help"); the Pages project and DNS are live.

…36.0)

Parameterize the Kingston collector by profile and add Brockville: v3 ingestion from https://brockville.food-help.ca only, additive migration 0019 (bfh_daily, bfh_outreach_daily) and GET /report?view=bfh returning exactly report 1.2. Kingston behavior is unchanged.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
buscore-lighthouse a4edfe2 Commit Preview URL

Branch Preview URL
Oct 10 2026, 02:06 PM

@truegoodcraft truegoodcraft self-assigned this Oct 10, 2026
@truegoodcraft
truegoodcraft marked this pull request as ready for review October 10, 2026 17:09
@truegoodcraft
truegoodcraft merged commit a0619d6 into main Oct 10, 2026
2 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