The Notification Delivery Analytics feature provides superadmins with a comprehensive dashboard to track per-channel delivery counts for email vs in-app notifications. This helps monitor the impact of user notification preferences and ensure reliable message delivery across the platform.
- Model:
App\Models\NotificationDeliveryLog— stores each delivery event with user, notification type, channel, category, and timestamp. - Listener:
App\Listeners\LogNotificationDelivery— listens to Laravel'sIlluminate\Notifications\Events\NotificationSentevent and records a log entry for every notification successfully delivered. - Controller:
App\Http\Controllers\Admin\NotificationAnalyticsController— aggregates delivery data into metrics, daily trends, type breakdowns, category breakdowns, and channel split percentages. - Migration:
notification_delivery_logstable with indexed columns for efficient querying.
- Page:
resources/js/pages/admin/notification-analytics.tsx— React page with Inertia rendering. - Layout: Accessible from the Admin Panel sidebar under "Notifications".
| Column | Type | Description |
|---|---|---|
id |
bigint | Primary key |
user_id |
foreignId | The user the notification was delivered to |
notification_type |
string | Class basename of the notification (e.g., DataExportCompleted) |
channel |
string | Normalized channel: email or in_app |
category |
string? | Optional category: security, team, billing, marketing |
is_successful |
boolean | Whether delivery was successful |
delivered_at |
timestamp | When the notification was delivered |
-
Key Metrics Cards:
- Total deliveries
- Email deliveries (with % of total)
- In-app deliveries (with % of total)
- Week-over-week trend (% change)
-
Daily Deliveries Chart (14 days):
- Stacked bar chart showing email vs in-app per day
- Hover tooltips with exact counts
-
Channel Distribution:
- Visual split bar showing email vs in-app ratio
-
By Category:
- Horizontal bars grouped by notification category (security, team, billing, marketing)
-
By Notification Type:
- Table with per-type email/in-app/total counts
The listener normalizes Laravel channel names for consistent storage:
mail→emaildatabase→in_app
Notification types are mapped to categories via LogNotificationDelivery::$categoryMap. New notification types can register their category using:
LogNotificationDelivery::registerCategory(MyNotification::class, 'billing');- Only superadmins (
is_superadmin = true) can access the analytics page. - Route:
GET /admin/notification-analytics - Named route:
admin.notification-analytics.index
9 Pest feature tests cover:
- Page renders for superadmins
- Non-admin access is forbidden
- Correct delivery counts by channel
- Deliveries grouped by notification type
- Channel split percentage calculation
- Category grouping
- Listener logs from
NotificationSentevent - Listener normalizes
database→in_app - Old deliveries excluded from 30-day metrics
app/Models/NotificationDeliveryLog.phpapp/Listeners/LogNotificationDelivery.phpapp/Http/Controllers/Admin/NotificationAnalyticsController.phpdatabase/migrations/2026_03_05_211440_create_notification_delivery_logs_table.phpresources/js/pages/admin/notification-analytics.tsxtests/Feature/Admin/NotificationAnalyticsTest.php