Skip to main content

Module record

Module record 

Source
Expand description

Counting traffic: every request (fed from the access-log path, so all protocols and whether or not lines are written) lands in hourly counts per host and group, daily unique visitors, and daily top lists.

Bounded by construction: every site the configuration routes (set_configured_hosts, up to MAX_SLOTS) and MAX_HOSTS other Host headers (more go to other), hourly buckets for retention_days, top lists of TOP entries a day (the rest added to (other)), MAX_PENDING undecided browsers per shard, a classification cache of MAX_CACHE per shard. Unique visitors are counted with hash(secret, day, host, ip, user-agent) — the secret is made at start and never stored, nor are the hashes — so nobody can be followed from one day to the next and no IP or User-Agent is kept.

A browser isn’t a person until it loads a stylesheet, script or font as a browser rendering the page does: its requests wait in a pending record and are counted as a person’s then, or as “browser, no assets” (a bot) after UNDECIDED without one — or at once after 32 requests without one.

Constants§

BEHAVIOUR
The per-day lists the script feeds ([traffic] script): seconds and page views with a report, keyed host/path; scroll depth, screen sizes, events and event properties, keyed host\tvalue; goal conversions (sessions that reached the goal), keyed host\tgoal.
DIMS
The per-day lists of people’s audience and sources, keyed host\tvalue: countries, browsers, OSes and device classes count visitors; channels and UTM values count visits (page views arriving from outside the site).
DIM_SAVED
Entries of each audience/source list kept on disk.
DIM_TOP
Entries a day’s audience/source list keeps (all hosts together).
EXTRA
The per-day lists added in 18.35, all keyed by host first:
GROUPS
How many groups are counted.
LIVE_WINDOW
How far back the live view looks.
MAX_CACHE
Classifications cached per shard.
MAX_ENGAGED_SECS
The longest time on one page counted (a tab left open).
MAX_HOSTS
Host headers that aren’t a configured site counted separately; others are other.
MAX_OPEN_SESSIONS
Sessions open at once, per shard; past it the quietest is closed.
MAX_PENDING
Browsers awaiting their first asset, per shard.
MAX_RECENT
People’s recent page views kept for it, per shard.
MAX_REPORTS
Reports a session may make; the rest are ignored.
MAX_SLOTS
Host slots in all (the index is a u8; one is kept for other).
MAX_VISITS
Visits kept for the recent-visitors feed (across all days).
SESSION_GAP
A person’s page views more than this apart are separate sessions (as Google Analytics counts them).
TOP
Entries a daily top list keeps.
TOP_SAVED
Entries of each top list kept on disk and reported.
UNDECIDED
A browser that loads no asset this long after its last request isn’t a person.
VISIT_PAGES
Pages a visit lists.

Functions§

enable
Start counting (the binary does this when the admin API is on).
enabled
Whether requests are being counted.
now
Seconds since the epoch, as the counts use.
set_configured_hosts
The sites the configuration routes ([[route]] match.host): each gets its own counts, ahead of whatever else arrives in a Host header, and is listed first on the Traffic page. Set at start and on every reload.