Vishal Tyagi
← Projects
Product Analytics·production

Product Analytics Pipeline

Built a product analytics telemetry pipeline : a provider abstraction over Amplitude, typed event schemas, Hive-backed client buffering, and sliding-window deduplication.

Date2026-05
Reading TimeN/A
Statusproduction
StackFlutter, Dart, Amplitude+1

Flutter mobile and web

Surfaces

[High Confidence]

Hive-persisted buffer before batch flush

Offline path

[High Confidence]

Timeline

  • Telemetry audit

    Mapped scattered tracking calls lacking shared schema validation, environment isolation, and retry behavior.

  • ProductAnalytics facade

    Introduced AnalyticsProvider contract and typed user/account identity models.

  • Buffering and dedup rollout

    Shipped Hive-backed event buffering and sliding-window deduplication middleware.

What it does

Behavioral tracking used to live as ad-hoc Amplitude calls inside feature UI. That produced three failure modes: sandbox events in production dashboards, duplicate .identify() / event spikes on re-renders, and one HTTP request per high-frequency action on flaky mobile networks.

The fix is a single ProductAnalytics facade: feature code calls domain methods; the facade owns schema validation, environment routing, deduplication, and batching.

Constraints

  • Same behavior on Flutter mobile and web
  • Field use with intermittent connectivity
  • Tracking must not block the UI thread
  • Dev/sandbox events must never land in production Amplitude projects without duplicating the client codebase

Decisions & tradeoffs

  1. Vendor-agnostic facade — UI talks to ProductAnalytics / AnalyticsProvider, not Amplitude SDKs directly.
  2. Hive-backed accumulator — high-frequency CRM activity is persisted locally and flushed in batches during idle time.
  3. Sliding-window dedup — payload hashes drop duplicates inside a configurable window before the network.
  4. Typed traitsProductAnalyticsUserTraits (and account traits) attach at auth boundaries instead of raw maps at call sites.
flowchart LR
  A[Feature Event Trigger] --> B[ProductAnalytics Facade]
  B --> C[Sliding Deduplication Window]
  C -->|Unique Event| D[Hive Persistent Local Storage]
  C -->|Duplicate| E[Silent Drop]
  D --> F{Environment Check}
  F -->|Production| G[Batch Network Transmission]
  F -->|Sandbox/Dev| H[Mock Provider / Local Log]

Tradeoffs: batching delays dashboard freshness in exchange for lower network/battery cost. Typed traits add a little authoring friction and prevent silent schema drift.

What it demonstrates

  • Product-analytics infrastructure design (taxonomy, identity, environment isolation)
  • Offline-first client buffering and idempotent event emission
  • Separating vendor SDKs from feature code so destinations can change without rewriting screens

See also the architecture case study.