Skip to main content

Analytics

JavaScriptDartSwiftKotlinJavaPythonGoPHPRustC#C++

EdgeBase Analytics provides two capabilities in one SDK: automatic request log metrics for monitoring your API usage, and custom event tracking for understanding user behavior. Request logs are collected automatically — zero setup required. Custom events are tracked from your client or server code with a single function call. Query everything programmatically via the Admin SDK or visually in the Admin Dashboard.


Admin SDK Coverage

Analytics querying and event management are available across all Admin SDKs.

Architecture

EdgeBase Analytics has two data paths: request logs (automatic) and custom events (explicit).

Analytics Data Flow
┌──────────────┐                    ┌──────────────┐
│  Client App   │ ── track() ──→    │  EdgeBase     │ ──→ LogsDO (_events table)
│  (@edgebase/  │                    │  Server       │
│   web)        │                    │               │ ← query ── Admin SDK
└──────────────┘                    │               │ ← query ── Dashboard
                                   │  Every API    │
┌──────────────┐                    │  request is   │ ──→ LogsDO (_logs table)
│  Admin SDK    │ ── track() ──→    │  auto-logged  │     or Analytics Engine
│  (@edgebase/  │                    └──────────────┘
│   admin)      │

How it works:

  1. Request Logs (Automatic) — Every API request is logged with method, path, status, latency, and user info. No code required.
  2. Custom Events (Explicit) — Call analytics.track() from the Client or Admin SDK to record user actions with custom properties.
  3. Querying — Use the Admin SDK to query metrics programmatically, or view them in the Admin Dashboard.
  4. Storage — Custom events are stored in LogsDO (SQLite). Request logs use Analytics Engine on Cloud or LogsDO on Docker/self-hosted.

Key Features

📊

Request Log Metrics

Automatic API usage metrics: total requests, errors, latency, unique users — with time series, breakdowns, and top endpoints.

🎯

Custom Event Tracking

Track any user action with arbitrary key-value properties. Up to 50 properties per event, 100 events per batch.

Browser Optimized

Client SDK batches events (20 per batch or 5s timer) and uses sendBeacon on page unload to prevent data loss.

🔍

Flexible Querying

Filter by time range, event name, user ID. Get counts, time series, or top events. Cursor-based pagination for large datasets.

🔒

Auth-Aware

Events from authenticated users automatically include their user ID. Anonymous events are also supported, protected by rate limiting.

📈

Dashboard Integration

All metrics are available in the Admin Dashboard with interactive charts, filters, and real-time updates.

What You Don't Have to Build

Without EdgeBaseWith EdgeBase
Set up a request logging pipeline (ELK, Datadog, etc.)Automatic — every API call is logged with zero config
Build an event ingestion endpoint with validationclient.analytics.track('purchase', { plan: 'pro' })
Handle batching, retry, and page-unload data lossBuilt-in — 5s batch timer + sendBeacon fallback
Write SQL queries for time-series aggregationadmin.analytics.timeSeries({ range: '7d' })
Build a metrics dashboard from scratchAdmin Dashboard included — charts, filters, export
Manage event data retention and rollupAutomatic — 90-day raw events, daily rollups for historical

Quick Example

// Client SDK — track user actions in the browser
import { createClient } from '@edgebase/web';
const client = createClient('https://my-app.edgebase.dev');

client.analytics.track('page_view', { path: '/pricing' });
client.analytics.track('button_click', { id: 'signup-cta', variant: 'A' });
client.analytics.track('purchase', { plan: 'pro', amount: 29.99 });
// Admin SDK — query metrics from your backend
import { createAdminClient } from '@edgebase/admin';
const admin = createAdminClient('https://my-app.edgebase.dev', {
serviceKey: process.env.EDGEBASE_SERVICE_KEY,
});

const overview = await admin.analytics.overview({ range: '7d' });
console.log(overview.summary.totalRequests);

const events = await admin.analytics.queryEvents({ event: 'purchase', metric: 'count' });
console.log(events.totalEvents);

Next Steps