diskfloppy.me/app/Http/Middleware/PageView.php

29 lines
666 B
PHP
Raw Normal View History

2024-06-11 20:36:58 +00:00
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use PostHog\PostHog;
use Symfony\Component\HttpFoundation\Response;
class PageView
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
PostHog::capture([
'distinctId' => request()->ip(),
'event' => '$pageview',
'properties' => array(
'$current_url' => url()->current(),
),
]);
return $next($request);
}
}