discourse/plugins/automation/spec/requests
Régis Hanol 6a79b59ac8
FEATURE: Track automation errors and improve logging (#36938)
When automations fail silently (e.g., PM sending blocked due to
validation errors), admins have no visibility into what's going wrong.
This leaves them guessing why their automations aren't working as
expected.

This change addresses the problem in three ways:

1. Error tracking in automation stats

The Stat model now tracks `total_errors` alongside existing run metrics.
When an automation raises an exception during execution, it's caught and
counted. This gives admins visibility into which automations are
experiencing problems.

2. Centralized logging module

Created `DiscourseAutomation::Logger` to replace scattered
`Rails.logger.warn("[discourse-automation] ...")` calls throughout the
codebase. This eliminates the fragile manual prefix pattern and ensures
consistent log formatting across all automation code. All existing
logging calls have been migrated to use this module.

3. Error count display in admin UI

The automation list now shows recent error counts next to run
statistics. Clicking the error count links directly to `/logs` filtered
for discourse-automation entries, making it easy to investigate
failures. The link uses `data-auto-route="true"` to ensure proper
navigation outside Ember's client-side router.

<img width="1397" height="1041" alt="2026-01-01 @ 23 03 34"
src="https://github.com/user-attachments/assets/6a6733f1-999c-44de-ab04-78dd764a1a43"
/>

Ref - https://meta.discourse.org/t/389922
2026-01-19 18:50:13 +01:00
..
admin_discourse_automation_automations_spec.rb FEATURE: Track automation errors and improve logging (#36938) 2026-01-19 18:50:13 +01:00
discourse_automation_append_last_checked_by_controller_spec.rb
discourse_automation_automations_spec.rb
discourse_automation_user_global_notices_spec.rb DEV: add shortcut fab!(:variable, :fabricator) to specs (#33577) 2025-07-11 11:16:34 -03:00