Overview

Count, group, and aggregate events with one shared query model.

Analytics answers questions about your events: how many happened, how they changed over time, what their values were, and where they came from. Every query returns aggregated results rather than individual events.

The shared query model

Vanta has one canonical query model. The same filters, time ranges, and field names work in the API, the SDK, the dashboard, and these analytics methods. You build the same conceptual query everywhere, so a filter you write in code behaves identically in the dashboard.

The Node.js SDK exports helpers for building queries:

typescript
import { filter, and, or, timeRange } from '@vanta-dev/node'

Analytics operations

  • Counts: the number of matching events in a range.
  • Timeseries: counts or values bucketed over time.
  • Aggregations: sum, avg, min, max, and percentiles over a range.
  • Grouping: results split by one or more fields.
  • Unique: counts of distinct values for a field.

Each operation is covered in its own page, followed by practical recipes.

A first query

typescript
const count = await vanta.count({
  filters: filter('type', 'equals', 'checkout.completed'),
  time: timeRange('2024-01-01T00:00:00Z', '2024-12-31T23:59:59Z'),
})

This returns the number of completed checkouts in 2024. Note the time range: analytics always queries a specific period.

Time is required

Every analytics query needs a time range. Provide it as ISO 8601 datetimes with a UTC timezone, for example 2024-01-01T00:00:00.000Z. See Time Ranges for the full details.