edwink / filament-user-activity
Tracks user activity and shows currently active users
Fund package maintenance!
edwink
Installs: 7 366
Dependents: 0
Suggesters: 0
Security: 0
Stars: 15
Watchers: 1
Forks: 6
Open Issues: 1
Requires
- php: ^8.1
- filament/filament: ^3.0
- illuminate/contracts: ^10.0|^11.0
- spatie/laravel-package-tools: ^1.15.0
Requires (Dev)
- nunomaduro/collision: ^7.9
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
Conflicts
README
Registers all requests and displays it conveniently to see currently online users, ie. with any requests in the last 15 minutes / 30 minutes / 60 minutes / day / week
Installation
You can install the package via composer:
composer require edwink/filament-user-activity
You can publish and run the migrations with:
php artisan vendor:publish --tag="filament-user-activity-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="filament-user-activity-config"
Optionally, you can publish the views using
php artisan vendor:publish --tag="filament-user-activity-views"
This is the contents of the published config file:
return [ "table" => [ "name" => env("FILAMENT_USER_ACTIVITY_TABLE_NAME", "user_activities"), "retention-days" => env("FILAMENT_USER_ACTIVITY_RETENTION_DAYS", 60), 'active-users' => [ 'timeframe-selection' => [ 15 => '15 Minutes', 30 => '30 Minutes', 60 => 'One hour', 120 => '2 Hours', 1440 => '24 hours', ], ], ] ];
Usage
Add Global Middleware in app/Http/Kernel.php
/** * The application's global HTTP middleware stack. * * These middleware are run during every request to your application. * * @var array<int, class-string|string> */ protected $middleware = [ ... \Edwink\FilamentUserActivity\Http\Middleware\RecordUserActivity::class, ];
Add trait to User Model app/Models/User.php
to add relationship activities
use Edwink\FilamentUserActivity\Traits\UserActivityTrait; ... class User extends Authenticatable { use UserActivityTrait; ... }
Configure your panel to have 2 additional views
use Edwink\FilamentUserActivity\FilamentUserActivityPlugin; ... public function panel(Panel $panel): Panel { return $panel ... ->plugins([ FilamentUserActivityPlugin::make() ]) ... } ...
Configure a scheduled task to truncate table depending on your configured days (default 60 days) or run it manually from time to time.
php artisan filament-user-activity:truncate-activities-table
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.