Files
outline/plugins/webhooks
codegen-sh[bot] 6c2313919b Improve webhook disabling heuristic with time-based analysis (#9800)
* Improve webhook disabling heuristic with time-based analysis

- Add WEBHOOK_FAILURE_TIME_WINDOW environment variable (default: 24 hours)
- Add WEBHOOK_FAILURE_RATE_THRESHOLD environment variable (default: 80%)
- Replace simple count-based logic with time-window failure rate analysis
- Require minimum 5 deliveries in time window before disabling
- Add comprehensive logging for webhook failure analysis
- Update email template to reflect new time-based approach

Addresses GitHub issue #9788 by making webhook disabling smarter and
considering time factors instead of just consecutive failure counts.

* Fix Logger.warn type error

Remove extra 'task' parameter from Logger.warn call to match the correct
signature: Logger.warn(message: string, extra?: Extra)

* Update WEBHOOK_FAILURE_TIME_WINDOW to use seconds instead of hours

- Change default value from 24 (hours) to 86400 (seconds)
- Update time conversion logic from hours*60*60*1000 to seconds*1000
- Rename timeWindowHours variable to timeWindowSeconds for clarity
- Update documentation comments to reflect seconds-based configuration

This provides more granular control while maintaining the same default
behavior (24 hours = 86400 seconds).

* Improve webhook failure logging and analysis threshold

- Only log webhook failure analysis when failedDeliveries.length > 0
- Extract hardcoded minimum deliveries threshold to constant
- Update minimum deliveries threshold from 5 to 10 for more reliable analysis

This reduces log noise when there are no failures and requires more data
points before considering webhook disabling.

---------

Co-authored-by: codegen-sh[bot] <131295404+codegen-sh[bot]@users.noreply.github.com>
2025-08-03 15:39:04 -04:00
..
2024-06-12 05:03:38 -07:00