Features Apograph CMS on GitHub

Insights plugin

The dashboard, and the slot that stops it becoming the module that knows everything.

Documents 0.5.2 Updated Edit this page Report a problem

On this page

A workspace dashboard at /workspaces/:id/insights. It ships the frame and nothing else: the route, the range picker, the section bands, the widget card shell, a per-widget error boundary, and a small set of chart primitives.

Install

npm install @apograph/insights-admin

Register

// apps/admin/src/plugins.ts
import { InsightsPlugin } from '@apograph/insights-admin';

InsightsPlugin();

No server half, no configuration, no environment variables.

It goes first among the workspace-interior plugins

It registers the dashboard’s default sections, and section contributions merge by id with the last one winning — so a plugin that renames or reorders a band has to come after it.

Its widget slot is order-independent, so nothing else is affected by where it sits.

It contributes no widgets of its own

Every card on the page arrives through INSIGHTS_WIDGET_SLOT, from the plugin that owns the data behind it. This package imports no other feature package.

That is the whole point. A dashboard is the module most likely to slowly become the one that has to know about every other one, and the slot is what prevents it.

export const INSIGHTS_WIDGET_SLOT = createSlot<InsightsWidget>('insights.widget');
export const INSIGHTS_SECTION_SLOT = createSlot<InsightsSection>('insights.section');

An InsightsWidget carries an id, its section and order, an optional size, an optional permission that gates it, a title, and a zero-prop component that reads what it needs. See slots for the general mechanism.

A shareable range

New in 0.4.0: the selected date range is written to the URL, so a dashboard can be linked to. Sending somebody “insights for last quarter” used to mean sending them a screenshot or a sentence telling them which picker to change.

See insights and activity for what the page shows.