From 0502252f4354346a352209a533d874625bd4f1d2 Mon Sep 17 00:00:00 2001 From: Artyom Osepyan Date: Tue, 21 Oct 2025 20:57:06 +0300 Subject: [PATCH 1/4] feat: add shouldIgnoreHosts method to filter HTTP client requests by host --- config/telescope.php | 5 ++++- src/Watchers/ClientRequestWatcher.php | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/config/telescope.php b/config/telescope.php index 1c9438fc3..8937b8512 100644 --- a/config/telescope.php +++ b/config/telescope.php @@ -143,7 +143,10 @@ 'ignore' => [], ], - Watchers\ClientRequestWatcher::class => env('TELESCOPE_CLIENT_REQUEST_WATCHER', true), + Watchers\ClientRequestWatcher::class => [ + env('TELESCOPE_CLIENT_REQUEST_WATCHER', true), + 'ignore_hosts' => [], + ], Watchers\CommandWatcher::class => [ 'enabled' => env('TELESCOPE_COMMAND_WATCHER', true), diff --git a/src/Watchers/ClientRequestWatcher.php b/src/Watchers/ClientRequestWatcher.php index 00c61cda8..aa0b97089 100644 --- a/src/Watchers/ClientRequestWatcher.php +++ b/src/Watchers/ClientRequestWatcher.php @@ -57,7 +57,8 @@ public function recordFailedRequest(ConnectionFailed $event) */ public function recordResponse(ResponseReceived $event) { - if (! Telescope::isRecording()) { + if (! Telescope::isRecording()|| + $this->shouldIgnoreHosts($event)) { return; } @@ -76,6 +77,20 @@ public function recordResponse(ResponseReceived $event) ); } + /** + * Determine whether to ignore this request based on its host. + * + * @param mixed $event + * @return bool + */ + protected function shouldIgnoreHosts($event) + { + $host = $event->request->toPsrRequest()->getUri()->getHost(); + $ignoreHosts = Arr::get($this->options, 'ignore_hosts', []); + + return in_array($host, $ignoreHosts); + } + /** * Determine if the content is within the set limits. * From 2ee6ad4421a88ea3993c483707a2b1dfd115fc67 Mon Sep 17 00:00:00 2001 From: Artyom Osepyan Date: Tue, 21 Oct 2025 21:03:11 +0300 Subject: [PATCH 2/4] style: fix coding style --- src/Watchers/ClientRequestWatcher.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Watchers/ClientRequestWatcher.php b/src/Watchers/ClientRequestWatcher.php index aa0b97089..3266a9a1b 100644 --- a/src/Watchers/ClientRequestWatcher.php +++ b/src/Watchers/ClientRequestWatcher.php @@ -57,7 +57,7 @@ public function recordFailedRequest(ConnectionFailed $event) */ public function recordResponse(ResponseReceived $event) { - if (! Telescope::isRecording()|| + if (! Telescope::isRecording() || $this->shouldIgnoreHosts($event)) { return; } From 44c61e7e3a6d67f84c90b4b36131142046e32f76 Mon Sep 17 00:00:00 2001 From: Artyom Osepyan Date: Thu, 23 Oct 2025 17:14:02 +0300 Subject: [PATCH 3/4] refactor: add 'enabled' flag for ClientRequestWatcher configuration --- config/telescope.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/telescope.php b/config/telescope.php index 8937b8512..a241a348e 100644 --- a/config/telescope.php +++ b/config/telescope.php @@ -144,7 +144,7 @@ ], Watchers\ClientRequestWatcher::class => [ - env('TELESCOPE_CLIENT_REQUEST_WATCHER', true), + 'enabled' => env('TELESCOPE_CLIENT_REQUEST_WATCHER', true), 'ignore_hosts' => [], ], From 43dad55697152b6293d1295e8c1e49125282f552 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 23 Oct 2025 10:16:55 -0500 Subject: [PATCH 4/4] Update ClientRequestWatcher.php --- src/Watchers/ClientRequestWatcher.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Watchers/ClientRequestWatcher.php b/src/Watchers/ClientRequestWatcher.php index 3266a9a1b..9cffca4fb 100644 --- a/src/Watchers/ClientRequestWatcher.php +++ b/src/Watchers/ClientRequestWatcher.php @@ -58,7 +58,7 @@ public function recordFailedRequest(ConnectionFailed $event) public function recordResponse(ResponseReceived $event) { if (! Telescope::isRecording() || - $this->shouldIgnoreHosts($event)) { + $this->shouldIgnoreHost($event)) { return; } @@ -83,12 +83,11 @@ public function recordResponse(ResponseReceived $event) * @param mixed $event * @return bool */ - protected function shouldIgnoreHosts($event) + protected function shouldIgnoreHost($event) { $host = $event->request->toPsrRequest()->getUri()->getHost(); - $ignoreHosts = Arr::get($this->options, 'ignore_hosts', []); - return in_array($host, $ignoreHosts); + return in_array($host, Arr::get($this->options, 'ignore_hosts', [])); } /**