Skip to content

Commit 0e653f8

Browse files
Merge pull request #33 from Jellyfrog/patch-1
Add support for report filtering
2 parents 88aed95 + 8fd7c9c commit 0e653f8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Flare.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ class Flare
5858

5959
/** @var callable|null */
6060
protected $filterExceptionsCallable;
61+
62+
/** @var callable|null */
63+
protected $filterReportsCallable;
6164

6265
public static function register(string $apiKey, string $apiSecret = null, ContextDetectorInterface $contextDetector = null, Container $container = null)
6366
{
@@ -81,6 +84,11 @@ public function filterExceptionsUsing(callable $filterExceptionsCallable)
8184
$this->filterExceptionsCallable = $filterExceptionsCallable;
8285
}
8386

87+
public function filterReportsUsing(callable $filterReportsCallable)
88+
{
89+
$this->filterReportsCallable = $filterReportsCallable;
90+
}
91+
8492
/**
8593
* @return null|string
8694
*/
@@ -242,6 +250,12 @@ public function sendTestReport(Throwable $throwable)
242250

243251
private function sendReportToApi(Report $report)
244252
{
253+
if ($this->filterReportsCallable) {
254+
if (! call_user_func($this->filterReportsCallable, $report)) {
255+
return;
256+
}
257+
}
258+
245259
try {
246260
$this->api->report($report);
247261
} catch (Exception $exception) {

0 commit comments

Comments
 (0)