Skip to content

feat: add error monitoring via System Health dashboard - #21

Open
datengraben wants to merge 2 commits into
masterfrom
claude/add-error-monitoring-g8QGe
Open

feat: add error monitoring via System Health dashboard#21
datengraben wants to merge 2 commits into
masterfrom
claude/add-error-monitoring-g8QGe

Conversation

@datengraben

Copy link
Copy Markdown
Owner

Introduces a persistent, admin-accessible error log and system health
dashboard so plugin-level admins can diagnose problems without needing
WP_DEBUG_LOG or server log access.

Key changes:

https://claude.ai/code/session_01NwDYnmgULHKztjaB4fcj99

claude added 2 commits May 9, 2026 09:12
Introduces a persistent, admin-accessible error log and system health
dashboard so plugin-level admins can diagnose problems without needing
WP_DEBUG_LOG or server log access.

Key changes:
- ErrorMonitor service: ring buffer (100 entries) stored in wp_options
  (autoload=false), records severity, message, caller file/line
- commonsbooking_write_log() now always records to ErrorMonitor before
  the WP_DEBUG_LOG guard — errors are captured in production too
- Replace 12 direct error_log() calls in src/ with commonsbooking_write_log()
  so API, Cache, Repository, and View errors all feed the monitor;
  these locations correspond to past bugs wielebenwir#1388, wielebenwir#1864, wielebenwir#2004, wielebenwir#2124
- Plugin::renderError() records every admin-notice transient error
- Plugin::handleBookingForms() records BookingDeniedException
- New CommonsBooking → System Health admin page (manage_commonsbooking
  capability, available to CB managers not just site admins) with:
    * System Status tab: PHP version, WP version, PHP extensions,
      database, scheduled cron jobs, REST API, recent error count;
      extensible via `commonsbooking_health_checks` filter
    * Error Log tab: sortable table of recorded errors with
      timestamp / severity / message / file:line; Clear button (nonce-
      protected, POST-redirect-GET)
- PHPUnit tests: ErrorMonitorTest (11 cases) and SystemHealthTest (5 cases)
- Cypress e2e tests: 5 specs covering page load, tab switching, menu entry

https://claude.ai/code/session_01NwDYnmgULHKztjaB4fcj99
Adds a "Download Troubleshooting Report" button to the System Health
dashboard that generates a self-contained local JSON file — no telemetry,
no external requests.

Report sections:
- system: plugin/WP/PHP versions, active plugins & theme, debug flags
- health: all SystemHealth checks (reused directly)
- error_log: full ErrorMonitor ring buffer
- stats: post counts for items, locations, timeframes, restrictions,
  bookings (confirmed/unconfirmed/canceled), orphaned bookings
- cron: next-run timestamp + human diff for all CB scheduled hooks

Implementation:
- TroubleshootingReport service collects all sections; extensible via
  `commonsbooking_troubleshooting_report` filter
- Secured via admin_post_ hook + nonce + manage_commonsbooking cap check
- 9 PHPUnit tests covering structure, types, filter, ISO 8601 timestamp,
  ErrorMonitor integration

https://claude.ai/code/session_01NwDYnmgULHKztjaB4fcj99
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.

2 participants