How I built a heartbeat that counts installs, not people: 1 ping a day, 4 fields, and no off switch

2026-11-28来源 dev.toEnglish

Ankita AI is a desktop AI assistant by Krish Verma — a little companion that lives on your desktop and gets things done while you're away. Until this week, I had no honest way to answer the simplest question about it: how many people actually open it each day? Downloads count files fetched, not installs running. So Ankita v2.7.6 ships a heartbeat: one ping per install per day, four fields, and — the part I expect you to argue with — no off switch.

The problem: downloads are not users

A download count counts installer files, not people — the same person downloads twice, a CI runner fetches the file, a version sits uninstalled. I wanted one number I could trust directionally: how many installs reported today. Not who, not what they asked, just how many.

Telemetry in a local-first desktop app is a trust decision, not a feature — so the heartbeat had to be small enough to defend in public: four fields, nothing that identifies a person, and a failure mode that never punishes the user.

What actually gets sent

One POST a day, to a Supabase table, with exactly this payload:

{ "install_id_hash": "9f2c… (64 hex chars)", "app_version": "2.7.6", "platform": "win32", "day": "2026-11-27" } 

The install ID is a random UUID generated once on the device. The server only ever sees its SHA-256 hash — the raw ID never leaves the machine. That hash is what lets the owner dashboard recognise the same install across days; it cannot be reversed into a person. No name, no email, no account, no prompts, no file paths, no chat content. Daily actives are just distinct hashes per day.

State lives in heartbeat.json in the user-data folder ({ installId, lastPingDay }, mode 0600), written atomically via temp-file-and-rename. If lastPingDay already equals today, nothing is sent; if the state file can't be written, no ping goes out at all — an uncountable ping is worse than no ping.

How it fires — and how it fails

desktop/electron/main.mjs fires it 6 seconds after launch, next to the update check, through a fire-and-forget wrapper:

setTimeout(() => { void maybeSendHeartbeat({ file: path.join(app.getPath('userData'), 'heartbeat.json'), version: app.getVersion(), platform: process.platform, }); }, 6000); 

The call is deliberately boring about failure. A 5-second timeout, and every failure path returns false: offline, endpoint down, or a read-only profile all mean "no ping today". The app works exactly as before — a failed heartbeat never blocks launch and never retries aggressively. If the app closed after the insert but before its state file updated, the server answers 409 on the duplicate (primary key (install_id_hash, day)), and the client treats that as counted.

Server-side there is no server code — a plain PostgREST insert, with row-level security letting the shipped publishable key insert and nothing else: no reads, no updates. The owner dashboard calls a private aggregate function with a server-only key; neither the service key nor raw install hashes ever reach a browser.

The decision I'm defending: required, not opt-in

The heartbeat started as an opt-in design — a usageHeartbeat toggle in Settings, off by default. I removed it: the old key now sits in RETIRED_SETTINGS_KEYS and is deleted from saved settings, and Settings → Privacy shows a "Required usage reporting" section with no toggle, listing exactly what is collected.

Why? An opt-in ping on a small open-source app returns close to zero data — the installs that opt in are the already-engaged ones, the opposite of a representative count. So I chose the smallest payload that answers the question and made it required, with the trade stated in the app itself rather than buried in a changelog.

I am not pretending that trade is free. Two honest limits ship with it. First, the count is directional, not audited: the anon key ships inside the app by design, RLS allows inserts from anyone, and a motivated attacker could invent install IDs to inflate the number — the (install_id_hash, day) key caps each fake ID at one row a day, but fake rows are indistinguishable from real ones. Second, this is not a count of people: one person can run several installs, reinstall, or use the terminal without appearing at all. The docs say so plainly — "a zero count means no install has reported yet, not that nobody uses the app."

Also in v2.7.6

The release carries three smaller changes behind the heartbeat: the shell now starts in the selected workspace (falling back to the app workspace when no project is set); personality and task skills persist across restarts, with context limits handled before a request is sent; and computer-use screenshot checks now apply native ChatGPT limits per tool result, so later verification screenshots stay visible. Details are in the release notes, and the heartbeat design is documented in full at docs/heartbeat.md.

Ankita is open source (MIT) — the whole mechanism is ~100 lines in desktop/electron/heartbeat.mjs, and you can read every line of it. The project is at github.com/akyourowngames/A.N.K.I.T.A, and the site is ankita-sable.vercel.app.

Tell me I'm wrong: is a required 4-field ping the right price for knowing whether anyone actually uses your app — or is any telemetry without a toggle a line an open-source desktop app shouldn't cross, even when the payload is this small? Where exactly would you draw it — an opt-in that returns almost nothing, a required ping with a disclosed payload, or no counting at all?

— Krish Verma, creator of Ankita AI

原文:https://www.a8q9.cn/en/article/how-i-built-a-heartbeat-that-counts-installs-not-people-1-ping-a-day-4-fields-an-e729b3.html

相关文章