Skip to content

feat: dashboards v2 (insight/text tiles, filters, templates) and public share links - #12

Merged
ayushozha merged 2 commits into
mainfrom
ayush/dashboards-v2
Nov 17, 2026
Merged

ayushozha merged 2 commits into
mainfrom
ayush/dashboards-v2

Conversation

@ayushozha

@ayushozha ayushozha commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

What and Why

Pulse's dashboards were a JSON blob that nothing rendered, and share links were minted but no route ever read them. This adds PostHog-style dashboards built from saved-insight and text tiles, with dashboard-wide filters, per-tile caching, templates, duplicate and move. It also adds the missing public share-link endpoint for dashboards, insights and legacy links.

Stacked on #11 (base ayush/saved-insights); retarget to main once the stack below merges.

Reference followed: PostHog's Dashboard and DashboardTile models and API (posthog/models/dashboard*.py, posthog/api/dashboards/):

  • tiles referencing insights or text, layouts, dashboard filters overriding insight date range and properties
  • pinned, the project "primary dashboard", duplicate with or without copying insights, and dashboard templates
  • PostHog SharingConfiguration for public tokens

Changes

  • Migration 032: the dashboards and dashboard_tiles tables. A partial unique index allows one home dashboard per project, and a CHECK makes each tile either an insight or text. It also adds dashboard_id and insight_id columns to shared_dashboards.
  • /api/v2/dashboards:
    • CRUD, and list with search, tags and pinned filters
    • /run (refresh), /duplicate (duplicate_insights) and /layouts (bulk PUT)
    • tiles: add, patch, delete, and /move to another dashboard
  • /api/v2/dashboard-templates: "Web analytics" and "Product analytics" (six and five insights). They use relative dates and are created with {"template": "…"}. A unit test runs every template query through the per-kind validators.
  • Filters: date_from and date_to (relative values allowed) plus extra properties are applied to every insight tile.
    • With filters, results are cached per tile, keyed by insight id, insight version and filters, so editing an insight invalidates the tile.
    • Without filters, tiles share the insight's own cache.
    • A failing tile returns error and the rest of the dashboard still renders.
    • Tiles that read person properties need the identity module; without it, only those tiles fail.
  • Sharing:
    • A link can target a dashboard or a saved insight, and the resource must belong to the project.
    • GET /api/shared/{token} serves the dashboard (all tiles), the insight, or, for legacy module links, a 30-day overview.
    • The password goes in an x-share-password header, is compared in constant time, and locks out for 15 minutes after 10 wrong attempts.
    • password_hash is no longer serialized in API responses.
  • Compatibility: v1 /api/v1/dashboards (legacy custom dashboards, used by both SDKs) is unchanged, which is why the new API lives under /api/v2.

Reviews and Follow-up

  • Code review: self-reviewed
  • Security review: ownership checked for every tile, move and share target; brute-force lockout on share passwords; constant-time hash compare; no hash leakage
  • Documentation: request shapes above. Follow-ups:
    • migrate legacy custom_dashboards rows into v2
    • stronger password hashing for share links (argon2)
    • dashboard UI

Files Changed

  • migrations/032_dashboards_v2.{up,down}.sql
  • services/dashboards.rs, routes/dashboards.rs (new)
  • services/sharing.rs, routes/features_ext.rs (share targets)
  • routes/mod.rs, services/mod.rs, main.rs

Scope and Non-scope

In scope: the dashboards v2 API, templates and public share links. Out of scope: UI, migrating legacy dashboards, and the excluded LLM/account features.

Validation

I ran this end to end against Postgres 18 and checked 34 cases:

  • tiles and validation
  • tile results equal the ad-hoc API with and without dashboard filters
  • cache reuse and invalidation on insight change
  • tile-level errors
  • bulk layouts, move, duplicate, the single home dashboard, and list filters
  • both templates render every tile
  • the legacy v1 route still works
  • public share links: no key, password, lockout, legacy and unknown tokens

Dashboards verification

Testing

cargo test: 125 passed, including new tests for filter application, template validity and layout validation.

cargo test dashboards

Size and Notes

About 1,200 changed lines. Migration 032 only creates tables and adds nullable columns.

🤖 Generated with Claude Code

…ic share links

- dashboards + dashboard_tiles tables; /api/v2/dashboards CRUD, list with
  search/tags/pinned, one home dashboard per project, soft delete
- tiles: saved-insight or markdown text, grid layout, add/update/delete,
  bulk layout save, move between dashboards, duplicate (optionally copying
  insights), at most 100 tiles
- dashboard filters (date range incl. relative dates + extra properties)
  applied to every insight tile; per-tile cache keyed by insight version and
  filters; without filters tiles share the insight's own cache; a failing
  tile reports its error without failing the dashboard; person-property tiles
  respect the identity module
- built-in templates (web analytics, product analytics) at
  /api/v2/dashboard-templates, created via {"template": "..."}
- share links can target a dashboard or a saved insight; new public
  GET /api/shared/{token} (password via x-share-password, constant-time
  check, lockout after 10 failures); password hashes no longer returned
- legacy /api/v1/dashboards (custom dashboards used by the SDK) unchanged

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T22:29:06.461595Z 656eaeb PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 656eaebb14

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

… read; enforce tile limit on move

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ayushozha
ayushozha changed the base branch from ayush/saved-insights to main November 17, 2026 01:13
@ayushozha
ayushozha merged commit 4415837 into main Nov 17, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant