Skip to content

Commit

Permalink
Merge pull request #33 from Jellyfrog/patch-1
Browse files Browse the repository at this point in the history
Add support for report filtering
  • Loading branch information
AlexVanderbist committed Aug 9, 2022
2 parents 88aed95 + 8fd7c9c commit 0e653f8
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 0e653f8

Please sign in to comment.