Skip to content

New: Add option to display error/fatal messages as on-screen push notifications (fixes #871)#872

Open
swashbuck wants to merge 1 commit into
masterfrom
issue/871
Open

New: Add option to display error/fatal messages as on-screen push notifications (fixes #871)#872
swashbuck wants to merge 1 commit into
masterfrom
issue/871

Conversation

@swashbuck

Copy link
Copy Markdown
Contributor

Fixes #871

New

Adds an opt-in mode where error and fatal log messages are also shown as on-screen push notifications, not only written to the browser console. This gives non-developer authors visibility of problems they would otherwise miss, so they can report them to a developer. The console output is unchanged.

The consumer lives in the notify view and subscribes to logging's existing log:error/log:fatal events, so logging.js is untouched and no new module dependencies are introduced. Notifications are deduplicated by message, show only the logged message (no stack trace), and use a generous, manually dismissable timeout. They are styled with fixed system colours to echo the browser console's error styling.

Behaviour is gated by a new _logging._notify config block, disabled by default so published courses do not surface errors to learners. Authors enable it when previewing. Added to both the modern (config.schema.json) and legacy (config.model.schema) schemas.

Config:

"_logging": {
  "_notify": {
    "_isEnabled": false,
    "_level": "error",
    "_timeout": 15000
  }
}
  • _isEnabled (default false): off unless the author opts in.
  • _level (error or fatal, default error): minimum level to notify.
  • _timeout (default 15000): how long each notification stays before fading; can also be dismissed manually.

Testing

  1. In a course config.json, set _logging._notify._isEnabled to true.
  2. Trigger an error, for example by running require('core/js/logging').error('Test error') in the browser console, or by loading a course with a known misconfiguration.
  3. Confirm the message appears as a push notification in the top-right, with red outline and pink fill, and also in the console.
  4. Fire the same message twice and confirm the second does not produce a duplicate notification.
  5. Set _isEnabled back to false and confirm no notification appears.

Posted via collaboration with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Needs Reviewing

Development

Successfully merging this pull request may close these issues.

New: optionally surface error/fatal logs as on-screen notifications

2 participants