The bits of an event's traffic_flags — traffic that is real but isn't
the audience: the site's own people and their networks.
A flagged hit is stored like any other; reports leave it out unless the
settings count that kind in, or a report is switched to show it
(PhoenixKitWebAnalytics.Reports.filter/1). Nothing is deleted, so a
switch flipped back brings the hits back. Rollups only ever hold unflagged
traffic.
| Flag | Bit | Set when |
|---|---|---|
internal_network | 1 | the client address is in a network listed in config :phoenix_kit_web_analytics, internal_networks: […] |
admin | 2 | the signed-in user holds a role listed in web_analytics_internal_roles |
admin_network | 4 | the client's network (an IPv4 address, an IPv6 /64) had such a user signed in within web_analytics_admin_network_hours |
Bits 8, 16 and 32 are reserved for the suspicious-traffic signals planned
next (honeypot, headless, datacenter).
A visit is flagged whole: a hit inherits its session's bits, and a bit
that first appears mid-visit is written back to the visit's earlier hits
(PhoenixKitWebAnalytics.Collector). How the bits are worked out lives in
PhoenixKitWebAnalytics.InternalTraffic.
Summary
Functions
Every defined bit at once — the mask that leaves out all flagged traffic.
The bit of one flag.
Whether a hit with flags is left out under mask — any of its bits
among the masked ones.
Every defined flag, {name, bit}, in display order.
The label shown for a flag.
The mask of the bits to leave out, from the names to leave out.
Every defined flag's name.
The names of the bits set in flags.
Types
Functions
@spec all() :: pos_integer()
Every defined bit at once — the mask that leaves out all flagged traffic.
@spec bit(name()) :: pos_integer()
The bit of one flag.
Whether a hit with flags is left out under mask — any of its bits
among the masked ones.
@spec flags() :: [{name(), pos_integer()}]
Every defined flag, {name, bit}, in display order.
The label shown for a flag.
@spec mask([name()]) :: non_neg_integer()
The mask of the bits to leave out, from the names to leave out.
iex> PhoenixKitWebAnalytics.TrafficFlags.mask([:internal_network, :admin_network])
5
@spec names() :: [name()]
Every defined flag's name.
The names of the bits set in flags.
iex> PhoenixKitWebAnalytics.TrafficFlags.names_in(6)
[:admin, :admin_network]