Skip to content

Commit f646736

Browse files
authored
Run filterReportsCallable in better place
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
1 parent 213fa2c commit f646736

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/Flare.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,12 @@ public function report(Throwable $throwable, callable $callback = null): ?Report
206206

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

209+
if ($this->filterReportsCallable) {
210+
if (! call_user_func($this->filterReportsCallable, $report)) {
211+
return null;
212+
}
213+
}
214+
209215
if (! is_null($callback)) {
210216
call_user_func($callback, $report);
211217
}
@@ -236,6 +242,12 @@ public function reportMessage(string $message, string $logLevel, callable $callb
236242
{
237243
$report = $this->createReportFromMessage($message, $logLevel);
238244

245+
if ($this->filterReportsCallable) {
246+
if (! call_user_func($this->filterReportsCallable, $report)) {
247+
return null;
248+
}
249+
}
250+
239251
if (! is_null($callback)) {
240252
call_user_func($callback, $report);
241253
}
@@ -250,12 +262,6 @@ public function sendTestReport(Throwable $throwable)
250262

251263
private function sendReportToApi(Report $report)
252264
{
253-
if ($this->filterReportsCallable) {
254-
if (! call_user_func($this->filterReportsCallable, $report)) {
255-
return;
256-
}
257-
}
258-
259265
try {
260266
$this->api->report($report);
261267
} catch (Exception $exception) {

0 commit comments

Comments
 (0)