Skip to content

Commit

Permalink
Return output of filterReportsCallable
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 committed Aug 23, 2022
1 parent 213fa2c commit 45b9b2d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Flare.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,7 @@ public function report(Throwable $throwable, callable $callback = null): ?Report
call_user_func($callback, $report);
}

$this->sendReportToApi($report);

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

protected function shouldSendReport(Throwable $throwable): bool
Expand Down Expand Up @@ -240,7 +238,7 @@ public function reportMessage(string $message, string $logLevel, callable $callb
call_user_func($callback, $report);
}

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

public function sendTestReport(Throwable $throwable)
Expand All @@ -252,14 +250,17 @@ private function sendReportToApi(Report $report)
{
if ($this->filterReportsCallable) {
if (! call_user_func($this->filterReportsCallable, $report)) {
return;
return null;
}
}

try {
$this->api->report($report);
} catch (Exception $exception) {
return null;
}

return $report;
}

public function reset()
Expand Down

0 comments on commit 45b9b2d

Please sign in to comment.