blob: dda06620feb2716bda8796df57e2d441c3b61860 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
<?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);
}
}
|