Repository navigation
feat(telemetry): record a host's country and US state for location breakdowns - #682
Merged
Merged
Conversation
Host reports now carry where the host connects from: the two-letter country Cloudflare's edge assigns to the request and, for a US host, the state (50 states plus DC). The Worker adds both after validation, so a host can't set or change them, and keeps nothing finer: no city, postal code, coordinates or address. App, notification-extension and relay reports stay location-free. This lets the usage dashboard break models, OS and agents per host down by location. The docs describe the new values and note that a cloud or VPN host reports its server's location, not its owner's.
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.
The usage dashboard can't break model choice, host OS or agents per host down by location, because host telemetry records no location at all. This adds the host's country and, for a US host, its state.
What changes
country(the two-letter code Cloudflare's edge assigns to the connection) andusState(one of the 50 states or DC) to each event's properties.ai.location.ipstays0.0.0.0. Unknown (XX) and Tor (T1) connections get nothing, and a US region outside the state list keeps only the country.request.cf, after the allowlist, so a host that sendscountryorusStatein its context has them dropped like any other unknown key.docs/TELEMETRY.mdgets a Host location section, including that a cloud or VPN host reports its server's location, anddocs/SECURITY_AND_PRIVACY.mdpoints to it.The public privacy policy on bighelp.app needs one matching sentence. That's a separate change in
bighelp-site, and the Worker shouldn't be deployed before it ships.How you tested it
test/geo.test.ts(14 tests): codes for US and other countries, DC, territories, unknown and Tor, non-state US regions, missingcf; forwarded host events carry both values and no city, postal code, coordinates or client address; app batches get none; client-sent values are dropped and can't override. With the feature switched off, 3 of the forwarding tests fail.pnpm test(251 passed),pnpm typecheckandwrangler deploy --dry-runpass.Created with Claude Opus 5.5 in Hermes Agent.