<?php

namespace App\Http\Middleware;

use App\Services\AttributionService;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class CaptureAttribution
{
    public function handle(Request $request, Closure $next): Response
    {
        if ($request->hasSession()) {
            app(AttributionService::class)->capture($request);
        }

        return $next($request);
    }
}
