Amba

Analytics

Events, sessions, and retention — track what users do, when they came back, and what kept them engaged.

Analytics is one of the seven canonical Amba categories. It covers three primitives:

  • Events — every Amba.events.track(name, properties) call is a queryable row in your project's event log. Used for segment evaluation, downstream webhooks, and ad-hoc product analysis.
  • Sessions — start/end timestamps with device metadata, recorded automatically by the SDK via app lifecycle hooks. The basis for active-user counts, session-duration histograms, and "lapsed" segment rules.
  • Retention — cohort-style queries derived from events and sessions. Built on top of the first two primitives; no separate retention table.

Analytics primitives feed every other category:

  • Engagement — rule-based segments evaluate against the event stream every 15 minutes.
  • Gamification — XP rules, achievement unlocks, and streak progress all derive from events.track calls.
  • Economy — currency grants and inventory updates emit events that show up in the same stream.

How to track an event

import { Amba } from '@layers/amba-web';
 
await Amba.auth.signInAnonymously();
await Amba.events.track('lesson_completed', {
  lesson_id: 'l_42',
  duration_seconds: 184,
  score: 0.91,
});

Events require an authenticated session (anonymous is fine). Properties are arbitrary JSON. See SDK · Events for the full per-platform reference, and the Admin API · Events for server-side listing and counting.

How sessions are recorded

The SDK calls /v1/client/sessions/start on app foreground and /v1/client/sessions/end on background (or beforeunload on web). You generally don't call these endpoints manually — they're driven by app lifecycle. See Platform · Sessions for the wire format and the manual-control APIs.

Querying analytics

The same surface is reachable through the MCP toolsamba_events_list, amba_events_count, amba_analytics_get, amba_sessions_list, amba_sessions_analytics — so your AI agent can pull the same numbers without leaving the editor.

See also

  • SDK · Events — per-platform events.track reference (Web, Node, React, React Native, Swift, Kotlin, Dart, C#).
  • Platform · Sessions — session-record wire format and manual control.
  • Segments — turn the event stream into rule-based audiences.
  • Webhooks — fan analytics events out to your other systems.

On this page