'Statistics', 'route' => 'manager.statistics.index', 'permission' => 'statistics.view']]; } public function commands(): array { return [ForgetVisitorKeys::class]; } public function actions(): array { return ['statistics.export' => ['Exported the statistics', ['sheet']]]; } public function views(): array { return ['statistics.index' => 'Opened the statistics']; } public function boot(): void { app()->singleton(CountedPages::class); // A person opens a few pages a minute; this only stops someone from flooding the statistics. RateLimiter::for('manager-pulse', fn (Request $request) => Limit::perMinute(max(1, (int) config('manager.statistics.per_minute', 120)))->by((string) $request->ip())); // Programs never run the script that reports a view, so the server counts the pages it serves them. // Through the kernel: it copies its own groups to the router when a request starts. if (config('manager.statistics.count_bots') && method_exists($kernel = app(Kernel::class), 'appendMiddlewareToGroup')) { $kernel->appendMiddlewareToGroup('web', CountBots::class); } // Without yesterday's key, yesterday's visitor codes can no longer be traced back. if (app()->runningInConsole()) { app()->afterResolving(Schedule::class, fn (Schedule $schedule) => $schedule->command(ForgetVisitorKeys::class)->dailyAt('00:05')); } } }