Sprout Analytics

Self-hosted analytics for React Native Expo apps running inside your own Convex deployment: session tracking, custom events, screen views, and error reporting w

Installation

npm install @sprout-convex/analytics

About Sprout Analytics

Sprout Analytics is a Convex component that adds session tracking, custom event tracking, screen tracking, user identification, and error capture to React Native Expo apps without any external ingestion service or third-party database. It ships an Expo SDK, a Convex component with batched HTTP ingest, sharded rollup counters, and fingerprinted error issues, plus a CLI that wires everything into an existing Convex and Expo project in one command. Your analytics data stays entirely within your own Convex deployment.

Benefits

Use cases

how to add analytics to a React Native Expo app with Convex

Sprout Analytics provides an Expo SDK and a Convex component that wires directly into an existing Convex and Expo project. Running bunx sprout init generates the component mount, HTTP ingest route, write key, and root layout hooks in one pass. The SDK exports track, screen, identify, and captureException, all backed by an offline-durable queue that retries with exactly-once delivery.

self-hosted error tracking for React Native without third-party services

Sprout Analytics captures uncaught JS errors and fatal exceptions automatically after initSprout runs, and exposes captureException for errors your code catches explicitly. Errors are fingerprinted into issues with open, resolved, and ignored workflow states, breadcrumbs, and stack traces, all stored inside your own Convex deployment with no data sent to external services.

session tracking and screen view analytics in Expo Router app

Sprout Analytics manages session boundaries automatically using AppState listeners, starting a new session after a configurable foreground gap (default 30 minutes). The useSproutScreenTracking hook placed in your expo-router root layout autocaptures navigation events as screen views, and the screen function is available for manual calls when a view does not correspond to a route change.

how to view analytics dashboard for a Convex Expo app locally

Sprout Analytics bundles a prebuilt dashboard UI into the published package. Running bunx sprout dashboard from your project root serves the dashboard on http://127.0.0.1:4321, reading your Convex URL from .env or .env.local and prompting for the app slug and dashboard key if they are not set as environment variables. No separate hosting or deployment is needed.

Frequently asked questions

Does Sprout Analytics send data to any external analytics service?

No. Sprout Analytics runs entirely inside your own Convex deployment. The Expo SDK batches and sends events to an HTTP ingest endpoint you register on your own Convex site URL, and all data is stored in your Convex database. No third-party ingestion service is involved.

What happens to events when the device is offline or the app is killed?

The Sprout Analytics SDK maintains an offline-durable event queue backed by AsyncStorage. Events that cannot be flushed immediately are persisted locally and retried with exactly-once delivery semantics. The queue survives app kills and is picked up again on the next initSprout call, with configurable batch size, queue size, and flush interval.

What are the peer dependencies required to use Sprout Analytics?

Sprout Analytics requires an existing Expo app with Convex already configured and npx convex dev working. It also requires expo-router for automatic screen autocapture, and expo-device, expo-constants, and @react-native-async-storage/async-storage, which are standard in a typical Expo project. Manual screen tracking with the screen function still works without expo-router.

How is the Convex component mounted and the ingest route registered?

The sprout init CLI command handles the wiring automatically: it mounts the Sprout component in convex/convex.config.ts using app.use, registers a POST /sprout/ingest route in convex/http.ts via Sprout.registerRoutes, generates a write key, and adds initSprout and useSproutScreenTracking to the Expo root layout. Any step it cannot automate is printed as a code snippet to apply manually.

Can the Sprout Analytics dashboard be shared with teammates or exposed publicly?

The Sprout dashboard is designed to run on localhost and is protected only by a shared dashboard key, not per-user authentication. The sprout dashboard command warns before binding to any address other than 127.0.0.1, and the README explicitly recommends keeping it on localhost. It is intended as a local developer tool, not a hosted shared service.

Links