Skip to content
Keshav Raj
One neat outbox sending typed envelopes down a pipe while a pile of error sparks drains away.
ARCHITECT HILLS−200K/DAY
SHIPPED Every app event through one typed producer and one durable outbox, wire format kept byte-for-byte.I OWNED Designer + primary authorOUTCOME ~200k/day auth failures eliminated
  1. AUDIT PRODUCERS
  2. TYPED EMITS
  3. DURABLE OUTBOX
  4. BYTE PARITY

ProductEventHub

Keshav RajDesigner + primary author · 2026 · ShippedContact meResume PDF
+122/hsign-up events recovered
1emit path for web + mobile

Context

ProductEventHub is the analytics path I redesigned in 2026 for the learner platform's web app, widgets and React Native app. I designed it and wrote most of it.

The problem

Analytics events went through redux-style middleware that watched app actions. The events were untyped, and some were lost or duplicated. Mobile batches carried no auth token, so they failed with about 200k auth errors a day.

The downstream data store partitions by the legacy event format, so any change to the wire format would shift data.

What I did

  1. I audited every event producer first and wrote a migration plan.

  2. I replaced middleware interception with explicit, typed emits for 8 event families. Payment and enrollment events get critical priority.

  3. I built one durable outbox, backed by MMKV on mobile and IndexedDB on web, with retry and isolation for poison events.

  4. I made token refresh single-flight with one retry, and fixed the token source on mobile.

  5. I deleted the old analytics service and middleware once every producer had moved.

Key decision

I kept the legacy wire format byte-for-byte, including its known bugs. That way no downstream partition shifted during the migration.

The cost is deliberate technical debt carried forward. I judged that safer than a format change mixed into an architecture change, and I can fix the format separately later.

Result

About 200k auth failures a day are gone. Cleaning up the wire path recovered 122 sign-up and login events an hour. Web and mobile now share 1 emit path.

Another fix: the events host is resolved at call time, so dev and preview builds stopped sending to production.

What I learned

I would again audit before migrating and pin the output format with tests. I would also have added monitoring on batch failures from day one, since the tokenless bug ran for the whole earlier period unseen.

Stack

  • TypeScript
  • React Native
  • MMKV
  • IndexedDB
  • JWT refresh
  • Vitest
Play the world →