Saved Views & Copy as Code
Save dashboard states and promote UI changes to code
Saved Views
Saved views let you bookmark specific filter and date range combinations on any dashboard. Click the Views button in the dashboard header to manage saved views.
Saving a view
- Set your desired date range and filters on the dashboard
- Click Views in the header toolbar
- Click Save current view
- Enter a name (e.g., "Last week US traffic") and save
Applying a view
Open the Views dropdown and click any saved view to instantly apply its filters and date range to the current dashboard.
Deleting a view
Click the trash icon next to any view in the dropdown to remove it. Only the view creator can delete their views.
Copy as Code
The Copy as Code button generates a complete defineDashboard() TypeScript file from the current dashboard configuration. This bridges the gap between UI exploration and code-first definitions.
// Generated output example:
import { defineDashboard, widget, controls } from "@realanalytics/sdk"
export default defineDashboard({
id: "overview",
title: "Overview",
defaultDateRange: "last_30_days",
controls: [
controls.dateRange({ editable: true }),
controls.filter({ editable: true }),
],
widgets: [
widget.metric({
id: "signups",
label: "Signups",
event: "signup_completed",
aggregation: "count",
}),
widget.timeSeries({
id: "traffic",
title: "Traffic",
event: "$pageview",
metric: "count",
}),
],
})Workflow: UI to Code
- Explore and configure a dashboard in the UI
- Click Copy as Code to generate the TypeScript definition
- Save as
analytics/dashboards/your-dashboard.ts - Run
npx realanalytics deployto make it the source of truth
Code is always the source of truth
Copy as Code is designed for promoting UI exploration back into your codebase. Once a dashboard is defined in code, subsequent changes should be made in the TypeScript file and deployed via CLI.