All pages

Usage History

The popover shows today, this week or this month. Usage History keeps every hour behind those figures, per app and per network, for as long as you choose.

It's the first section of the main window. Open it from Open Usage History under Data in the popover, or the four squares beside the popover's gear: both open it on the popover's period. Or choose Usage History… (⌘Y) in the right-click menu, or Usage History in the main window's sidebar.

Using it

While Usage History is shown on a period that includes now, it refreshes every 30 seconds.

What counts

History counts the same internet-only figure as the popover. Mirroring a screen, Time Machine to a NAS or a Plex stream from your own server is never part of it. See accuracy for how that figure is worked out.

It starts the moment you install a version that has it (1.4.0 or later). Nothing from before can be recovered: the old totals have no hours in them, and spreading a lump over a day would be inventing data.

Sessions

A session is one visit to a network: from joining it until you leave for another, or until the Mac has been silent for 30 minutes, as it is after a sleep.

Networks

A network is identified by its router's hardware address, not its name. Two routers with the same Wi-Fi name stay apart, and roaming between access points of one network stays one network. The same router over Wi-Fi and over Ethernet is one network, which is what a data cap cares about.

What it's called:

CSV format

Hour,Network,Network Type,Metered,App,Downloaded (bytes),Uploaded (bytes),Update That Got Through

How it's built

Storage. ~/Library/Application Support/NetworkMonitor/history.sqlite, through the system's own SQLite library, with no third-party dependency. History only grows, and every view is a range query and a sum, which is the wrong shape for a JSON file. WAL journaling with synchronous = NORMAL: a write is an append rather than an fsync, and a crash can lose the last moments but never corrupt the file. A file that can't be opened is moved aside as history.unreadable-<time>.sqlite, never deleted, and a new one started.

Schema (UsageHistory.swift). One row per hour per session, and one per hour per session per app. An hour is the finest grain any view needs, and keeps a year to roughly a hundred thousand rows. The servers each app talked to, for Connections, are kept the same way.

Table Holds Key
sessions network id, type, default label, start, end (last traffic), metered id
apps app key, name, bundle path, whether it's System, parent app key
traffic per hour and session: interface bytes, LAN bytes, attributed app bytes, each way (hour, session_id)
app_traffic per hour, session and app: bytes in and out (hour, session_id, app_key)
servers a server's address; its name column is only read for rows from before #247 id
app_servers each app and server pair, once, with when it was first seen (#111) id
server_traffic per hour, session and app and server: bytes in and out, and connections blocked (#114) (hour, session_id, app_server_id)
server_names per hour, session and app and server: each name the app reached it by, and how many of those connections went through or were blocked (#247) (hour, session_id, app_server_id, name)
list_blocks per hour, session and app: each site a list blocked, the list, and how many times (#250) (hour, session_id, app_key, name, list)
updates each update that got through: the app, its version, the data it used, and the session it was first seen on (#96) (report, source, name)

The raw figures are stored and the internet figure is derived when reading, with the same clamp the popover uses, so the formula lives in one place: MIN(interface, MAX(interface − LAN, apps)) per direction, per hour and session.

Feeding. UsageStore forwards every byte and every network change to UsageHistory, so History and the popover can never disagree about which network a byte used. Reset Now and midnight clear the current connection's counter, never History.

Writing. Batched in memory and written when the usage file is saved (about every 15 seconds, on a network change, on sleep and on quit), in one transaction of upserts that add to existing rows. Synchronous, because quit calls it, and well under a millisecond. It's also flushed before every read, so the current hour is never missing. A failed batch is dropped, not retried, because a database that refuses one write will refuse the next; the current connection's counter is unaffected.

Reading happens on its own serial queue, so stepping through a year never stalls the menu bar. Measured on a generated 400-day database (5.5 MB): a year's per-app totals in 32 ms, hourly totals in 2 ms.

Retention (historyRetention in preferences) prunes whole days, at most once a day and straight away when the setting changes, then reclaims space with incremental_vacuum.

The chart is Swift Charts, stacked by hand so segments get a 2-point gap and only the top of a bar is rounded. The value axis uses round 1024-based steps chosen by the app (Swift Charts' own steps printed "953.7 MB"). The four colours were checked for colour-blind separation in light and dark mode; two of the light ones fall below 3:1 contrast against the window, which is why every figure is also given as text. Hover dims other bars by mixing them toward the background rather than lowering opacity, because the double-drawn top segment would show through.

Tests in UsageHistoryTests.swift cover the internet figure matching the popover, LAN-only traffic never counting, every session rule above, filters, retention, Clear History, the CSV adding up, DST days having 23 or 25 hourly bars, and the axis steps. They use a temporary database and a UTC calendar.

Known limits

This page is docs on GitHub, as of 365f4d4. To suggest a change, open an issue.