Skip to content

Commit

Permalink
Add support ignore request when status code specified
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Mazur committed Nov 24, 2021
1 parent 320b0d7 commit 3896ffb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/telescope.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
13 changes: 12 additions & 1 deletion src/Watchers/RequestWatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function register($app)
*/
public function recordRequest(RequestHandled $event)
{
if (! Telescope::isRecording()) {
if (! Telescope::isRecording() || $this->shouldIgnore($event)) {
return;
}

Expand Down Expand Up @@ -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'] ?? []);
}
}

0 comments on commit 3896ffb

Please sign in to comment.