From eafa1561f6b1f32716373b6d28ad98574249f622 Mon Sep 17 00:00:00 2001 From: Philip Iezzi Date: Thu, 23 May 2024 13:00:13 +0200 Subject: [PATCH] Prefix path with `/` Update README with more ignore patterns, make FourXxRecorder section easier to copy-paste --- README.md | 48 +++++++++++++++++------------------------- src/FourXxRecorder.php | 3 ++- 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 88e87cd..75db4cc 100644 --- a/README.md +++ b/README.md @@ -21,17 +21,24 @@ composer require morrislaptop/laravel-pulse-4xx Add the `FourXxRecorder` to the `config/pulse.php` file. -```diff +```php return [ // ... + 'recorders' => [ -+ \Morrislaptop\LaravelPulse4xx\FourXxRecorder::class => [ -+ 'enabled' => env('PULSE_4XX_ENABLED', true), -+ 'sample_rate' => env('PULSE_4XX_SAMPLE_RATE', 1), -+ 'ignore' => [ -+ '#^/wp-admin#', // Classic WordPress... -+ ], -+ ], + Morrislaptop\LaravelPulse4xx\FourXxRecorder::class => [ + 'enabled' => env('PULSE_4XX_ENABLED', true), + 'sample_rate' => env('PULSE_4XX_SAMPLE_RATE', 1), + 'ignore' => [ + '#^/wp-admin#', // Classic WordPress... + '#^/wp-login#', + '#^/wp-config#', + '#^/xmlrpc\.php#', + '#^/browserconfig\.xml#', // Microsoft junk + ], + ], + + // ... ] ] ``` @@ -44,30 +51,13 @@ To add the card to the Pulse dashboard, you must first [publish the vendor view] php artisan vendor:publish --tag=pulse-dashboard ``` -Then, you can modify the `dashboard.blade.php` file: +Then, add the card to your `resources/views/vendor/pulse/dashboard.php`: -```diff +```blade -+ - - - - - - - - - - - - - - - - - - + + ``` diff --git a/src/FourXxRecorder.php b/src/FourXxRecorder.php index c5ba8b8..033d1c1 100755 --- a/src/FourXxRecorder.php +++ b/src/FourXxRecorder.php @@ -7,6 +7,7 @@ use Illuminate\Contracts\Http\Kernel; use Illuminate\Http\Request; use Illuminate\Support\Carbon; +use Illuminate\Support\Str; use Laravel\Pulse\Concerns\ConfiguresAfterResolving; use Laravel\Pulse\Pulse; use Laravel\Pulse\Recorders\Concerns; @@ -46,7 +47,7 @@ public function record(Carbon $startedAt, Request $request, Response $response): return; } - $path = $request->path(); + $path = Str::start($request->path(), '/'); if ($this->shouldIgnore($path)) { return;