Skip to content
Sleep at nightTrust and privacy

Errors & analytics

Know what broke and what's used, without spying on anyone.

See what your users do and what breaks, from day one. Analytics stays completely silent until a user says yes to tracking. And when something fails, the user gets a short code your support team can actually look up.

  • 0

    tracking events before the user says yes

  • 1

    place where all error codes live

  • 2

    tools that vanish from the build if unset

The problem this solves

Without a shared foundation, every team rebuilds these edge cases — differently.

The consent check someone missed

Analytics that fires on page load, with a banner bolted on later, needs a guard at every call site. One missed guard is a compliance incident.

"It broke" with nothing to go on

A user reports a failure with no reference, or worse, pastes a raw stack trace. Support has nothing stable to match against a real captured event.

Tools that crash without their keys

SDKs that assume their keys exist crash local development, ship dead bundle weight, or quietly behave differently between environments.

How it works

The mechanism end to end, as implemented in the repository.

  1. 1

    Consent comes first

    Every tracking call checks the user's analytics cookie choice. On a yes, the tracker loads lazily, and a listener catches users who say yes later in the session.

  2. 2

    Errors get captured with context

    Error reporting filters out noise and tags each event with structured context like org, project, and job. In development, events log locally instead of being sent.

  3. 3

    Users get a stable reference

    Every failure maps through one registry to a support reference like APP-CAPACITY-001 and a safe public message. A released reference always means the same thing, forever.

  4. 4

    Missing keys cost nothing

    No analytics or error-reporting keys configured? Every helper becomes a no-op and the build drops the unused tools entirely.

Interactive example

See it working

This walkthrough demonstrates the implemented backend contract without using an account, credentials, or provider calls.

Interactive example

Explore the implemented decisions

Choose a sample state
Analytics suppressed

Deterministic sample data only. No account, provider, or network connection is used by the interaction.

Highlights

Why it matters

Tracking waits for a yes

Analytics is a silent no-op until the user accepts the analytics cookie, even if they say yes mid-session.

Errors carry context

Error reports are tagged with the org, project, job, and AI details, so you can triage without digging through raw data.

Failures come with a reference

Every API error maps to a short support code and a safe public message users can quote in a ticket.

Engineering guarantees

What this does and does not promise

Safety boundary

Error reporting is separate from analytics consent, and the kit doesn't pretend otherwise. The privacy and retention policy for error data, and what your context tags may contain, is still yours to set.

Implementation evidence

The boundary above is code, not a claim. These files carry the contract:

  • src/lib/analytics.ts
  • src/lib/sentry.ts
  • src/registries/error-codes.ts
  • docs/ERROR-CODES.md
Questions

Frequently asked questions

Build on the errors & analytics foundation

The docs describe the same contracts this page demonstrates.