Logo Beartropy Alert System

Alert System

Sending Alerts
Sending alerts is straightforward using the Alert facade.

Basic Usage

Simple usage with just a type and a message.

1use Beartropy\AlertSystem\Facades\Alert;
2 
3Alert::send('Healthcheck', '🔥 CPU is on fire');

Advanced Usage

Pass additional details (context) and options (like subject or cooldown).

The process involves:

  • Looking up all recipients configured for the given alert type.
  • Sending the message via all associated channels (e.g., mail, telegram).
  • Logging the result (success/failure) for each recipient.

1use Beartropy\AlertSystem\Facades\Alert;
2 
3Alert::send('System', 'The disk is almost full', [
4 'host' => 'web-01',
5 'threshold' => '95%',
6], [
7 'mailSubject' => '🚨 Disk Alert',
8 'cooldown' => 0,
9]);

Method Signature

The detailed signature of the send method.

1Alert::send(
2 string $type,
3 string $message,
4 array $details = [],
5 array $options = [] // e.g., mailSubject, cooldown
6): void