Skip to content

an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions

fix(telemetry): via stops crediting a restart that returned without installing

Chaitanya Giriea0ada9fe965
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 338de87b..5e2b27a1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -44,7 +44,8 @@ clickable paths in terminal output, one editor instead of two, and 23 community
A `via` property says whether the app's own updater installed it (`auto`), something else moved
the version (`manual`), or there was no update log to read (`unknown`) — read from the update
log the app already keeps, so it works for installs updating from a version released before
- this one.
+ this one. A restart the user asked for that then quietly installed nothing counts as `manual`,
+ not `auto`, because the log names which build started next.
### Fixed
diff --git a/TELEMETRY.md b/TELEMETRY.md
index d2beb9ae..51f46020 100644
--- a/TELEMETRY.md
+++ b/TELEMETRY.md
@@ -50,8 +50,10 @@ identifiers, or API keys. Nothing free-form — the property allowlist in
the app's data in the same way.
- To set `via`, the app reads its own update log (`updater.log`, kept in the
same user-data directory) to see whether the version it is now running is the
- one its updater downloaded and you asked it to restart into. Only that
- one-word result leaves the machine — no line, path or message from that log
+ one its updater downloaded and you asked it to restart into, and whether that
+ restart is what actually installed it: the log names each version as it
+ starts, so a build other than this one starting afterwards means something
+ else did the installing. Only that one-word result leaves the machine — no line, path or message from that log
is ever sent.
- IP-based geolocation is used only to derive a country for aggregate stats;
PostHog does not retain the IP on the event.
diff --git a/src/main/analytics.ts b/src/main/analytics.ts
index cfd3f2b3..18431b9e 100644
--- a/src/main/analytics.ts
+++ b/src/main/analytics.ts
@@ -315,7 +315,14 @@ export function writeVersionStamp(stateDir: string, version: string): void {
*
* Matching on the version is what makes it trustworthy: a leftover pair from a
* PREVIOUS upgrade names that older version, so it cannot be mistaken for this
- * one. The log is read only to derive the closed enum below — no line, path or
+ * one. The pair is necessary but not sufficient, because `quitAndInstall()`
+ * can return without installing anything — so a launch that names a different
+ * version after the request, or a refused quit warning, takes it back to
+ * `manual`. That correction matters more from 0.4.5 on than it did before it:
+ * the title-bar badge is now the MANUAL download, so the user whose automatic
+ * install quietly did nothing is exactly the user who then reaches for manual,
+ * and crediting that install to `auto` would flatter the path that failed.
+ * The log is read only to derive the closed enum below — no line, path or
* message from it is ever sent, and updater.ts is not modified to support this
* (`test/update-applied.test.cjs` asserts the two literals still match, so a
* future reword fails the suite instead of silently degrading the metric).
@@ -324,6 +331,11 @@ const LOG_FILE = 'updater.log';
const LOG_DOWNLOADED = 'update downloaded: ';
const LOG_QUIT_REQUESTED = 'quitAndInstall requested by the user';
const LOG_QUIT_FAILED = 'quitAndInstall failed:';
+/** Written once per packaged launch, naming the version that launched — in
+ * v0.4.3 and v0.4.4 as shipped, so it is readable for the 0.4.5 hop. */
+const LOG_READY = /native updater ready \(current v([^)\s]+)\)/;
+/** Only in 0.4.5 and later, so it starts paying off for the 0.4.6 hop. */
+const LOG_QUIT_CANCELLED = 'quitAndInstall cancelled by the user at the quit warning';
/** The log grows by a line or two per update, never on a routine check, so this
* is years of history — but it is a user-writable file, so the read is bounded
* rather than trusting. */
@@ -360,6 +372,25 @@ export function updateVia(logText: string | null, toVersion: string): UpdateVia
// an attempt that threw is the very next line — the app never quit, and
// whatever moved the version afterwards was not us.
if (lines[j + 1]?.includes(LOG_QUIT_FAILED)) return 'manual';
+
+ // A request that threw is the easy case. The one that matters is the request
+ // that returned cleanly and still did not install: `quitAndInstall()` reports
+ // no outcome (updater.ts says so in its own header), so a silent no-op and a
+ // successful install are the same line. The log tells them apart anyway,
+ // because the app that runs NEXT identifies itself:
+ //
+ // - a launch naming any version other than the one we landed on means a
+ // build that is not the target ran after the restart was asked for, so
+ // that restart did not install this version;
+ // - the user refusing the quit warning says the same thing outright.
+ //
+ // Both are disproof only. Their absence is not evidence of success, so this
+ // still cannot see an install that failed with nothing running afterwards.
+ for (let n = j + 1; n < lines.length; n++) {
+ if (lines[n].includes(LOG_QUIT_CANCELLED)) return 'manual';
+ const launched = LOG_READY.exec(lines[n]);
+ if (launched && launched[1] !== toVersion) return 'manual';
+ }
return 'auto';
}
diff --git a/test/update-applied.test.cjs b/test/update-applied.test.cjs
index 719694c2..d14322a4 100644
--- a/test/update-applied.test.cjs
+++ b/test/update-applied.test.cjs
@@ -257,6 +257,7 @@ const L = {
downloaded: (v) => `[2026-08-21T10:00:00.000Z] update downloaded: ${v} — waiting for the user to restart`,
requested: '[2026-08-21T10:05:00.000Z] quitAndInstall requested by the user',
failed: '[2026-08-21T10:05:00.001Z] quitAndInstall failed: ENOENT',
+ cancelled: '[2026-08-21T10:05:30.000Z] quitAndInstall cancelled by the user at the quit warning',
downloadErr: '[2026-08-21T09:00:00.000Z] download failed: socket hang up'
};
const log = (...lines) => lines.join('\n') + '\n';
@@ -293,6 +294,58 @@ test('via: a failed attempt followed by a successful one is auto', () => {
);
});
+test('via: a restart that returned cleanly and still did not install is manual', () => {
+ // The failure mode the log is FOR: quitAndInstall() reports no outcome, so a
+ // silent no-op looked exactly like success. The old build launching again
+ // after the request is what gives it away — and this user is precisely the
+ // one who then uses the manual badge, so calling it auto would credit the
+ // path that failed.
+ assert.equal(
+ updateVia(log(L.downloaded('0.4.5'), L.requested, L.ready('0.4.4')), '0.4.5'),
+ 'manual'
+ );
+});
+
+test('via: from_version is never needed for that — any version but ours is disproof', () => {
+ // Load-bearing, because the version stamp ships WITH this event: every 0.4.5
+ // upgrade reports from_version 'unknown', so a from-version-specific check
+ // would do nothing for the one release this is being shipped to measure.
+ assert.equal(
+ updateVia(log(L.downloaded('0.4.5'), L.requested, L.ready('0.3.9')), '0.4.5'),
+ 'manual'
+ );
+});
+
+test('via: the target launching after the request is still auto', () => {
+ // The new build identifying itself is what success looks like, and updater.ts
+ // may well write it before analytics reads the tail in the same process.
+ assert.equal(
+ updateVia(log(L.downloaded('0.4.5'), L.requested, L.ready('0.4.5')), '0.4.5'),
+ 'auto'
+ );
+});
+
+test('via: a launch BEFORE the request says nothing about it', () => {
+ assert.equal(
+ updateVia(log(L.ready('0.4.4'), L.downloaded('0.4.5'), L.requested), '0.4.5'),
+ 'auto'
+ );
+});
+
+test('via: refusing the quit warning is manual', () => {
+ assert.equal(
+ updateVia(log(L.downloaded('0.4.5'), L.requested, L.cancelled), '0.4.5'),
+ 'manual'
+ );
+});
+
+test('via: a refused quit followed by one that stuck is auto', () => {
+ assert.equal(
+ updateVia(log(L.downloaded('0.4.5'), L.requested, L.cancelled, L.requested), '0.4.5'),
+ 'auto'
+ );
+});
+
test('via: the request must come AFTER the download, not before', () => {
assert.equal(updateVia(log(L.requested, L.downloaded('0.4.5')), '0.4.5'), 'manual');
});
@@ -350,6 +403,14 @@ test('updater.ts still emits the exact lines via reads', () => {
src.includes('logLine(`quitAndInstall failed:'),
'updater.ts no longer logs the failed attempt — update analytics.ts LOG_QUIT_FAILED'
);
+ assert.ok(
+ src.includes('logLine(`native updater ready (current v${app.getVersion()})`)'),
+ 'updater.ts no longer names the launching version — update analytics.ts LOG_READY'
+ );
+ assert.ok(
+ src.includes("logLine('quitAndInstall cancelled by the user at the quit warning')"),
+ 'updater.ts no longer logs the refused quit — update analytics.ts LOG_QUIT_CANCELLED'
+ );
});
// ── via, end to end ─────────────────────────────────────────────────────────