Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Nov 25, 2021
1 parent 3896ffb commit abc9660
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion config/telescope.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
28 changes: 16 additions & 12 deletions src/Watchers/RequestWatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

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

0 comments on commit abc9660

Please sign in to comment.