Web Analytics 0.10.0: Rate limits for public routes, API request tracking and a proxy check
Web Analytics 0.10.0 lets a Phoenix site rate-limit its public routes by visitor and by network, records API requests on the Events page, and warns you when a reverse proxy makes every visitor look like one address.
Rate limits
A developer adds PhoenixKitWebAnalytics.RateLimit.Plug to a pipeline with rules: which paths, which methods, how many requests per visitor and per network in a time window. Each request a rule covers is counted for its visitor and for its network, and both must have room, so a client that changes its browser string is still held by its network. A refused request gets a 429 with a retry-after header, as JSON or a small HTML page. The site’s internal networks, its staff, local development and requests carrying a bypass token are never limited. Nothing is limited until the plug is installed.
In Settings, a new Rate limits section switches the limits on, to log only (record what would be refused and let it through, to tune the limits first) or off. It is on by default, but does nothing until the plug is installed. Blocked networks lists addresses or networks to refuse with a 403 on every path the plug covers; nothing is ever added to it by itself.
The new Rate limits page under Web Analytics shows the rules, what each has allowed, refused and logged on this server since it started, and the latest refusals. All of it lives in memory; nothing about a refusal is stored in the database.
The new Rate limits page.
API requests on the Events page
List paths under API requests in Settings, one pattern per line, and requests to them are recorded with their method and status. The Events page then shows an API requests card by method and path, an API responses card by status class, and API requests in the live feed menu. They are not page views and join no visit, so no other number changes. At most 60 a minute per visitor are kept. It is off while the list is empty, and the tracking plug has to be in the API routes’ pipeline.
A check of visitors’ addresses
Settings now look at the last 200 page views on the server and warn when every visitor seems to be one address: All your visitors look like one internal address. points to a reverse proxy that doesn’t pass the visitor’s address on, and says what to change. When all is well, a short line says the addresses look right. Only a summary is kept in memory, never the addresses.
Upgrading
Web Analytics 0.10 needs PhoenixKit 3.5 or later: update core first. There are no migrations. Rate limits and API tracking stay off until a developer installs the plug or lists API paths.
Full release notes: Web Analytics 0.10.0
0.10.0 · 15 November 2026
No migrations. Requires PhoenixKit core 3.5.0 or later.
Added
- The visitor in your own code.
PhoenixKitWebAnalytics.visitor/1returns the request’s visitor as the module counts it —%{visitor_id, ip, network, prefetch?}, the same ID the request’s page view is stored under — andput_visitor/1keeps it inconn.privatefor the rest of the request. It never creates the salt and stores nothing (RequestVisitor). - Rate limits (opt-in).
PhoenixKitWebAnalytics.RateLimit.Plugwith rules in the router, counted per visitor and per network on core’s Hammer counters, andRateLimit.charge/3/check/3for work that is expensive only sometimes. Internal networks, staff, local development and a bypass token from app config are never limited. A429withretry-afterandratelimit-*headers, JSON or HTML, or the host’s ownon_deny:. Settings:web_analytics_rate_limit(on/log_only/off) andweb_analytics_blocked_networks_secret(answered403). A new Rate limits admin page shows the rules, this node’s counts and the latest refusals — all in memory, nothing in the database. Telemetry:[:phoenix_kit_web_analytics, :rate_limit, :deny | :block]. - API requests (off by default). Paths listed in
web_analytics_track_api_pathsare recorded as"api"events — method, path, 2xx–4xx status — and shown on the Events page (Reports.api_requests/2). They are never page views and never part of a visit: no visitor, visit, bounce, entry/exit or “right now” number changes. Capped at 60 a minute per visitor and 240 per network (api_events_per_minute). The tracking plug must be in the API routes’ pipeline. - A client-address check. The plug samples the last 200 page views in
memory (booleans and a keyed hash, never an address), and Settings warns
when every visitor looks like one internal address — a reverse proxy
that doesn’t append
X-Forwarded-For— or one public one.PhoenixKitWebAnalytics.ip_health/0.
Changed
- Core pin raised to
>= 3.5.0 and < 4.0.0, the ecosystem-wide minimum; the feature detection for older cores is gone. - An unactivated Speculation-Rules prerender records nothing on its LiveView socket (no presence, interaction, patch or leave) until a connect after activation.
- With header storage on, the rate-limit bypass header’s value (default
x-rate-limit-bypass, or the configuredbypass_header) is never kept. - Locked dependencies refreshed (
phoenix_kit3.6.0).
Fixed
RateLimit.charge/3with a visitor map whosevisitor_idisnil(no salt yet) counted every visitor of a network against one per-visitor limit; it is now counted by its network alone.- A malformed rule in
config :phoenix_kit_web_analytics, :rate_limit, rules:made every configured rule unknown tocharge/3, silently; it now skips only itself, with its own warning. That warning no longer says the request was allowed, and it no longer silences a real counter failure. - A settings read that fails kept rate limits on but dropped the networks
in
config :phoenix_kit_web_analytics, internal_networks:, so an office listed only there could be limited. Those networks still exempt. The blocklist, which lives only in settings, stays empty. charge/3spent a visitor’s remaining allowance on a cost that did not fit, so a smaller charge in the same window was then refused. Both buckets are checked before either is charged.
Web Analytics 0.10.0. Install or update: {:phoenix_kit_web_analytics, "~> 0.10"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.