Skip to content

Commit

Permalink
Merge pull request #184 from spatie/support-context
Browse files Browse the repository at this point in the history
[Draft] Add support for context
  • Loading branch information
freekmurze authored Mar 28, 2024
2 parents c9f8d05 + f16cafd commit 60b1d67
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"ext-mbstring": "*",
"illuminate/support": "^10.0|^11.0",
"spatie/flare-client-php": "^1.3.5",
"spatie/ignition": "^1.9",
"spatie/ignition": "^1.13",
"symfony/console": "^6.2.3|^7.0",
"symfony/var-dumper": "^6.2.3|^7.0"
},
Expand Down
2 changes: 2 additions & 0 deletions config/flare.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Spatie\LaravelIgnition\FlareMiddleware\AddJobs;
use Spatie\LaravelIgnition\FlareMiddleware\AddLogs;
use Spatie\LaravelIgnition\FlareMiddleware\AddQueries;
use Spatie\LaravelIgnition\FlareMiddleware\AddContext;
use Spatie\LaravelIgnition\FlareMiddleware\AddNotifierName;

return [
Expand Down Expand Up @@ -53,6 +54,7 @@
AddJobs::class => [
'max_chained_job_reporting_depth' => 5,
],
AddContext::class,
CensorRequestBodyFields::class => [
'censor_fields' => [
'password',
Expand Down
27 changes: 27 additions & 0 deletions src/FlareMiddleware/AddContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Spatie\LaravelIgnition\FlareMiddleware;

use Closure;
use Illuminate\Log\Context\Repository;
use Illuminate\Support\Facades\Context;
use Spatie\FlareClient\FlareMiddleware\FlareMiddleware;
use Spatie\FlareClient\Report;

class AddContext implements FlareMiddleware
{
public function handle(Report $report, Closure $next)
{
if (! class_exists(Repository::class)) {
return $report;
}

$allContext = Context::all();

if (count($allContext)) {
$report->group('laravel_context', Context::all());
}

return $report;
}
}

0 comments on commit 60b1d67

Please sign in to comment.