Repository navigation
fix(admin): source macOS activation from conversation records, not telemetry - #11642
Git-on-my-level merged 5 commits into
Conversation
The Activation KPI read 0.2% (4 of 1,812 macOS signups over 60d). Three independent defects, each of which only ever pushed the number down: 1. Cohort. The signup subquery filtered by timestamp *before* min(), so the "first" sign-in was the first one inside the window. 237 of 1,810 were returning users re-authenticating, counted as new signups. 2. Numerator. The join keyed off min(timestamp) of Memory Created, so a user whose first-ever memory predated their window was marked unactivated even when they created one inside it. Now tests for any memory in the window. 3. Maturation. Every signup was pooled, including 167 that had not yet had seven days to activate -- a guaranteed-zero numerator against a real denominator. The weekly chart already excluded these; the headline did not. The dominant term was none of those. Desktop only began emitting Memory Created on the normal durable-session path in 98f1ee7 (2026-08-11); before it, the event fired only for recordings that failed to bind a local session. Stable 0.12.144 is 66% of the fleet and emitted 0 events across 454 recording users in three days, so the metric was measuring build age, not activation. That is a rollout capability the surface never modelled, so its default was rendered as an authoritative rate. Activation now carries the capability explicitly: the headline is the rate among signups whose build can report, null when none could, with telemetry coverage shown alongside. An unmeasurable metric reads as unmeasurable instead of as a confident near-zero. Verification: - npx tsc --noEmit: clean - npm test (web/admin): 14 files, 94 tests passing, 6 new - npx eslint on all three changed files: 0 errors - New HogQL validated directly against PostHog project 302298 before landing - Ran the route locally (next dev, dev-auth bypass) against live PostHog: GET /api/omi/stats/viral-metrics?days=60 -> 200, {activationRate: null, activationTelemetryCoverage: 0, activationSignups: 0, activationPooledRate: 0.1} - Loaded /dashboard/classic in a browser and confirmed both tiles render: "Activation -- - Memory within 7d - not yet measurable" with "0% of signups on a build that reports it", and "Weekly Activated Users - Memory in 7d - no reporting build in this cohort" Not addressed here, and both need a decision rather than a patch: stable is still on a build that cannot report, and Cloud Run service `backend` has POSTHOG_HOST but no POSTHOG_PROJECT_API_KEY, so every backend-side product event is dropped. Failure-Class: FC-unestablished-capability-default Co-Authored-By: Claude Opus 5 <[email protected]>
…d surface Third declaration of this class in the 90-day window with no reusable guard, which the guard-artifact ratchet rejects: a recurring class must produce a shared surface, not more paperwork. `summarizeActivation` and `maturedWeeklyActivation` are that surface for the metrics side of the class. They model "this cohort could not report" as its own value -- a null rate distinct from a measured zero -- and carry coverage next to it, so a serving surface cannot render an unestablished capability as an authoritative number. The behavioral tests pin exactly that distinction. Verification: OMI_PR_BODY_FILE=<draft> make preflight -> all selected checks pass, including failure-class-protocol and failure-class-guard-artifact-ratchet. Co-Authored-By: Claude Opus 5 <[email protected]>
…lemetry The desktop `Memory Created` event cannot answer this question today: builds before 98f1ee7 never emit it, and stable 0.12.144 -- ~66% of the fleet -- produced 0 events across 454 recording users in three days. Any metric keyed on that event reports build age. A conversation document exists whether or not the client managed to report it, so activation now reads `users/{uid}/conversations` directly: a macOS signup is activated if a conversation was created inside its first 7 days. Measured against production Firestore before writing this route: 1,456 matured macOS signups over 60 days, 532 activated, **36.5%** -- rising from 20.2% (week of Jun 29) to 57.1% (week of Aug 3). The dashboard was reporting 0.2%. Two things the cohort query has to get right, both covered by tests: - `created_at` is null on user docs written by the current signup path; `signup_platform_at` is the populated field. Cohorting on `created_at` returns 35 users instead of 10,375. - `signup_os` alongside a `signup_platform_at` range needs a composite index that does not exist on this project, so the range is the query and the platform is filtered in memory. Fanning out one aggregation query per signup is too slow for a request, so it runs in the existing cron precompute endpoint (maxDuration 3600) and the GET is a payload-cache read, matching profitability and infra-costs. Verification: - npx tsc --noEmit: clean - npm test (web/admin): 15 files, 101 tests passing, 5 new behavioural tests for computeActivation against a faked Firestore covering the 7-day boundary, the macOS filter, maturity exclusion, 500-doc pagination, and per-user read failures being reported rather than scored as unactivated - eslint on both new files: 0 errors - The algorithm was validated end-to-end against production Firestore (1,456 users, 0 read errors) before it was written in TypeScript NOT verified: the TypeScript route has not been executed against Firestore -- this machine has no FIREBASE_CLIENT_EMAIL/FIREBASE_PRIVATE_KEY, which lib/firebase/admin.ts requires. First real exercise will be the cron run. Failure-Class: FC-unestablished-capability-default Co-Authored-By: Claude Opus 5 <[email protected]>
There was a problem hiding this comment.
2 issues found across 8 files
Confidence score: 3/5
- In
web/admin/lib/growth-metrics.ts, failed conversation reads are currently counted as valid non-activations, which can systematically depress the activation KPI and mask real trend changes; keep an explicit unknown/error bucket and remove those users from the denominator, then report that bucket separately. - In
web/admin/app/api/omi/stats/viral-metrics/route.ts, capability detection for macOS sign-ins can be wrong when onlyapp_versionis present, causing eligible builds to be marked incapable and skewing viral metrics; readapp_versionwith$app_versionas fallback before version comparison.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="web/admin/lib/growth-metrics.ts">
<violation number="1" location="web/admin/lib/growth-metrics.ts:198">
P1: When a conversation read fails, this branch treats the user as a valid non-activation and dilutes the KPI. Preserve an unknown/error state and exclude those users from the rate denominator, while reporting them separately through `erroredUsers`.</violation>
</file>
<file name="web/admin/app/api/omi/stats/viral-metrics/route.ts">
<violation number="1" location="web/admin/app/api/omi/stats/viral-metrics/route.ts:180">
P1: When a macOS sign-in event has the registered `app_version` property but no `$app_version`, this expression classifies its build as incapable. Read `app_version` with `$app_version` as a fallback before comparing the version.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| const current = totals.get(week) ?? { signups: 0, activated: 0 }; | ||
| current.signups += 1; | ||
| signups += 1; | ||
| if (member.activated) { |
There was a problem hiding this comment.
P1: When a conversation read fails, this branch treats the user as a valid non-activation and dilutes the KPI. Preserve an unknown/error state and exclude those users from the rate denominator, while reporting them separately through erroredUsers.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At web/admin/lib/growth-metrics.ts, line 198:
<comment>When a conversation read fails, this branch treats the user as a valid non-activation and dilutes the KPI. Preserve an unknown/error state and exclude those users from the rate denominator, while reporting them separately through `erroredUsers`.</comment>
<file context>
@@ -97,10 +147,121 @@ export function maturedWeeklyActivation(
+ const current = totals.get(week) ?? { signups: 0, activated: 0 };
+ current.signups += 1;
+ signups += 1;
+ if (member.activated) {
+ current.activated += 1;
+ activated += 1;
</file context>
| min(timestamp) as s_ts, | ||
| arrayMap( | ||
| part -> toIntOrZero(part), | ||
| splitByChar('.', coalesce(argMin(properties.$app_version, timestamp), '0')) |
There was a problem hiding this comment.
P1: When a macOS sign-in event has the registered app_version property but no $app_version, this expression classifies its build as incapable. Read app_version with $app_version as a fallback before comparing the version.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At web/admin/app/api/omi/stats/viral-metrics/route.ts, line 180:
<comment>When a macOS sign-in event has the registered `app_version` property but no `$app_version`, this expression classifies its build as incapable. Read `app_version` with `$app_version` as a fallback before comparing the version.</comment>
<file context>
@@ -128,40 +139,60 @@ export async function GET(request: NextRequest) {
+ min(timestamp) as s_ts,
+ arrayMap(
+ part -> toIntOrZero(part),
+ splitByChar('.', coalesce(argMin(properties.$app_version, timestamp), '0'))
+ ) >= [${MIN_ACTIVATION_TELEMETRY_VERSION.join(", ")}] as reports_activation
FROM events
</file context>
| splitByChar('.', coalesce(argMin(properties.$app_version, timestamp), '0')) | |
| splitByChar('.', argMin(COALESCE(nullIf(properties.app_version, ''), nullIf(properties.$app_version, ''), '0'), timestamp)) |
…them zero Review found the metric reproducing, one layer down, the exact mistake it exists to undo. A failed conversation read left the user in the cohort with `activated: false`, so an unreadable user was indistinguishable from one who did not activate -- while the code comment claimed the opposite. Read failures are now `null`, excluded from the denominator, and surfaced via `erroredUsers`: a partial read shrinks the sample rather than depressing the rate. Three more from the same review: - The weekly widgets keyed their fallback on `activationStats?.weeks?.length`, so a legitimately empty Firestore cohort silently fell back to the telemetry series. Test for the payload, not for a non-empty array. - `macosKpis` omitted `activationStats` from its dependency list, so the tile stayed `--` whenever activation resolved after `vm` and `profitability`. - A non-numeric `days` reached Firestore as NaN date arithmetic and 500'd; it is now clamped to 1..180 with a 60 default. Not taken: adding an `app_version` fallback beside `$app_version`. Of 2,294 macOS `Sign In Completed` events in 60 days, 2,294 carry `$app_version` and 0 carry only the unprefixed property, so the fallback would be speculative. Verification: - npx tsc --noEmit: clean - npm test (web/admin): 15 files, 102 tests passing, 1 new covering a partly unreadable week, 1 tightened to assert the denominator not just the count - npx eslint on all three changed files: 0 errors - npm run build with the CI env: compiled, /api/omi/stats/activation registered Failure-Class: FC-unestablished-capability-default Co-Authored-By: Claude Opus 5 <[email protected]>
…ale label Review caught that the Firestore fake discarded the bounds the route passes to `where()` and re-derived the 7-day window from its own seed data. The tests therefore agreed with the fake rather than checking the route: a wrong field, a shifted bound, or an off-by-one in the production query would still have passed. The fake now applies the route's own predicates and rejects any filter that is not on `created_at`, so the query shape decides the count. Proven by mutation, not by assertion alone: - widen the upper bound to MATURITY_DAYS + 1 -> the boundary test fails - filter `started_at` instead of `created_at` -> all 7 tests fail - restored -> all 7 pass Adds a boundary case pinning the window closed at both ends: a conversation at exactly signup and at exactly signup+7d activates; 86s either side does not. Also relabels the weekly chart from "Memory created within 7 days of signup" to "Conversation created", which is what the series now measures -- the old subtitle described the telemetry event this PR moved off. Verification: - npx tsc --noEmit: clean - npm test (web/admin): 15 files, 103 tests passing - npx eslint on all three changed files: 0 errors - npm run build with the CI env: compiled successfully Failure-Class: FC-unestablished-capability-default Co-Authored-By: Claude Opus 5 <[email protected]>
|
Verified this end-to-end in a worktree at d5e502f:
Cross-checked the Two non-blocking notes: (1) a cold-cache GET can still trigger the full per-user fan-out on the request path ( This redefines a headline admin KPI (the dashboard will show ~36.5% where it showed 0.2%), so leaving formal merge sign-off to a human maintainer who can confirm the new methodology is the number they want on the dashboard. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
What
The macOS Activation KPI on
admin.omi.meread 0.2%. The real figure, measured from production conversation records, is 36.5% — and rising from 20.2% (week of Jun 29) to 57.1% (week of Aug 3).Why it was wrong
The metric counted the desktop
Memory Createdevent. Builds before98f1ee7c7f(2026-08-11) never emit it on the normal durable-session path, and stable0.12.144— ~66% of the macOS fleet — produced 0 events across 454 recording users in three days. The metric was reporting build age, not behaviour.Three independent query defects compounded it, each only ever pushing the number down:
timestampbeforemin(), so "first sign-in" meant first sign-in inside the window. 237 of 1,810 were returning users re-authenticating, counted as new signups.min(timestamp)ofMemory Created, so a user whose first-ever memory predated their window was marked unactivated even when they created one inside it.What changed
No amount of query-fixing gets a real number out of a source two thirds of the fleet cannot write to, so activation moves off telemetry. A conversation document exists whether or not the client managed to report it, so the new route reads
users/{uid}/conversationsdirectly: a macOS signup is activated if a conversation was created inside its first 7 days.Two traps in the cohort query, both covered by tests:
created_atis null on user documents written by the current signup path;signup_platform_atis the field that is actually populated. Cohorting oncreated_atreturns 35 users instead of 10,375.signup_osalongside asignup_platform_atrange needs a composite index that does not exist on this project, so the range is the query and the platform is filtered in memory.Fanning out one aggregation query per signup is too slow for a request, so it runs in the existing cron precompute endpoint (
maxDuration3600) and the GET is a payload-cache read — the same shape asprofitabilityandinfra-costs.The PostHog-derived series is kept as a fallback for the window before the activation route has a cached payload, with its three defects fixed and its telemetry coverage now explicit, so it reports "not measurable" rather than a confident near-zero.
Verification
npx tsc --noEmit— cleannpm test(web/admin) — 15 files, 101 tests passing, 10 newnpx eslinton every changed file — 0 errorsmake preflight— 14/14 checks passnext dev, dev-auth bypass) against live PostHog:GET /api/omi/stats/viral-metrics?days=60→ 200/dashboard/classicin a browser and confirmed the tiles renderNew behavioural tests for
computeActivationrun against a faked Firestore and cover the 7-day boundary, the macOS filter, maturity exclusion, 500-doc pagination, and per-user read failures being reported rather than silently scored as unactivated.Not verified
The TypeScript route has not been executed against Firestore — this machine has no
FIREBASE_CLIENT_EMAIL/FIREBASE_PRIVATE_KEY, whichlib/firebase/admin.tsrequires. Its first real exercise will be the cron run.Not addressed here
Both need a decision rather than a patch:
backendhasPOSTHOG_HOSTbut noPOSTHOG_PROJECT_API_KEY, so every backend-side product event is silently dropped — this is also whyMCP Tool Calldoes not exist in PostHog.Failure-Class: FC-unestablished-capability-default