Add integrations health monitoring
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Jobs\ProcessRevenueCatWebhook;
|
||||
use App\Services\Integrations\IntegrationWebhookRecorder;
|
||||
use App\Support\ApiError;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -11,6 +12,8 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class RevenueCatWebhookController extends Controller
|
||||
{
|
||||
public function __construct(private readonly IntegrationWebhookRecorder $recorder) {}
|
||||
|
||||
public function handle(Request $request): JsonResponse
|
||||
{
|
||||
$secret = (string) config('services.revenuecat.webhook', '');
|
||||
@@ -61,9 +64,18 @@ class RevenueCatWebhookController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
$eventId = (string) $request->header('X-Event-Id', '');
|
||||
$eventType = data_get($decoded, 'event.type');
|
||||
$webhookEvent = $this->recorder->recordReceived(
|
||||
'revenuecat',
|
||||
$eventId !== '' ? $eventId : null,
|
||||
is_string($eventType) && $eventType !== '' ? $eventType : null,
|
||||
);
|
||||
|
||||
ProcessRevenueCatWebhook::dispatch(
|
||||
$decoded,
|
||||
(string) $request->header('X-Event-Id', '')
|
||||
$eventId,
|
||||
$webhookEvent->id,
|
||||
);
|
||||
|
||||
return response()->json(['status' => 'accepted'], 202);
|
||||
|
||||
Reference in New Issue
Block a user