Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support ignore request when status code specified #1150

Merged
merged 1 commit into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'] ?? []);
}
}