Start free trial
Start free trial Log in

14-day free trial. No credit card.

How to track Laravel notifications in production

Per-channel delivery tracking across mail, Slack, SMS, database, and broadcast, with event listeners and aggregate dashboards.

  • Guide
  • 3 min read

How do I track Laravel notifications?

Listen to NotificationSending, NotificationSent, and NotificationFailed events in a service provider to record every delivery. For aggregated dashboards per notification class and channel, install an APM. NightOwl records every notification with its class, channel and duration, grouped by class with send counts and average and p95 duration over time.

Updated

A notification in Laravel can fan out to five channels from one dispatch (email, Slack, SMS, a database row, a broadcast), and each of those can succeed or fail independently. That's what tracking has to account for: "the OrderShipped notification went out" isn't a single yes/no, it's five separate deliveries with five different failure modes. A user can get the email and not the SMS, or the database row and nothing else. Monitoring notifications means watching delivery per channel, not per notification.

The three notification events

Laravel fires these events once per channel: NotificationSending before the channel runs (return false from a listener to cancel that channel), then NotificationSent if the channel succeeds or NotificationFailed if it throws. Register the listeners in AppServiceProvider::boot():

app/Providers/AppServiceProvider.php

php
use Illuminate\Notifications\Events\NotificationSending;
use Illuminate\Notifications\Events\NotificationSent;
use Illuminate\Notifications\Events\NotificationFailed;
use Illuminate\Support\Facades\Event;

public function boot(): void
{
    Event::listen(function (NotificationSent $event) {
        logger()->info('Notification sent', [
            'class' => get_class($event->notification),
            'channel' => $event->channel,
            'notifiable_type' => get_class($event->notifiable),
            'notifiable_id' => $event->notifiable->getKey(),
        ]);
    });

    Event::listen(function (NotificationFailed $event) {
        logger()->error('Notification failed', [
            'class' => get_class($event->notification),
            'channel' => $event->channel,
            'data' => $event->data,
        ]);
    });
}

Queue every notification, then track the queue

Every notification that hits an external service (mail, Slack, SMS) should implement ShouldQueue so it doesn't block the request:

app/Notifications/OrderShipped.php

php
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;

class OrderShipped extends Notification implements ShouldQueue
{
    use Queueable;

    public function via($notifiable): array
    {
        return ['mail', 'database'];
    }

    public function shouldSend($notifiable, $channel): bool
    {
        // Rate-limit: don't send twice within an hour
        $key = "shipped:{$notifiable->id}:{$channel}";
        if (cache()->has($key)) return false;
        cache()->put($key, true, now()->addHour());
        return true;
    }
}

Queued notifications fail as queued jobs. Pair notification tracking with failed-job monitoring to catch silent delivery failures.

Metrics that matter

  • Delivery rate per channel: sent / (sent + failed). Drops indicate provider issues.
  • Send count per notification class: Catches runaway sends during incidents.
  • Queue lag: Time between dispatch and actual delivery. Rising lag means your workers can't keep up (see monitoring queue latency).
  • Failure clustering by recipient: Same user failing across multiple notifications usually means a stale email address or broken webhook.

Gotchas by channel

  • Mail: Your mail provider accepting the message doesn't mean it reached the user's inbox. Track bounces via your mail provider's webhook and mark users as undeliverable in your database.
  • Slack webhooks: A workspace admin can revoke or rotate the webhook URL, and every send fails until someone updates your config. Alert when all recent Slack sends fail, not on each one.
  • SMS: Carriers drop small percentages. Don't alert on single failures, alert on rate drops.
  • Database: Rarely fails, since it's an insert into your own database, but users only see it when they log in, so don't make it your only channel.
  • Broadcast: Depends on your broadcaster (Pusher, Ably, Reverb). WebSocket disconnects mean delivery isn't guaranteed for offline users.

NightOwl alerts when a send throws an exception it hasn't seen before or runs past its duration threshold; the all-failed and rate-drop checks above need a NotificationFailed listener of your own.

See every notification by class and channel

The Notifications page lists each notification class with its channels, send count, and average and p95 duration. Set a duration threshold on a notification and NightOwl opens a performance issue, with an alert, when a send runs longer.

No credit card needed.

Terminal
composer require nightowl/agent
php artisan nightowl:install
php artisan nightowl:agent

Frequently asked questions

Anything else, write to support@usenightowl.com

How do I track Laravel notifications in production?

For each channel, Laravel fires NotificationSending, then NotificationSent when the channel succeeds or NotificationFailed when it throws. Listen to them in AppServiceProvider to record per-channel delivery. For per-class counts and send durations without writing the listeners yourself, install an APM that wires the events for you. NightOwl records every notification with its class, channel and duration, tied to the request or job that sent it.

What's the difference between Laravel mail and notifications?

Mail is one transport. Notifications are a higher-level abstraction that can deliver across mail, Slack, Nexmo/Vonage, database rows, broadcast channels, or anything you implement as a driver. Tracking mail monitors email delivery; tracking notifications monitors every channel an instance of a notification class fires through. Most teams care about both but in different dashboards.

How do I know when a Slack or SMS notification fails in Laravel?

Laravel dispatches NotificationFailed only when a channel throws while sending, with the channel name and the exception in $event->data['exception']. A channel that gets an error back without throwing never fires it. Register a listener on NotificationFailed, log by channel, and alert on spike. Delivery to the end user isn't guaranteed by a 200 response.

Should I queue Laravel notifications?

Yes, almost always. Notifications dispatched from the request cycle block the response. Use ShouldQueue on the notification class, which turns each delivery into a queued job. Downside: queued notifications fail in the queue, not in the request, so you need failed-job monitoring (see our failed-job guide) to notice when they don't deliver.

How do I track which users received which notifications?

Use the database channel: Laravel's built-in notifications table stores notifiable_id, type, read_at, and data per delivery. Combine with NotificationSent event listeners for channels that don't write to the database. For privacy-aware recipient tracking, store a hashed user ID rather than PII in log records.

How do I rate-limit Laravel notifications?

Use shouldSend($notifiable, $channel) on the notification class to return false when the recipient has already received the same class within a cooldown window (store the last-sent timestamp in cache or DB). For global rate limits, wrap the dispatch in Laravel's RateLimiter facade. Aggressive rate limiting on errors prevents notification storms during incidents.

What's a realistic delivery rate for Laravel notifications?

Channel-dependent, and there's no reliable benchmark to aim for. Database notifications never leave your app, so they only fail when the insert fails. Email, Slack and SMS depend on providers and carriers you don't control. Track delivery rate per channel over time and compare it with its own history. A falling rate on email usually means sender reputation is slipping.

Can I test Laravel notifications without actually sending?

Yes. Notification::fake() in your test class intercepts every dispatch. Assert which notifications were sent to which notifiable, and with which channel. For dry-runs in production (e.g. a staging run that shouldn't actually email users), use the log mail driver and a no-op Slack webhook URL in env-specific config.

Related

Flat pricing, whatever your traffic does

Every plan starts with a 14-day free trial. No credit card needed.

Hobby
$5 a month

One app for a side project. Issues and alerts, with a 14-day dashboard window.

Start my 14-day trial
TeamRecommended
$15 a month

Up to 3 apps and 5 people per team. Full history, the MCP server, data clearing and agent health.

Start my 14-day trial
Agency
$69 a month

Unlimited client apps and people, one overview of every app, and apps you can hand over.

Start my 14-day trial