DEV Community

Krish Verma
Krish Verma

Posted on

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

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"
}
Enter fullscreen mode Exit fullscreen mode

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);
Enter fullscreen mode Exit fullscreen mode

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

Top comments (2)

Collapse
 
userxnom profile image
Abdullah Naseer •

Krish, the part of this I keep coming back to is the failure mode, not the payload: if heartbeat.json can't be written, no ping goes out at all. Most telemetry fails loud or fails sticky — yours fails silent and safe, which is the right direction for a local-first app.

The 4 fields are about as small as a count can get — a SHA-256 of a random UUID plus version, platform and day. Where I would still push back on the 'required, not opt-in' call is the server side: PostgREST sees the request, so the IP is in the picture even if the row itself is anonymous. If request logs are kept, a daily ping from the same IP next to a stable hash becomes an identity trail in practice. Do you drop or rotate those logs, or is that a limit you are accepting alongside the fake-row one?

Collapse
 
krish_verma_77e28d3fd63ca profile image
Krish Verma •

You're right to push on this — the server side is the weaker half, and I don't want to overclaim it.

The row itself stores no IP: supabase/heartbeat.sql only has install_id_hash, app_version, platform, day and created_at, and the anon key can insert but can't read. But the ping is a plain PostgREST insert from sendHeartbeat() in desktop/electron/heartbeat.mjs (5-second timeout, fails silent), so Supabase sees the source IP on every request — that's unavoidable with a direct insert, and docs/heartbeat.md already says the receiving service may process connection details in its request logs.

The honest answer to your question is: I haven't configured any log dropping or rotation. There's nothing in the repo that does it — no log drain, no retention setting — so it's a limit I'm accepting alongside the fake-row one, not something I've engineered away. The exposure is narrow but real: the IP plus stable hash pairing exists only in Supabase's own platform logs, visible to me as project owner, not in the table and not on the owner dashboard, which only ever sees aggregates through the service-role function. If someone had those logs, a daily ping from the same IP next to the same hash would be linkable — the hash being stable across days is what makes the count work, and it's also what makes that pairing possible.

The one mitigation that would actually close it is putting a tiny proxy in front of the table so Supabase never sees the client IP directly — same fix shape as the fake-row problem. I haven't built that yet, and until I do, "the row is anonymous, the transport isn't fully" is the accurate claim.