diff --git a/config/telescope.php b/config/telescope.php index 9540fad7d..71753eeba 100644 --- a/config/telescope.php +++ b/config/telescope.php @@ -162,7 +162,7 @@ Watchers\RequestWatcher::class => [ 'enabled' => env('TELESCOPE_REQUEST_WATCHER', true), 'size_limit' => env('TELESCOPE_RESPONSE_SIZE_LIMIT', 64), - 'ignore_status_code' => [], + 'ignore_status_codes' => [], ], Watchers\ScheduleWatcher::class => env('TELESCOPE_SCHEDULE_WATCHER', true), diff --git a/src/Watchers/RequestWatcher.php b/src/Watchers/RequestWatcher.php index 9b6694f43..bb840bb8a 100644 --- a/src/Watchers/RequestWatcher.php +++ b/src/Watchers/RequestWatcher.php @@ -36,7 +36,8 @@ public function register($app) */ public function recordRequest(RequestHandled $event) { - if (! Telescope::isRecording() || $this->shouldIgnore($event)) { + if (! Telescope::isRecording() || + $this->shouldIgnoreStatusCode($event)) { return; } @@ -58,6 +59,20 @@ public function recordRequest(RequestHandled $event) ])); } + /** + * Determine if the request should be ignored based on its status code. + * + * @param mixed $event + * @return bool + */ + protected function shouldIgnoreStatusCode($event) + { + return in_array( + $event->response->getStatusCode(), + $this->options['ignore_status_codes'] ?? [] + ); + } + /** * Format the given headers. * @@ -208,15 +223,4 @@ protected function extractDataFromView($view) } })->toArray(); } - - /** - * Determine if the request should be ignored. - * - * @param mixed $event - * @return bool - */ - private function shouldIgnore($event) - { - return in_array($event->response->getStatusCode(), $this->options['ignore_status_code'] ?? []); - } }