Back to docs
Recipe

Event Tracking

Patterns for instrumenting user actions, feature adoption, and conversion funnels inside your Nimbus-protected application.

Core pattern

Wrap every meaningful user interaction in a lightweight event emitter that batches payloads locally and flushes on an interval or threshold. Never block the UI thread on telemetry.

track('license.activate', {
tier: 'pro',
duration_ms: 142
});

Batching strategy

Accumulate events in a ring buffer. Flush when the buffer reaches 50 events or 30 seconds elapse, whichever comes first. On flush failure, persist to a local SQLite fallback and retry with exponential backoff.

Privacy & compliance

Never log raw PII. Hash user identifiers with HMAC-SHA256 before they leave the client. Strip IP addresses at the ingestion edge. Honor Do Not Track headers and provide an opt-out toggle in settings.

Schema discipline

Every event name follows object.action convention. Payloads are flat key-value maps — no nested objects. This keeps your analytics warehouse queryable without JSON flattening gymnastics.

Next: read License Heartbeat for periodic validation patterns that pair with event tracking.