Skip to content

Commit 3fa025d

Browse files
Chore: add webhook logging (alexjustesen#2647)
Co-authored-by: Alex Justesen <[email protected]>
1 parent 40eca53 commit 3fa025d

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

app/Actions/Notifications/SendWebhookTestNotification.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function handle(array $webhooks)
4242
'url' => url('/admin/results'),
4343
])
4444
->doNotSign()
45-
->dispatch();
45+
->dispatchSync();
4646
}
4747

4848
Notification::make()
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace App\Listeners;
4+
5+
use Illuminate\Support\Facades\Log;
6+
use Spatie\WebhookServer\Events\WebhookCallFailedEvent;
7+
8+
class LogWebhookFailure
9+
{
10+
/**
11+
* Handle the event.
12+
*/
13+
public function handle(WebhookCallFailedEvent $event): void
14+
{
15+
Log::error('Webhook notification failed', [
16+
'url' => $event->webhookUrl,
17+
'error_type' => $event->errorType,
18+
'error_message' => $event->errorMessage,
19+
]);
20+
}
21+
}

lang/en/settings/notifications.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
'webhook' => [
5757
'add' => 'Add webhook URLs!',
5858
'sent' => 'Test webhook notification sent.',
59+
'failed' => 'Webhook notification failed.',
5960
'payload' => 'Testing webhook notification',
6061
],
6162
],

0 commit comments

Comments
 (0)