Skip to content

Metrics: count the Wear OS app as a watch, and Home Assistant as its own family - #379

Merged
SiteRelEnby merged 2 commits into
mainfrom
feat/client-family-metrics
Nov 4, 2026
Merged

SiteRelEnby merged 2 commits into
mainfrom
feat/client-family-metrics

Conversation

@SiteRelEnby

Copy link
Copy Markdown
Contributor

Closes #337.

  • Wear OS reads zero because the watch never sends the header. The Wear OS client stamps Sheaf Android Wear/<version> on its User-Agent and nothing on X-Sheaf-Client, and the family parser only read the header, so watch traffic was other and the sessions list named those sessions "Unknown". effective_client_header now returns the header when sent, else the User-Agent when it starts with an official app prefix, else nothing; the family parser, the stored session name and the extended tier's version parse all read it. The no-browser-fallback rule for web is unchanged: a browser string never matches an official prefix. sheaf android wear/ is added to the prefix table (it is not a prefix collision with sheaf android/; they diverge after "android").
  • Home Assistant as a named automation family. client_family_from takes the User-Agent as well; for an API-key credential it checks a fixed table of integration prefixes (homeassistant/, what the shared HTTP session sends) and otherwise stays api. A session or JWT with that User-Agent is still other. homeassistant is added to ClientFamily and the metric label literal, so the pre-warm loop, the per-family gauges and the overlap pairs pick it up; it gets its own sketch under the api kind, flushed and restored like the interactive ones, so active_accounts_*_by_client{client_family="homeassistant"} is a subset of {auth_kind="api"} rather than a split of it. Other integrations can be added to the same table as they are identified.
  • METRICS.md and the client design notes describe the User-Agent fallback and the new family; changelog entries for both.

Verification

  • Classifier tests: the Wear OS User-Agent lands as watch with and without an empty header and is outranked by a sent header; a browser string and okhttp stay other; Home Assistant User-Agents are homeassistant only under an API key; the version parse works from the effective claim; the stored session name for a header-less watch is its User-Agent and classifies as watch.
  • Sketch scheme test extended for the automation ref and the account-scope refs. Classifier, usage-sketch, metrics, extended-metrics, session-store and auth suites pass against a rebuilt test stack. Ruff clean.

…own family

The Wear OS app identifies itself on its User-Agent, as
`Sheaf Android Wear/<version>`, and sends no X-Sheaf-Client header. The
family parser only ever read the header, so every watch request landed
in `other`, the watch family read zero, and the sessions list called the
watch "Unknown". An official app prefix on the User-Agent is now honoured
when no header is sent: it is the same claim carried in a different
header. A browser string never matches an official prefix, so the web app
is still counted only from its own header, as before. The stored session
name and the extended tier's version parse read the same effective claim.

An API-key request whose User-Agent starts `HomeAssistant/` is now the
`homeassistant` family rather than plain `api`. Named automation families
are decided from a fixed table, so the label set stays bounded, and each
gets its own active-account sketch under the api kind, a subset of the
api total rather than a split of it. `api` itself keeps meaning "an API
key, whatever it was".
@SiteRelEnby
SiteRelEnby enabled auto-merge November 4, 2026 01:45
@SiteRelEnby
SiteRelEnby merged commit 729c092 into main Nov 4, 2026
46 of 48 checks passed
@SiteRelEnby
SiteRelEnby deleted the feat/client-family-metrics branch November 4, 2026 01:53
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.

per-user-client metrics: look into WearOS reporting, add homeassistant as category

1 participant