Documentation

Dashboards Overview

Define and deploy dashboards from TypeScript files

Dashboards live in analytics/dashboards/*.ts and are compiled byrealanalytics build into JSON for deployment.

Minimum dashboard config

import { defineDashboard, controls, widget } from '@realanalytics/sdk'

export default defineDashboard({
  id: 'overview',
  title: 'Overview',
  defaultDateRange: 'last_30_days',
  controls: [
    controls.dateRange({ editable: true }),
  ],
  widgets: [
    widget.metric({
      id: 'pageviews',
      label: 'Pageviews',
      event: '$pageview',
      aggregation: 'count',
    }),
  ],
})

DashboardConfig fields

FieldTypeDescription
idstringDashboard slug/identifier
titlestringDisplay title
defaultDateRangeDateRangePresetInitial date preset
controlsControlConfig[]Top-level UI controls
widgetsWidgetConfig[]Rendered cards/charts

Date range presets

'today' | 'yesterday' | 'last_7_days' | 'last_30_days' | 'last_90_days'
| 'this_month' | 'last_month' | 'this_quarter' | 'this_year'

Controls

controls: [
  controls.dateRange({ editable: true }),
  controls.compare({ editable: true, enabled: true }),
  controls.filter({ editable: true }),
]

Controls decide what viewers may change without a code change. enabled(default true) turns a capability on or off; editable decides whether viewers can change it.

ControlEnabled and editableNot editable or disabled
dateRangeDate range pickerFixed defaultDateRange label; saved views can't change it
filterExploration filter, saved-view filters and chart drilldownNone of these; only code-defined filters apply
compareComparisons on, with a Compare toggleNot editable: comparisons on, no toggle. Disabled: no comparison queries or overlays

A control you don't declare keeps its default: the date range and exploration filter are editable, and comparisons follow each widget's own settings (for example timeSeries.comparison or breakdown.showComparison) without a toggle. controls: [] therefore means "all defaults". Declare a control to lock or disable it.

Project structure

analytics/
├── events.ts
└── dashboards/
    ├── overview.ts
    ├── marketing.ts
    └── product.ts

Deploy changes

npx --no-install realanalytics build
npx --no-install realanalytics deploy

Next Steps