diff --git a/config/telescope.php b/config/telescope.php index f6e1a6ace..9540fad7d 100644 --- a/config/telescope.php +++ b/config/telescope.php @@ -162,6 +162,7 @@ Watchers\RequestWatcher::class => [ 'enabled' => env('TELESCOPE_REQUEST_WATCHER', true), 'size_limit' => env('TELESCOPE_RESPONSE_SIZE_LIMIT', 64), + 'ignore_status_code' => [], ], Watchers\ScheduleWatcher::class => env('TELESCOPE_SCHEDULE_WATCHER', true), diff --git a/src/Watchers/RequestWatcher.php b/src/Watchers/RequestWatcher.php index eb8ed7484..9b6694f43 100644 --- a/src/Watchers/RequestWatcher.php +++ b/src/Watchers/RequestWatcher.php @@ -36,7 +36,7 @@ public function register($app) */ public function recordRequest(RequestHandled $event) { - if (! Telescope::isRecording()) { + if (! Telescope::isRecording() || $this->shouldIgnore($event)) { return; } @@ -208,4 +208,15 @@ 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'] ?? []); + } }