entensy / filament-tracer
Filament Tracer is a versatile package to report exceptions and traces. Table schemas are compatible with any language of choice.
Requires
- php: ^8.1|^8.2|^8.3
- filament/filament: ^3.2
- illuminate/database: ^10.48|^11.19
- illuminate/support: ^10.48|^11.19
- spatie/laravel-ignition: ^2.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- illuminate/testing: ^10.29
- laravel/pint: ^1.13
- pestphp/pest: ^2.24.0
- phpunit/phpunit: ^10.4.0
README
Filament tracer is a flexible filament plugin to report and view exceptions and traces with a generic table schema to be able to store traces from other programming languages.
The purpose of this package is to have a common tables to report/log errors throughout your applications, independent of what programming language you use so long as your application has a connection to the database, you can store the traces then later view them in filament dashboard.
Installation
This plugin requires Filament v3.0+, it does not work in older version!
Install the package via composer:
composer require entensy/filament-tracer
You could also use direct repository url in your composer.json
:
"require": { "entensy/filament-tracer": "dev-main" } "repositories": [ { "type": "git", "url": "https://github.com/entensy/filament-tracer.git" } ]
Usage
Register the plugin in your desired filament panel:
public function panel(Panel $panel): Panel { return $panel ... ->plugins([ FilamentTracerPlugin::make() // You may define how you would like to get tab badge numbers, these must return int type ->tracesCounterUsing(fn($record) => count( explode(PHP_EOL, $record->traces) ) ?? 0) ->queriesCounterUsing(fn($record) => /** return int value */) ->bodyCounterUsing(fn($record) => /** return int value */) ->headersCounterUsing(fn($record) => /** return int value */) ->cookiesCounterUsing(fn($record) => /** return int value */) ]); }
To register capturing exceptions and errors, go to your
app\Exceptions\Handler.php
file and put the following snippet into register
method:
$this->reportable(function (Throwable $e) { if ($this->shouldReport($e)) { \Entensy\FilamentTracer\FilamentTracer::capture($e, request()); } });
Theme
You may change the palette colors in your Filament Panel Service Provider:
$panel ->colors([ 'danger' => Color::Rose, 'primary' => Color::Red, 'success' => Color::Green, 'warning' => Color::Yellow, 'gray' => Color::Gray, 'info' => Color::Blue, ])
Configuration
You may publish configuration using Laravel's publish command:
# Publish config file php artisan vendor:publish --tag=filament-tracer-config # Publish views php artisan vendor:publish --tag=filament-tracer-views # Publish translations php artisan vendor:publish --tag=filament-tracer-translations # Publish migrations php artisan vendor:publish --tag=filament-tracer-migrations
Custom Tracer Class
You may write your own tracer class by changing the default class in the plugin
config file. If you don't have this file, you may publish it with
php artisan vendor:publish --tag=filament-tracer-config
file:
[ ... // You may implement your own tracer by implementing Tracerable interface 'tracer' => \Entensy\FilamentTracer\DefaultTracer::class, ... ]
Defining a custom Tracer class has to implement Tracerable
interface.
use Entensy\FilamentTracer\Contracts\Tracerable; class MyCustomTracer implements Tracerable { // }
If you would like to change how an error being stored, you may overwrite this
implementation by implementing HasStore
interface in your custom tracer class
then add your implementation in store
method
use Entensy\FilamentTracer\Contracts\HasStore; use Entensy\FilamentTracer\Contracts\Tracerable; class MyCustomTracer implements Tracerable, HasStore { public function store(): mixed { $err = $this->getThrowable(): // just log the trace and don't store it in database logger()->error($err); return true; } }
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
Please email security@entensy.com
for any security issues.
Credits
License
This repository is under MIT License (MIT).