Skip to content

fix(admin): source macOS activation from conversation records, not telemetry - #11642

Merged
Git-on-my-level merged 5 commits into
BasedHardware:mainfrom
Archit-lal:fix/macos-activation-telemetry
Aug 16, 2026
Merged

Git-on-my-level merged 5 commits into
BasedHardware:mainfrom
Archit-lal:fix/macos-activation-telemetry

Conversation

@Archit-lal

@Archit-lal Archit-lal commented Aug 15, 2026 •

Copy link
Copy Markdown
Collaborator

What

The macOS Activation KPI on admin.omi.me read 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 Created event. Builds before 98f1ee7c7f (2026-08-11) never emit it on the normal durable-session path, and stable 0.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:

  1. Cohort — the signup subquery filtered by timestamp before min(), so "first sign-in" meant first sign-in 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.
  3. Maturation — every signup was pooled, including 167 that had not yet had seven days to activate. The weekly chart already excluded these; the headline did not.

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}/conversations directly: 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_at is null on user documents written by the current signup path; signup_platform_at is the field that is actually populated. Cohorting on created_at returns 35 users instead of 10,375.
  • Filtering on 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 — the same shape as profitability and infra-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 — clean
  • npm test (web/admin) — 15 files, 101 tests passing, 10 new
  • npx eslint on every changed file — 0 errors
  • make preflight — 14/14 checks pass
  • New HogQL validated directly against PostHog project 302298
  • Ran the viral-metrics route locally (next dev, dev-auth bypass) against live PostHog: GET /api/omi/stats/viral-metrics?days=60 → 200
  • Loaded /dashboard/classic in a browser and confirmed the tiles render
  • The activation algorithm was validated end-to-end against production Firestore before being written in TypeScript: 1,456 matured macOS signups over 60 days, 532 activated, 0 read errors

New behavioural tests for computeActivation run 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, which lib/firebase/admin.ts requires. Its first real exercise will be the cron run.

Not addressed here

Both need a decision rather than a patch:

  • Stable is still on a build that cannot report activation via telemetry.
  • Cloud Run service backend has POSTHOG_HOST but no POSTHOG_PROJECT_API_KEY, so every backend-side product event is silently dropped — this is also why MCP Tool Call does not exist in PostHog.

Failure-Class: FC-unestablished-capability-default

Archit-lal and others added 3 commits August 15, 2026 15:47
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]>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 only app_version is present, causing eligible builds to be marked incapable and skewing viral metrics; read app_version with $app_version as 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) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Suggested change
splitByChar('.', coalesce(argMin(properties.$app_version, timestamp), '0'))
splitByChar('.', argMin(COALESCE(nullIf(properties.app_version, ''), nullIf(properties.$app_version, ''), '0'), timestamp))

Archit-lal and others added 2 commits August 15, 2026 15:57
…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]>
@Git-on-my-level

Copy link
Copy Markdown
Member

Verified this end-to-end in a worktree at d5e502f: npx tsc --noEmit clean and npx vitest run 103/103 passing (web/admin), matching the commit's stated evidence. The three query defects the PR description claims to fix are all visible in the diff, and each of the earlier bot findings checks out as resolved on this head. Per-file notes:

  • web/admin/app/api/omi/stats/activation/route.ts (new) — the core of the PR. The cohort paginates users on a signup_platform_at range with signup_os === "macos" filtered client-side (the missing-composite-index constraint is documented inline); signups inside the 7-day maturity window are excluded rather than scored as guaranteed zeros; per-user conversation count() runs 16-wide; and read failures stay null so unreadable users surface via erroredUsers instead of depressing the rate. The comment explaining why null must not collapse to false is exactly right. days is clamped to 1..180.
  • web/admin/lib/__tests__/activation-route.test.ts (new) — the fake applies the route's own where() predicates and rejects filters not on created_at, so the 7-day window is a real contract rather than a mirror of the seed data; the boundary test pins the window closed at both ends, and the pagination test drives past the 500-doc page.
  • web/admin/lib/growth-metrics.ts — summarizeActivation pools only matured days; capableRate/telemetryCoverage make "nobody could report" read as unmeasurable rather than zero; legacy series without capable counts default to fully-capable rather than zero-coverage. Sound.
  • web/admin/lib/__tests__/growth-metrics.test.ts — good new cases for the unmeasurable week, the maturity exclusion, and the day-the-window-closes boundary.
  • web/admin/app/api/omi/stats/viral-metrics/route.ts — the rewritten HogQL moves the window filter outside the min(timestamp) subquery (true first-ever sign-in instead of first-inside-window), keys activation off any memory inside the window instead of the user's earliest, and tags capability via $app_version at first sign-in vs 0.12.167. Each of the three old defects is now structurally hard to reintroduce.
  • web/admin/app/(protected)/dashboard/classic/page.tsx — the headline tile keys on activationStats.rate with n= and an amber unreadable-users note; the weekly chart prefers Firestore weeks and falls back to telemetry only before the payload loads (activationStats ? — payload presence, not weeks.length, which was the earlier empty-cohort bug); macosKpis now lists activationStats in its deps; the chart subtitles now say "Conversation created".
  • web/admin/app/api/internal/precompute/route.ts — warms activation:v1:macos:60 behind the existing run() helper; ACTIVATION_DAYS = 60 matches the dashboard request, so the request path should normally hit the cache.
  • .github/failure-classes/FC-unestablished-capability-default.json — canonical_prevention_artifact is a valid registry field (10 other FC files carry it) and points at real files in this PR.

Cross-checked the created_at-is-null claim against backend/database/users.py:184-189 — signup_platform_at is indeed the field the signup path populates. Declining the app_version fallback is reasonable given the 2,294/2,294 $app_version coverage cited in aa3bcae, and the telemetry series is only the pre-cache fallback now.

Two non-blocking notes: (1) a cold-cache GET can still trigger the full per-user fan-out on the request path (maxDuration = 3600) — fine while precompute warms it, just worth watching first-request latency; (2) the signups subquery now scans all-time macOS Sign In Completed events to get the true first sign-in — correct, just a heavier HogQL query behind the 30-minute cache.

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 need human response.

@Git-on-my-level Git-on-my-level added positive-signal Automation verified a genuine fix/quality contribution needs-maintainer-review Needs a human maintainer to sign off before merge web labels Aug 15, 2026
@Git-on-my-level
Git-on-my-level merged commit b062dec into BasedHardware:main Aug 16, 2026
32 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-maintainer-review Needs a human maintainer to sign off before merge positive-signal Automation verified a genuine fix/quality contribution web

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants