Skip to content

Commit

Permalink
Run filterReportsCallable in better place
Browse files Browse the repository at this point in the history
Current code will populate Flare::sentReports() even if it's filtered since the return from sendReportToApi() is not used:

$this->sendReportToApi($report);
return $report;

This is a regression from #33
  • Loading branch information
Jellyfrog authored Aug 23, 2022
1 parent 213fa2c commit f646736
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/Flare.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ public function report(Throwable $throwable, callable $callback = null): ?Report

$report = $this->createReport($throwable);

if ($this->filterReportsCallable) {
if (! call_user_func($this->filterReportsCallable, $report)) {
return null;
}
}

if (! is_null($callback)) {
call_user_func($callback, $report);
}
Expand Down Expand Up @@ -236,6 +242,12 @@ public function reportMessage(string $message, string $logLevel, callable $callb
{
$report = $this->createReportFromMessage($message, $logLevel);

if ($this->filterReportsCallable) {
if (! call_user_func($this->filterReportsCallable, $report)) {
return null;
}
}

if (! is_null($callback)) {
call_user_func($callback, $report);
}
Expand All @@ -250,12 +262,6 @@ public function sendTestReport(Throwable $throwable)

private function sendReportToApi(Report $report)
{
if ($this->filterReportsCallable) {
if (! call_user_func($this->filterReportsCallable, $report)) {
return;
}
}

try {
$this->api->report($report);
} catch (Exception $exception) {
Expand Down

0 comments on commit f646736

Please sign in to comment.