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
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', ], ], ]];
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
To restrict access to the Resource and Page publish the config and edit the config file or add the following to your .env file:
# enable access controlFILAMENT_USER_ACTIVITY_ACCESS_CONTROL_ENABLED=true# using Spaties - Roles & PermissionsFILAMENT_USER_ACTIVITY_SPATIE_PERMISSIONS_ACTIVE=trueFILAMENT_USER_ACTIVITY_SPATIE_PERMISSION="filament_user_activity.view" // the name of your permission default = 'filament_user_activity.view'# alternatively restrict access only to a list of specific emailsFILAMENT_USER_ACTIVITY_ALLOWED_EMAILS="admin@test.com, admin2@test.com"# or user_ids...FILAMENT_USER_ACTIVITY_ALLOWED_USER_IDS="1,2,3,4"
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.