Skip to content

Commit 18a7ab2

Browse files
docs: update @SInCE tags to 2.1.0 for new features
1 parent 8096d61 commit 18a7ab2

File tree

9 files changed

+92
-11
lines changed

9 files changed

+92
-11
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- **Granular Alert Preferences**: Per-submission failure alerts with granular control
13+
- New `alert_types` setting structure with `threshold` and `individual` options
14+
- `maybe_send_individual_alert()` triggers when a submission permanently fails after all retries
15+
- Individual alerts are event-driven (no cooldown) vs rate-limited threshold alerts
16+
- Privacy-first design: alert emails contain only error metadata (form name, endpoint, timestamp, response code, error message) - never user-submitted form data
17+
- Spam prevention: transient flag per log_id prevents duplicate alerts on retry
18+
- UI: "Alert Types" section with nested checkboxes for threshold and individual alerts
19+
- Threshold settings reorganized under clear subheading
20+
- Backward compatible: threshold alerts enabled by default, individual disabled
21+
- Integrated in `LogsController::handle_retry_action()` for retry exhaustion and max limit scenarios
22+
1223
- **Response Action Hook (`cf7_api_after_response`)**: New filter hook for extending plugin functionality
1324
- Fires after each API response is received (success or failure)
1425
- Provides complete response data (status code, headers, body, parsed JSON, duration)

docs/API_REFERENCE.md

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,31 @@ Handles plugin activation, deactivation, and lifecycle.
624624
| `uninstall()` | `void` | Plugin uninstallation handler |
625625
| `create_tables()` | `void` | Create database tables |
626626

627+
### Config\Settings
628+
629+
Plugin settings management with singleton pattern.
630+
631+
```php
632+
use SilverAssist\ContactFormToAPI\Config\Settings;
633+
634+
$settings = Settings::instance();
635+
$is_enabled = $settings->is_alerts_enabled();
636+
```
637+
638+
#### Methods
639+
640+
| Method | Return | Description |
641+
|--------|--------|-------------|
642+
| `instance()` | `Settings` | Get singleton instance |
643+
| `get(string $key, $default)` | `mixed` | Get setting value |
644+
| `set(string $key, $value)` | `bool` | Set setting value |
645+
| `is_alerts_enabled()` | `bool` | Check if alerts are enabled globally |
646+
| `get_alert_types()` | `array` | Get alert types configuration (since 2.1.0) |
647+
| `is_threshold_alerts_enabled()` | `bool` | Check if threshold alerts are enabled (since 2.1.0) |
648+
| `is_individual_alerts_enabled()` | `bool` | Check if individual alerts are enabled (since 2.1.0) |
649+
| `get_alert_recipients()` | `string` | Get comma-separated alert recipients |
650+
| `is_encryption_enabled()` | `bool` | Check if encryption is enabled |
651+
627652
### Service\Logging\LogWriter
628653

629654
Create and update log entries.
@@ -743,6 +768,45 @@ $encrypted = $encryption->encrypt($data);
743768
$decrypted = $encryption->decrypt($encrypted);
744769
```
745770

771+
### Service\Notification\EmailAlertService
772+
773+
Email alert service for monitoring API errors.
774+
775+
**Since**: 1.3.0 (Individual alerts added in 2.1.0)
776+
777+
```php
778+
use SilverAssist\ContactFormToAPI\Service\Notification\EmailAlertService;
779+
780+
$alerts = EmailAlertService::instance();
781+
$alerts->check_and_alert(); // Threshold-based alerts
782+
$alerts->maybe_send_individual_alert($log_id, $form_id); // Individual failure alerts
783+
```
784+
785+
#### Methods
786+
787+
| Method | Return | Description |
788+
|--------|--------|-------------|
789+
| `instance()` | `EmailAlertService` | Get singleton instance |
790+
| `check_and_alert()` | `void` | Check error rates and send threshold alerts |
791+
| `maybe_send_individual_alert(int $log_id, int $form_id)` | `void` | Send individual failure alert if enabled (since 2.1.0) |
792+
793+
#### Individual Failure Alerts
794+
795+
Individual failure alerts (added in 2.1.0) notify administrators immediately when a submission permanently fails after exhausting all retries.
796+
797+
**Features**:
798+
- Event-driven (no cooldown like threshold alerts)
799+
- Privacy-first: emails contain only error metadata, never user-submitted form data
800+
- Spam prevention: transient flag per log_id prevents duplicate alerts
801+
802+
**Alert email includes**:
803+
- Site name and form title
804+
- API endpoint URL
805+
- Timestamp
806+
- HTTP response code
807+
- Error message
808+
- Link to view full log details
809+
746810
### Controller\ContactForm\SubmissionController
747811

748812
CF7 submission controller handling hook registration.
@@ -993,6 +1057,6 @@ class LoggingServiceTest extends TestCase {
9931057

9941058
---
9951059

996-
**Document Version**: 2.0.0
997-
**Last Updated**: January 25, 2026
1060+
**Document Version**: 2.1.0
1061+
**Last Updated**: January 26, 2026
9981062
**Maintained By**: Silver Assist Development Team

includes/Config/Settings.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ public function is_encryption_enabled(): bool {
356356
/**
357357
* Get alert types configuration
358358
*
359-
* @since 2.0.0
359+
* @since 2.1.0
360360
* @return array{threshold: bool, individual: bool} Alert types configuration.
361361
*/
362362
public function get_alert_types(): array {
@@ -381,7 +381,7 @@ public function get_alert_types(): array {
381381
/**
382382
* Check if threshold alerts are enabled
383383
*
384-
* @since 2.0.0
384+
* @since 2.1.0
385385
* @return bool
386386
*/
387387
public function is_threshold_alerts_enabled(): bool {
@@ -392,7 +392,7 @@ public function is_threshold_alerts_enabled(): bool {
392392
/**
393393
* Check if individual failure alerts are enabled
394394
*
395-
* @since 2.0.0
395+
* @since 2.1.0
396396
* @return bool
397397
*/
398398
public function is_individual_alerts_enabled(): bool {

includes/Controller/Admin/LogsController.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ private function get_log_by_id( int $log_id ): ?array {
515515
*
516516
* Fetches statistics from LogStatistics service based on current filters.
517517
*
518+
* @since 2.1.0
518519
* @return array{stats: array<string, mixed>, date_context: string} Statistics and date context.
519520
*/
520521
private function get_statistics_data(): array {
@@ -544,6 +545,7 @@ private function get_statistics_data(): array {
544545
/**
545546
* Get date context label for statistics
546547
*
548+
* @since 2.1.0
547549
* @param string $date_filter Date filter type.
548550
* @param string|null $date_start Start date.
549551
* @param string|null $date_end End date.
@@ -578,6 +580,7 @@ private function get_date_context_label( string $date_filter, ?string $date_star
578580
*
579581
* Converts date filter type to start/end date strings.
580582
*
583+
* @since 2.1.0
581584
* @return array{filter: string, start: string|null, end: string|null} Date range parameters.
582585
*/
583586
private function get_date_range_from_filter(): array {
@@ -632,6 +635,7 @@ private function get_date_range_from_filter(): array {
632635
/**
633636
* Get custom date range from request parameters
634637
*
638+
* @since 2.1.0
635639
* @param string $date_start Start date.
636640
* @param string $date_end End date.
637641
* @return array{filter: string, start: string|null, end: string|null} Custom date range.
@@ -861,7 +865,7 @@ private function get_filtered_logs(): array {
861865
* Triggers an individual failure alert for a log entry if the feature is enabled.
862866
* Gets the form_id from the log and passes it to the EmailAlertService.
863867
*
864-
* @since 2.0.0
868+
* @since 2.1.0
865869
* @param int $log_id Log entry ID.
866870
* @return void
867871
*/

includes/Controller/Admin/SettingsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ private function sanitize_email_recipients( string $input ): string {
323323
/**
324324
* Sanitize alert types array
325325
*
326-
* @since 2.0.0
326+
* @since 2.1.0
327327
* @param array<string, mixed> $post_data POST data array.
328328
* @return array{threshold: bool, individual: bool} Sanitized alert types.
329329
*/

includes/Service/Logging/LogReader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public function decrypt_log_fields( array $log ): array {
222222
* Retrieves a list of forms that have at least one log entry.
223223
* Includes form ID and title, with graceful handling for deleted forms.
224224
*
225-
* @since 2.0.0
225+
* @since 2.1.0
226226
* @return array<int, array{form_id: string, post_title: string|null}> Array of forms with logs.
227227
*/
228228
public function get_forms_with_logs(): array {

includes/Service/Notification/EmailAlertService.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ public function send_test_email( string $recipient ): bool {
380380
* Called when a submission permanently fails after exhausting all retries.
381381
* Checks settings and sends alert if individual alerts are enabled.
382382
*
383-
* @since 2.0.0
383+
* @since 2.1.0
384384
* @param int $log_id Log entry ID.
385385
* @param int $form_id Contact Form 7 form ID.
386386
* @return void
@@ -416,7 +416,7 @@ public function maybe_send_individual_alert( int $log_id, int $form_id ): void {
416416
*
417417
* Sends an email notification for a single submission that failed permanently.
418418
*
419-
* @since 2.0.0
419+
* @since 2.1.0
420420
* @param int $log_id Log entry ID.
421421
* @param int $form_id Contact Form 7 form ID.
422422
* @return void
@@ -490,7 +490,7 @@ private function send_individual_failure_alert( int $log_id, int $form_id ): voi
490490
/**
491491
* Build individual failure alert email body HTML
492492
*
493-
* @since 2.0.0
493+
* @since 2.1.0
494494
* @param array<string, mixed> $log Log entry data.
495495
* @param string $form_title Form title.
496496
* @return string HTML email body.

phpstan-bootstrap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Defines WordPress constants that are not included in the stubs.
66
* These constants are defined in wp-includes/default-constants.php
77
*
8+
* @since 2.1.0
89
* @package ContactFormToAPI
910
*/
1011

tests/Unit/Service/Api/ApiClientHookTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/**
33
* Tests for ApiClient cf7_api_after_response hook
44
*
5+
* @since 2.1.0
56
* @package SilverAssist\ContactFormToAPI\Tests\Unit\Service\Api
67
*/
78

0 commit comments

Comments
 (0)