feat(dashboard): add dashboard and widget management commands#401
Closed
feat(dashboard): add dashboard and widget management commands#401
Conversation
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>
Contributor
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Init
Issue List
Other
Bug Fixes 🐛Init
Other
Internal Changes 🔧Init
Other
Other
🤖 This preview updates automatically when you update the PR. |
Contributor
Codecov Results 📊✅ 104 passed | Total: 104 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ❌ Patch coverage is 60.81%. Project has 1158 uncovered lines. Files with missing lines (4)
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 |
…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>
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>
3 tasks
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #402
Adds
sentry dashboardandsentry dashboard widgetcommands for managing dashboards without rawsentry apicalls. This came out of a bug where strippingwidgetTypeduring a PUT caused all widgets to default to"error-events"— these commands provide a safe, typed interface.Commands
All commands support
--json/--fieldsviabuildCommand. 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,dateCreatedfrom widgets;id,widgetId,dateCreatedfrom queries;isResizablefrom layout). It never stripswidgetType,displayType, orlayout, 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=3so two fit side-by-side per row (3+3=6). Big numbers usew=2(three per row), tables usew=6(full width), and world maps usew=4.Changes
src/types/dashboard.ts— Zod schemas, types, auto-layout utilities, andstripWidgetServerFields/prepareDashboardForUpdatesrc/types/index.ts— Shared positional-target parsing (parseOrgTarget,parseDashboardTarget)src/commands/dashboard/—list,view,create,delete+ route mapsrc/commands/dashboard/widget/—add,edit,delete+ route mapsrc/commands/dashboard/resolve.ts— Title-based dashboard resolution (fuzzy match with confirmation)src/lib/api-client.ts—listDashboards,getDashboard,createDashboard,updateDashboard,deleteDashboardsrc/lib/sentry-urls.ts—buildDashboardsListUrl,buildDashboardUrlsrc/lib/formatters/human.ts— Dashboard and widget table/detail formatterssrc/app.ts— Route registration +dashboardsplural aliasTest plan
bun run typecheckpassesbun run lintpassessentry dashboard list sentry/sentry dashboard view <id> sentry/ --jsonsentry dashboard create "Test" sentry/sentry dashboard delete <id> sentry/widgetType(verify with--json | jq)w=3each)