Skip to content

Commit

Permalink
Add support for report filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
Jellyfrog committed Aug 4, 2022
1 parent 88aed95 commit 8fd7c9c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Flare.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class Flare

/** @var callable|null */
protected $filterExceptionsCallable;

/** @var callable|null */
protected $filterReportsCallable;

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

public function filterReportsUsing(callable $filterReportsCallable)
{
$this->filterReportsCallable = $filterReportsCallable;
}

/**
* @return null|string
*/
Expand Down Expand Up @@ -242,6 +250,12 @@ 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 8fd7c9c

Please sign in to comment.