feat: add error monitoring via System Health dashboard - #21
Open
datengraben wants to merge 2 commits into
Open
Conversation
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
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.
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:
(autoload=false), records severity, message, caller file/line
the WP_DEBUG_LOG guard — errors are captured in production too
so API, Cache, Repository, and View errors all feed the monitor;
these locations correspond to past bugs GBFS API: Zeitzonen inkorrekt wielebenwir/commonsbooking#1388, Hotfix notwendig: Doppelbuchungen durch nicht invalidierten Cache wielebenwir/commonsbooking#1864, GBFS Stationsaufbau falsch wielebenwir/commonsbooking#2004, Admin cannot cancel booking of other user in frontend wielebenwir/commonsbooking#2124
capability, available to CB managers not just site admins) with:
database, scheduled cron jobs, REST API, recent error count;
extensible via
commonsbooking_health_checksfiltertimestamp / severity / message / file:line; Clear button (nonce-
protected, POST-redirect-GET)
https://claude.ai/code/session_01NwDYnmgULHKztjaB4fcj99