Nexus Analytics
A powerful, production-ready event tracking SDK for understanding user behavior. Track events in real-time, build powerful analytics, and make data-driven decisions with confidence.
What is Nexus?
Nexus is a modern analytics platform that helps you understand your users through real-time event tracking. Instead of relying on third-party analytics services, Nexus gives you full control over your data with a simple, developer-friendly SDK and powerful backend infrastructure.
Real-time Data
Events are tracked and available instantly on your dashboards. No delays, no batching tricks—pure real-time analytics.
Reliable at Scale
Designed to handle millions of events. Automatic batching, retries, and failsafe delivery ensure nothing is lost.
Privacy First
Your data stays yours. We don't sell data, and you have complete control over what gets tracked.
Developer Friendly
Simple, intuitive API that takes minutes to integrate. No complex configuration needed.
Quick Start (5 minutes)
Get Your API Key
Install the SDK
Install the production-ready SDK via npm or pnpm:
Initialize the SDK
import { Nexus } from 'nexus-avail';
// Initialize once at app startup
Nexus.init({
apiKey: 'pk_live_your_api_key', // Generate at https://nexus-anal.vercel.app/
projectId: 'your_project_id',
environment: 'production'
});Start Tracking Events
// Track user actions with type-safe schemas
Nexus.track('user_signup', {
email: 'user@example.com',
source: 'landing_page'
});
// Track product interactions
Nexus.track('product_viewed', {
productId: 'prod_123',
productName: 'Awesome Headphones',
category: 'Electronics'
});
// Track orders
Nexus.track('order_created', {
orderId: 'order_987',
userId: 'user_123',
amount: 99.99,
currency: 'USD',
items: [{ productId: 'prod_123', qty: 1 }]
});View Your Analytics
Go to your Nexus dashboard and watch your events stream in real-time. Explore trends, user behavior, and conversion funnels.
SDK Playground
Want to see the SDK in action without writing any code? Check out our interactive SDK Playground. It's a live demo where you can trigger events and see how they are tracked in real-time.
Cross-Platform Support
The Nexus SDK is designed to work seamlessly in any environment. It automatically detects where it's running and adjusts its behavior for maximum performance and reliability.
Browser Environment
Uses IndexedDB for robust offline persistence and SubtleCrypto for secure request signing. Perfect for React, Next.js, and Vue apps.
Node.js Environment
Uses the filesystem for event caching and the native crypto module. Ideal for server-side tracking in API routes or backend services.
Core Concepts
Type-Safe Events
Nexus uses TypeScript to ensure your event data is always correct. No more missing fields or typos in your analytics data.
Nexus.track('payment_failed', {
orderId: 'order_123',
error: 'Insufficient funds'
})Automatic Batching
Events are automatically batched and flushed every 30 seconds or when the batch size reaches 20 events — whichever comes first. This matches industry-standard defaults (Segment, Amplitude). You can override both via config.
// Events are queued and sent efficiently
Nexus.track('product_viewed', { productId: '1' });
Nexus.track('product_viewed', { productId: '2' });Offline Persistence
If the user goes offline, events are saved locally and automatically synced when the connection is restored.
SDK Methods Reference
Nexus.init(config)
Initializes the SDK. Must be called before tracking any events.
Nexus.init({
apiKey: 'your_key',
projectId: 'your_id',
environment: 'production', // 'development' | 'production'
batchSize: 20, // default: 20 events per batch
flushInterval: 30000, // default: 30 seconds
maxRetries: 3, // default: 3 retries on failure
onKilled: (reason) => { // called if SDK auto-disables due to repeated auth errors
console.error('SDK terminated:', reason);
}
});Nexus.track(eventType, data)
Records an event with type-safe data validation.
Nexus.track('user_login', {
email: 'john@example.com'
});Nexus.flush()
Immediately sends all queued events. Returns a promise that resolves when sending is complete.
await Nexus.flush();Nexus.getSessionId()
Returns the current unique session identifier.
const sessionId = Nexus.getSessionId();Nexus.destroy()
Flushes pending events and cleans up resources.
await Nexus.destroy();Nexus.identify(userId)
Associates all subsequent events with a specific user ID. Call this after login.
Nexus.identify('user_123');Nexus.pageView(data?)
Convenience method that automatically captures the current URL, path, title, and referrer.
// Auto-captures current page URL, title, referrer
Nexus.pageView();
// Or with overrides
Nexus.pageView({ title: 'Custom Title' });Nexus.trackError(error, context?)
Records an SDK error event. Useful for wiring up global error handlers.
// With an Error object
Nexus.trackError(new Error('Payment timeout'), 'checkout');
// Or with a string
Nexus.trackError('Something went wrong', 'api_call');Best Practices
Use Consistent Event Names
Stick to the predefined event types for maximum compatibility with Nexus dashboards.
Initialize Once
Call `Nexus.init()` once at the root of your application (e.g., in `App.tsx` or `layout.tsx`).
Include Contextual Data
Always include relevant properties with events. More context = better insights.
Don't Track Sensitive Data
Never track passwords, API keys, or payment information. Only track what you need for analysis.
Flush Before Unload
Call `Nexus.destroy()` in your cleanup logic to ensure all pending events are sent.
Use TypeScript
Take advantage of the SDK's full TypeScript support for autocompletion and error checking.
Platform Features
Event Analytics
View event trends, distributions, and patterns. Understand which actions drive your business.
User Cohorts
Segment users by behavior, traits, or time. Build cohorts for targeted analysis and campaigns.
Conversion Funnels
Track multi-step user journeys and identify where users drop off. Optimize conversion rates.
Retention Analysis
Measure user retention over time. Build cohort retention tables to track user engagement.
Real-time Dashboards
Live event streams and dashboards. See what's happening right now, not yesterday.
Custom Alerts
Get notified when something unusual happens. Set alerts for error rates, usage spikes, and more.
Multiple Projects
Manage analytics for multiple apps or environments. Each with its own API key and data.
Data Privacy
Your data is yours. No selling, no sharing. Complete control over what gets tracked.