Skip to main content
Amplitude is the production analytics provider: a fully managed event pipeline with funnels, retention charts, and cohort analysis out of the box.

Why

Amplitude gives you a production-grade analytics pipeline without any infrastructure to manage. You instrument events on the backend, and Amplitude handles ingestion, storage, and visualisation. It’s the right choice when you need funnel analysis, retention metrics, or cohort-based product insights.

Setup

  1. In apps/backend/src/configuration/production.ts (and staging.ts if you have one), set tools.analytics:
    analytics: {
      client: AnalyticsClientType.AMPLITUDE,
      apiKey: process.env.AMPLITUDE_API_KEY,
    }
    
  2. In your production environment, set:
    AMPLITUDE_API_KEY=your_amplitude_api_key
    
  3. Keep development.ts and test.ts using the local client — Amplitude should never receive dev or test traffic.
  4. Run make test module=backend.

Tracking events

Call tools.analytics.track() with an event name, a properties object, and an optional identification object:
tools.analytics.track(
  'subscription_upgraded',
  {
    plan: subscription.plan,
    billingCycle: subscription.cycle,
    previousPlan: previousSubscription.plan,
  },
  { user_id: user.id },
);
Keep event names in snake_case. Keep property keys bounded and low-cardinality where used for filtering.

Gotchas

  • amplitude.init() is called once at startup inside buildAmplitudeAnalytics. Do not call it elsewhere.
  • The node SDK batches and flushes events asynchronously. A process crash before the flush window may drop the last few events — this is expected behaviour for fire-and-forget analytics.
  • Never send Amplitude traffic from development.ts or test.ts — it pollutes your production data and your event quota.

What’s next?

  • Local — the dev stub to use in development.ts and test.ts.
  • Configuration — switching pluggable tool implementations.