Skip to content

feat(dashboard): add dashboard and widget management commands#401

Closed
betegon wants to merge 5 commits intomainfrom
feat/dashboard-commands
Closed

feat(dashboard): add dashboard and widget management commands#401
betegon wants to merge 5 commits intomainfrom
feat/dashboard-commands

Conversation

@betegon
Copy link
Member

@betegon betegon commented Mar 12, 2026

Closes #402

Adds sentry dashboard and sentry dashboard widget commands for managing dashboards without raw sentry api calls. This came out of a bug where stripping widgetType during a PUT caused all widgets to default to "error-events" — these commands provide a safe, typed interface.

Commands

sentry dashboard list [<org/>]
sentry dashboard view <id> [<org/>]
sentry dashboard create <title> [<org/>] [--widget-json <path>]
sentry dashboard delete <id> [<org/>]
sentry dashboard widget add <dashboard-id> --from-json <path> [<org/>]
sentry dashboard widget edit <dashboard-id> (--index <n> | --title <name>) --from-json <path> [<org/>]
sentry dashboard widget delete <dashboard-id> (--index <n> | --title <name>) [<org/>]
sentry dashboards   # plural alias → dashboard list

All commands support --json/--fields via buildCommand. Dashboard and widget targets can use <org/dashboard> positional syntax or title-based resolution (e.g. sentry dashboard view "Error Monitoring").

How widget mutations work

Widget add/edit/delete follow a GET → modify → PUT flow. The prepareDashboardForUpdate() utility strips only server-generated fields (id, dashboardId, dateCreated from widgets; id, widgetId, dateCreated from queries; isResizable from layout). It never strips widgetType, displayType, or layout, which was the root cause of the previous bug.

Widget JSON is validated against Zod schemas before being sent to the API.

Default layout

New widgets are auto-placed on a 6-column grid. Line, area, and bar charts default to w=3 so two fit side-by-side per row (3+3=6). Big numbers use w=2 (three per row), tables use w=6 (full width), and world maps use w=4.

Changes

  • src/types/dashboard.ts — Zod schemas, types, auto-layout utilities, and stripWidgetServerFields/prepareDashboardForUpdate
  • src/types/index.ts — Shared positional-target parsing (parseOrgTarget, parseDashboardTarget)
  • src/commands/dashboard/list, view, create, delete + route map
  • src/commands/dashboard/widget/add, edit, delete + route map
  • src/commands/dashboard/resolve.ts — Title-based dashboard resolution (fuzzy match with confirmation)
  • src/lib/api-client.tslistDashboards, getDashboard, createDashboard, updateDashboard, deleteDashboard
  • src/lib/sentry-urls.tsbuildDashboardsListUrl, buildDashboardUrl
  • src/lib/formatters/human.ts — Dashboard and widget table/detail formatters
  • src/app.ts — Route registration + dashboards plural alias

Test plan

  • bun run typecheck passes
  • bun run lint passes
  • sentry dashboard list sentry/
  • sentry dashboard view <id> sentry/ --json
  • sentry dashboard create "Test" sentry/
  • sentry dashboard delete <id> sentry/
  • Widget add/edit round-trip preserves widgetType (verify with --json | jq)
  • Widget delete removes correct widget by index/title
  • Two line/bar widgets auto-layout side-by-side (w=3 each)

Adds `sentry dashboard list/view/create` and `sentry dashboard widget add/edit`
commands for managing Sentry dashboards without raw API calls.

Widget add/edit use a GET-modify-PUT flow that preserves widgetType, displayType,
and layout — only server-generated fields (id, dateCreated, etc.) are stripped.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 12, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

Init

  • Enforce canonical feature display order by betegon in #388
  • Accept multiple delimiter formats for --features flag by betegon in #386
  • Add git safety checks before wizard modifies files by betegon in #379
  • Add experimental warning before wizard runs by betegon in #378
  • Add init command for guided Sentry project setup by betegon in #283

Issue List

  • Auto-compact when table exceeds terminal height by BYK in #395
  • Redesign table to match Sentry web UI by BYK in #372

Other

  • (dashboard) Add dashboard and widget management commands by betegon in #401
  • Add --dry-run flag to mutating commands by BYK in #387
  • Return-based output with OutputConfig on buildCommand by BYK in #380
  • Add --fields flag for context-window-friendly JSON output by BYK in #373
  • Magic @ selectors (@latest, @most_frequent) for issue commands by BYK in #371
  • Input hardening against agent hallucinations by BYK in #370
  • Add response caching for read-only API calls by BYK in #330

Bug Fixes 🐛

Init

  • Remove implementation detail from help text by betegon in #385
  • Truncate uncommitted file list to first 5 entries by MathurAditya724 in #381

Other

  • (api) Convert --data to query params for GET requests by BYK in #383
  • (docs) Remove double borders and fix column alignment on landing page tables by betegon in #369
  • Add trace ID validation to trace view + UUID dash-stripping by BYK in #375

Internal Changes 🔧

Init

  • Remove --force flag by betegon in #377
  • Remove dead determine-pm step label by betegon in #374

Other

  • Migrate non-streaming commands to CommandOutput with markdown rendering by BYK in #398
  • Convert Tier 2-3 commands to return-based output and consola by BYK in #394
  • Convert remaining Tier 1 commands to return-based output by BYK in #382
  • Converge Tier 1 commands to writeOutput helper by BYK in #376

Other

  • Minify JSON on read and pretty-print on write in init local ops by MathurAditya724 in #396

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 12, 2026

Codecov Results 📊

104 passed | Total: 104 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

❌ Patch coverage is 60.81%. Project has 1158 uncovered lines.
❌ Project coverage is 94.47%. Comparing base (base) to head (head).

Files with missing lines (4)
File Patch % Lines
api-client.ts 73.96% ⚠️ 263 Missing
human.ts 89.20% ⚠️ 143 Missing
dashboard.ts 48.62% ⚠️ 93 Missing
sentry-urls.ts 85.14% ⚠️ 11 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    95.50%    94.47%    -1.03%
==========================================
  Files          142       152       +10
  Lines        20343     20958      +615
  Branches         0         0         —
==========================================
+ Hits         19427     19800      +373
- Misses         916      1158      +242
- Partials         0         0         —

Generated by Codecov Action

betegon and others added 2 commits March 12, 2026 10:17
…ased resolution

Switch all dashboard commands from --org flag to [<org/project>] positional
pattern (consistent with issue list, project list, etc). Dashboard create
now auto-detects and passes project IDs to the API for project-scoped
dashboards.

- Add projects?: number[] to createDashboard/updateDashboard API signatures
- Preserve projects in prepareDashboardForUpdate() for widget GET→PUT flow
- Accept dashboard title (case-insensitive) in addition to numeric ID for
  view, widget add/edit/delete commands
- Extract shared resolve.ts with resolveOrgFromTarget, parseDashboardPositionalArgs,
  and resolveDashboardId helpers
- Add widget delete command and route registration

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@betegon betegon mentioned this pull request Mar 12, 2026
2 tasks
line, area, and bar widgets defaulted to w=4 (of 6 columns), so two
charts could never sit side-by-side (4+4=8>6). Change to w=3 so two
fit per row (3+3=6), cutting dashboard vertical scroll roughly in half.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@betegon
Copy link
Member Author

betegon commented Mar 12, 2026

Superseded by #406 (dashboard list/view/create) and #407 (widget add/edit/delete).

@betegon betegon closed this Mar 12, 2026
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.

Dashboard & Widget CLI Commands

1 participant