first commit

This commit is contained in:
Sampanna Rimal
2024-08-27 17:48:06 +05:45
commit 53c0140f58
10839 changed files with 1125847 additions and 0 deletions

View File

@ -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', $allContext);
}
return $report;
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace Spatie\LaravelIgnition\FlareMiddleware;
use Closure;
use Spatie\FlareClient\FlareMiddleware\FlareMiddleware;
use Spatie\FlareClient\Report;
use Spatie\LaravelIgnition\Recorders\DumpRecorder\DumpRecorder;
class AddDumps implements FlareMiddleware
{
protected DumpRecorder $dumpRecorder;
public function __construct()
{
$this->dumpRecorder = app(DumpRecorder::class);
}
public function handle(Report $report, Closure $next)
{
$report->group('dumps', $this->dumpRecorder->getDumps());
return $next($report);
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace Spatie\LaravelIgnition\FlareMiddleware;
use Closure;
use Spatie\FlareClient\FlareMiddleware\FlareMiddleware;
use Spatie\FlareClient\Report;
class AddEnvironmentInformation implements FlareMiddleware
{
public function handle(Report $report, Closure $next)
{
$report->frameworkVersion(app()->version());
$report->group('env', [
'laravel_version' => app()->version(),
'laravel_locale' => app()->getLocale(),
'laravel_config_cached' => app()->configurationIsCached(),
'app_debug' => config('app.debug'),
'app_env' => config('app.env'),
'php_version' => phpversion(),
]);
return $next($report);
}
}

View File

@ -0,0 +1,58 @@
<?php
namespace Spatie\LaravelIgnition\FlareMiddleware;
use Illuminate\Database\QueryException;
use Spatie\FlareClient\Contracts\ProvidesFlareContext;
use Spatie\FlareClient\FlareMiddleware\FlareMiddleware;
use Spatie\FlareClient\Report;
class AddExceptionInformation implements FlareMiddleware
{
public function handle(Report $report, $next)
{
$throwable = $report->getThrowable();
$this->addUserDefinedContext($report);
if (! $throwable instanceof QueryException) {
return $next($report);
}
$report->group('exception', [
'raw_sql' => $throwable->getSql(),
]);
return $next($report);
}
private function addUserDefinedContext(Report $report): void
{
$throwable = $report->getThrowable();
if ($throwable === null) {
return;
}
if ($throwable instanceof ProvidesFlareContext) {
// ProvidesFlareContext writes directly to context groups and is handled in the flare-client-php package.
return;
}
if (! method_exists($throwable, 'context')) {
return;
}
$context = $throwable->context();
if (! is_array($context)) {
return;
}
$exceptionContextGroup = [];
foreach ($context as $key => $value) {
$exceptionContextGroup[$key] = $value;
}
$report->group('exception', $exceptionContextGroup);
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace Spatie\LaravelIgnition\FlareMiddleware;
use Spatie\FlareClient\FlareMiddleware\FlareMiddleware;
use Spatie\FlareClient\Report;
use Spatie\LaravelIgnition\Recorders\JobRecorder\JobRecorder;
class AddJobs implements FlareMiddleware
{
protected JobRecorder $jobRecorder;
public function __construct()
{
$this->jobRecorder = app(JobRecorder::class);
}
public function handle(Report $report, $next)
{
if ($job = $this->jobRecorder->getJob()) {
$report->group('job', $job);
}
return $next($report);
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace Spatie\LaravelIgnition\FlareMiddleware;
use Spatie\FlareClient\FlareMiddleware\FlareMiddleware;
use Spatie\FlareClient\Report;
use Spatie\LaravelIgnition\Recorders\LogRecorder\LogRecorder;
class AddLogs implements FlareMiddleware
{
protected LogRecorder $logRecorder;
public function __construct()
{
$this->logRecorder = app(LogRecorder::class);
}
public function handle(Report $report, $next)
{
$report->group('logs', $this->logRecorder->getLogMessages());
return $next($report);
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace Spatie\LaravelIgnition\FlareMiddleware;
use Spatie\FlareClient\FlareMiddleware\FlareMiddleware;
use Spatie\FlareClient\Report;
class AddNotifierName implements FlareMiddleware
{
public const NOTIFIER_NAME = 'Laravel Client';
public function handle(Report $report, $next)
{
$report->notifierName(static::NOTIFIER_NAME);
return $next($report);
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace Spatie\LaravelIgnition\FlareMiddleware;
use Spatie\FlareClient\Report;
use Spatie\LaravelIgnition\Recorders\QueryRecorder\QueryRecorder;
class AddQueries
{
protected QueryRecorder $queryRecorder;
public function __construct()
{
$this->queryRecorder = app(QueryRecorder::class);
}
public function handle(Report $report, $next)
{
$report->group('queries', $this->queryRecorder->getQueries());
return $next($report);
}
}