### Install Project Dependencies Source: https://github.com/mradder/filament-logger/blob/main/CONTRIBUTING.md Installs the necessary dependencies for the project using Composer and npm. ```bash composer install npm install ``` -------------------------------- ### Configure All Alert Settings and Rules Source: https://github.com/mradder/filament-logger/blob/main/docs/custom-events.md A comprehensive configuration example showing enabled alerts, cache store, mail recipients, webhook URLs for Slack and Discord, and detailed rules for various activities. ```php 'alerts' => [ 'enabled' => true, 'cache_store' => 'redis', 'mail' => [ 'to' => ['security@example.com'], ], 'slack' => [ 'webhook_url' => 'https://hooks.slack.com/services/...', ], 'discord' => [ 'webhook_url' => 'https://discord.com/api/webhooks/...', ], 'rules' => [ 'destructive_activity' => [ 'channels' => ['mail', 'slack', 'discord'], 'events' => ['Deleted', 'Force Deleted'], 'cooldown_minutes' => 10, ], 'role_changes' => [ 'channels' => ['mail'], 'risk_reasons' => ['role_change'], 'cooldown_minutes' => 15, ], 'failed_login_spike' => [ 'type' => 'threshold', 'log_names' => ['Access'], 'events' => ['Failed Login'], 'threshold' => 5, 'window_minutes' => 10, 'cooldown_minutes' => 15, ], ], ], ``` -------------------------------- ### Example: Log Panel Auth Events from Web Guard Source: https://github.com/mradder/filament-logger/blob/main/README.md This example demonstrates how to configure Filament Logger to log only authentication events originating from the 'web' guard, suitable for applications with separate Filament panels and storefronts. ```php 'access' => [ // Log only panel auth events from the web guard. 'guards' => ['web'], ] ``` -------------------------------- ### Install Filament Logger Package Source: https://github.com/mradder/filament-logger/blob/main/docs/installation.md Use Composer to install the filament-logger package. Ensure your project meets the specified PHP and Filament version requirements. ```bash composer require mradder/filament-logger ``` -------------------------------- ### Example Export Metadata Header Source: https://github.com/mradder/filament-logger/blob/main/docs/configuration.md This JSON object represents the content of the X-Activity-Export-Metadata header. It provides details about the export, including timestamps, user information, included columns, applied filters, and the source resource. ```json { "exported_at": "2026-05-26T12:00:00+00:00", "exported_by": 1, "exported_by_name": "alice@example.com", "columns": ["id","description","tags","created_at"], "filters": {"log_name":"Access","date_preset":"last_7_days","search":"email"}, "source": "MrAdder\FilamentLogger\Resources\ActivityResource" } ``` -------------------------------- ### Publish Config and Migrations Source: https://github.com/mradder/filament-logger/blob/main/docs/installation.md Run this Artisan command to publish the package's configuration file and the Spatie Activitylog migration stub. This sets up the necessary files for customization and database integration. ```bash php artisan filament-logger:install ``` -------------------------------- ### Publish Config and Run Migrations Source: https://github.com/mradder/filament-logger/blob/main/README.md Publish the package's configuration files and run the necessary database migrations using Artisan commands. This sets up the package's database tables and configuration. ```bash php artisan filament-logger:install php artisan migrate ``` -------------------------------- ### Useful Project Commands Source: https://github.com/mradder/filament-logger/blob/main/CONTRIBUTING.md Provides common commands for validating the composer configuration, running tests, performing static analysis, and building documentation. ```bash composer validate --strict ``` ```bash vendor/bin/pest ``` ```bash vendor/bin/phpstan analyse --memory-limit=512M ``` ```bash npm run docs:build ``` -------------------------------- ### Run Database Migrations Source: https://github.com/mradder/filament-logger/blob/main/docs/installation.md Execute this command to apply the published migrations to your database, creating the necessary tables for logging activities. ```bash php artisan migrate ``` -------------------------------- ### Configure Slack Webhook for Alerts Source: https://github.com/mradder/filament-logger/blob/main/docs/custom-events.md Set up a Slack incoming webhook URL in your `.env` file and reference it in the Filament Logger configuration for sending alerts. ```dotenv FILAMENT_LOGGER_SLACK_WEBHOOK_URL=https://hooks.slack.com/services/... ``` ```php 'alerts' => [ 'enabled' => true, 'slack' => [ 'webhook_url' => env('FILAMENT_LOGGER_SLACK_WEBHOOK_URL'), ], ], ``` -------------------------------- ### Configure Resource Model Event Logging Source: https://github.com/mradder/filament-logger/blob/main/docs/configuration.md Enable or disable resource observers and specify attributes to ignore globally, per model, or per Filament resource. ```php 'resources' => [ 'enabled' => true, 'ignore' => ['updated_at', 'remember_token'], 'ignore_for_models' => [ App\Models\User::class => ['last_seen_at', 'login_count'], ], 'ignore_for_resources' => [ App\Filament\Resources\UserResource::class => ['last_seen_at', 'login_count'], ], ], ``` -------------------------------- ### Configure Discord Webhook for Alerts Source: https://github.com/mradder/filament-logger/blob/main/docs/custom-events.md Provide your Discord webhook URL in the `.env` file and configure it within the Filament Logger settings to enable Discord alerts. ```dotenv FILAMENT_LOGGER_DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/... ``` ```php 'alerts' => [ 'enabled' => true, 'discord' => [ 'webhook_url' => env('FILAMENT_LOGGER_DISCORD_WEBHOOK_URL'), ], ], ``` -------------------------------- ### Configure Access Event Logging by Guard Source: https://github.com/mradder/filament-logger/blob/main/README.md Set the 'access.guards' configuration to an array of guard names to log access events only from those specified guards. The default is null, logging events from all guards. ```php 'access' => [ // ... 'guards' => ['web'], ] ``` -------------------------------- ### Select Delivery Channels for Alert Rules Source: https://github.com/mradder/filament-logger/blob/main/docs/custom-events.md Specify the delivery channels (mail, slack, discord) for each alert rule. Ensure that any referenced channel is also configured. ```php 'alerts' => [ 'rules' => [ 'destructive_activity' => [ 'channels' => ['mail', 'slack', 'discord'], ], ], ], ``` -------------------------------- ### Custom Playbook Configuration Source: https://github.com/mradder/filament-logger/blob/main/docs/activity-review.md Add custom playbooks to the 'activity_playbooks' configuration to define specific review workflows. ```php 'activity_playbooks' => [ 'sensitive_changes_last_24h' => [ 'label' => 'Sensitive Changes (24h)', 'icon' => 'heroicon-o-key', 'preset' => 'high_risk', 'date_preset' => 'last_24_hours', ], ], ``` -------------------------------- ### Dashboard Widgets Configuration Source: https://github.com/mradder/filament-logger/blob/main/docs/activity-review.md Enable and configure dashboard widgets for spotting activity spikes and risky behavior. Set the lookback period in days and the top limit for displayed items. ```php 'dashboard' => [ 'enabled' => true, 'lookback_days' => 30, 'top_limit' => 5, ], ``` -------------------------------- ### Register Activity Resource in Filament Panel Source: https://github.com/mradder/filament-logger/blob/main/docs/installation.md Add the Activity resource to your Filament panel configuration. This makes the activity log accessible within your Filament admin interface. Ensure the resource path is correctly configured. ```php use Filament\Panel; public function panel(Panel $panel): Panel { return $panel ->resources([ config('filament-logger.activity_resource'), ]); } ``` -------------------------------- ### Define Custom Log Names and Colors Source: https://github.com/mradder/filament-logger/blob/main/docs/configuration.md Create custom log names and assign colors to them for better organization and visual distinction in logs. This also includes settings for custom events. ```php 'custom' => [ [ 'log_name' => 'Security', 'color' => 'danger', ], ], 'custom_events' => [ 'default_log_name' => 'Custom', 'color' => 'primary', ], ``` -------------------------------- ### Configure Access Event Logging Source: https://github.com/mradder/filament-logger/blob/main/docs/configuration.md Enable or disable specific authentication events like login, logout, and failed attempts. This configuration is applied per event. ```php 'access' => [ 'events' => [ 'login' => true, 'logout' => true, 'failed' => true, 'lockout' => true, 'password_reset' => true, 'two_factor_recovery' => true, ], ], ``` -------------------------------- ### Default Pruning Configuration Source: https://github.com/mradder/filament-logger/blob/main/docs/activity-review.md Set default pruning behavior in the configuration file. ```php 'pruning' => [ 'days' => 365, 'only' => [], 'except' => [], ], ``` -------------------------------- ### Configure Diff Formatting for Activity Details Source: https://github.com/mradder/filament-logger/blob/main/docs/configuration.md Adjust how large values are displayed in the activity detail page's structured diff view. Options include collapsing after a certain length and pretty-printing JSON. ```php 'diff' => [ 'collapse_after' => 120, 'pretty_print_json' => true, ], ``` -------------------------------- ### Configure Additional Eloquent Model Logging Source: https://github.com/mradder/filament-logger/blob/main/docs/configuration.md Register and configure logging for Eloquent models not managed by Filament resources. Specify models to register and attributes to ignore for specific models. ```php 'models' => [ 'enabled' => true, 'register' => [ App\Models\User::class, ], 'ignore' => ['updated_at', 'remember_token'], 'ignore_for' => [ App\Models\User::class => ['last_seen_at', 'login_count'], ], ], ``` -------------------------------- ### Configure Mail Settings for Alerts Source: https://github.com/mradder/filament-logger/blob/main/docs/custom-events.md Configure Laravel's mailer in `.env` and specify recipient email addresses for alert notifications in the package configuration. ```dotenv MAIL_MAILER=smtp MAIL_HOST=smtp.example.com MAIL_PORT=587 MAIL_USERNAME=mailer@example.com MAIL_PASSWORD=secret MAIL_ENCRYPTION=tls MAIL_FROM_ADDRESS="audit@example.com" MAIL_FROM_NAME="Filament Logger" ``` ```php 'alerts' => [ 'enabled' => true, 'mail' => [ 'to' => [ 'security@example.com', 'ops@example.com', ], ], ], ``` -------------------------------- ### Publish Filament Logger Translations Source: https://github.com/mradder/filament-logger/blob/main/docs/installation.md Use this command to publish the translation files for the filament-logger package. This allows for customization of the package's language strings. ```bash php artisan vendor:publish --tag="filament-logger-translations" ``` -------------------------------- ### Schedule Pruning Command Source: https://github.com/mradder/filament-logger/blob/main/docs/activity-review.md Add the filament-logger:prune command to your application's scheduler for daily execution. ```php use Illuminate\Support\Facades\Schedule; Schedule::command('filament-logger:prune')->daily(); ``` -------------------------------- ### Activity Filters Configuration Source: https://github.com/mradder/filament-logger/blob/main/docs/activity-review.md Configure saved filters and date presets for the activity list. This allows users to quickly access specific sets of activity logs based on predefined criteria like risk level, event type, or log names. ```php 'activity_filters' => [ 'date_presets' => [ 'today' => 'Today', 'last_24_hours' => 'Last 24 Hours', 'last_7_days' => 'Last 7 Days', 'last_30_days' => 'Last 30 Days', 'this_month' => 'This Month', ], 'saved' => [ 'high_risk' => [ 'label' => 'High Risk', 'icon' => 'heroicon-o-shield-exclamation', 'risk' => ['high'], ], 'destructive' => [ 'label' => 'Deletes', 'icon' => 'heroicon-o-trash', 'events' => ['Deleted', 'Force Deleted'], ], 'auth_issues' => [ 'label' => 'Auth Issues', 'icon' => 'heroicon-o-lock-closed', 'log_names' => ['Access'], 'events' => ['Failed Login', 'Lockout'], ], 'failed_logins' => [ 'label' => 'Failed Logins', 'icon' => 'heroicon-o-exclamation-triangle', 'log_names' => ['Access'], 'events' => ['Failed Login'], 'date_preset' => 'last_7_days', ], 'destructive_recent' => [ 'label' => 'Recent Destructive', 'icon' => 'heroicon-o-fire', 'events' => ['Deleted', 'Force Deleted'], 'date_preset' => 'last_7_days', ], 'auth_anomalies' => [ 'label' => 'Auth Anomalies', 'icon' => 'heroicon-o-finger-print', 'log_names' => ['Access'], 'events' => ['Failed Login', 'Lockout', 'Two Factor Recovery'], 'date_preset' => 'last_30_days', ], ], ], ``` -------------------------------- ### IP Address Redaction Configuration Source: https://github.com/mradder/filament-logger/blob/main/docs/security.md Configure IP address handling to store full IPs but redact them for unauthorized viewers. This provides flexibility for privileged reviewers while masking IPs for general users. ```php 'access' => [ 'store_ip' => true, 'anonymize_ip' => false, 'redact_ip_for_unauthorized_viewers' => true, ], ``` -------------------------------- ### Configure Sensitive Key Redaction Source: https://github.com/mradder/filament-logger/blob/main/docs/configuration.md Define a placeholder for redacted sensitive keys and extend the list of keys to be redacted across various log outputs. This applies recursively. ```php 'redacted_placeholder' => '[REDACTED]', 'sensitive_keys' => [ 'password', 'api_token', 'client_secret', 'webhook_url', 'authorization', 'ip_address', ], ``` -------------------------------- ### Investigation Playbooks Configuration Source: https://github.com/mradder/filament-logger/blob/main/docs/activity-review.md Define investigation playbooks that bundle saved tab presets with optional date presets for one-click review paths. This helps streamline the process of investigating specific types of activity. ```php 'activity_playbooks' => [ 'all_activity' => [ 'label' => 'All Activity', 'icon' => 'heroicon-o-bars-3-bottom-left', 'preset' => 'all', ], 'high_risk_incidents' => [ 'label' => 'High Risk Incidents', 'icon' => 'heroicon-o-shield-exclamation', 'preset' => 'high_risk', 'date_preset' => 'last_30_days', ], 'auth_anomalies' => [ 'label' => 'Auth Anomalies', 'icon' => 'heroicon-o-finger-print', 'preset' => 'auth_anomalies', 'date_preset' => 'last_30_days', ], 'failed_logins' => [ 'label' => 'Failed Logins', 'icon' => 'heroicon-o-exclamation-triangle', 'preset' => 'failed_logins', 'date_preset' => 'last_7_days', ], 'destructive_actions' => [ 'label' => 'Destructive Actions', 'icon' => 'heroicon-o-fire', 'preset' => 'destructive_recent', 'date_preset' => 'last_7_days', ], ], ``` -------------------------------- ### Configure Alert Throttling for Sensitive Activity Source: https://github.com/mradder/filament-logger/blob/main/docs/configuration.md Throttle sensitive activity alerts per rule to reduce noise from repeated matching events. Specify the cache store and cooldown period in minutes. ```php 'alerts' => [ 'cache_store' => 'redis', 'rules' => [ 'destructive_activity' => [ 'events' => ['Deleted', 'Force Deleted'], 'cooldown_minutes' => 10, ], ], ], ``` -------------------------------- ### Scope Access Logging by Guard Source: https://github.com/mradder/filament-logger/blob/main/docs/configuration.md In multi-guard applications, filter access logging to specific guards. This applies to events with a 'guard' property. ```php 'access' => [ 'guards' => ['web'], ], ``` -------------------------------- ### Deep-Link to Filtered Activity Source: https://github.com/mradder/filament-logger/blob/main/docs/activity-review.md Construct deep links to directly access filtered views of the Activity resource. ```text /admin/activity-logs?activeTab=high_risk&tableFilters[created_at][preset]=last_30_days ``` -------------------------------- ### Export Configuration Source: https://github.com/mradder/filament-logger/blob/main/docs/activity-review.md Customize export settings for audit data, including enabling exports, setting the chunk size for processing, and defining the columns to be included in CSV and JSON exports. ```php 'exports' => [ 'enabled' => true, 'chunk_size' => 500, 'columns' => [ 'id', 'log_name', 'event', 'description', 'subject_type', 'subject_id', 'causer_type', 'causer_id', 'causer_name', 'risk', 'tags', 'properties', 'created_at', ], ], ``` -------------------------------- ### Prune Activity Records Source: https://github.com/mradder/filament-logger/blob/main/docs/activity-review.md Use the filament-logger:prune artisan command to remove old activity records. ```bash php artisan filament-logger:prune ``` ```bash php artisan filament-logger:prune --days=90 ``` ```bash php artisan filament-logger:prune --days=90 --log-name=Access --log-name=Resource ``` ```bash php artisan filament-logger:prune --days=90 --except-log-name=Notification ``` ```bash php artisan filament-logger:prune --dry-run ``` -------------------------------- ### Register Activity Policy Source: https://github.com/mradder/filament-logger/blob/main/docs/security.md Register your custom ActivityPolicy in the AuthServiceProvider to enforce strict authorization for activity logs. This ensures that access to activity logs is controlled by defined policies. ```php ActivityPolicy::class, ]; } ``` -------------------------------- ### Log a Custom Event Source: https://github.com/mradder/filament-logger/blob/main/docs/custom-events.md Log domain-specific events using the `FilamentLogger::log` method. This allows for custom log names, subjects, causals, properties, tags, risk levels, and timestamps. ```php use MrAdder\FilamentLogger\Facades\FilamentLogger; FilamentLogger::log( event: 'Role Escalated', description: 'Elevated user privileges for incident response', options: [ 'logName' => 'Security', 'causer' => auth()->user(), 'subject' => $user, 'properties' => [ 'old' => ['role' => 'editor'], 'attributes' => ['role' => 'admin'], 'ticket' => 'SEC-42', ], 'tags' => ['security', 'roles'], ], ); ``` -------------------------------- ### Configure IP Address Redaction for Unauthorized Viewers Source: https://github.com/mradder/filament-logger/blob/main/docs/configuration.md Control whether IP addresses are redacted for users who do not pass a specific sensitive-data policy ability. This can be configured alongside general IP storage settings. ```php 'authorization' => [ 'sensitive_ability' => 'viewSensitiveData', ], 'access' => [ 'store_ip' => true, 'anonymize_ip' => false, 'redact_ip_for_unauthorized_viewers' => true, ], ``` -------------------------------- ### Configure Risk Tagging for High-Risk Activity Source: https://github.com/mradder/filament-logger/blob/main/docs/configuration.md Automatically tag high-risk activity based on specific events or changes to sensitive keys like roles or permissions. This helps identify potentially dangerous actions. ```php 'risk' => [ 'high' => [ 'events' => [ 'Deleted', 'Force Deleted', 'Failed Login', 'Lockout', ], 'change_keys' => [ 'role', 'role_id', 'roles', 'permission', 'permissions', ], ], ], ``` -------------------------------- ### Custom Sensitive Data Ability Name Source: https://github.com/mradder/filament-logger/blob/main/docs/security.md If you wish to use a different ability name for viewing sensitive data than the default `viewSensitiveData`, you can configure it in the activitylog configuration. ```php 'authorization' => [ 'sensitive_ability' => 'viewAuditSecrets', ], ``` -------------------------------- ### Disable Strict Authorization Source: https://github.com/mradder/filament-logger/blob/main/docs/security.md If you need the legacy behavior where authorization is more permissive, you can disable strict mode in the activitylog configuration file. ```php 'authorization' => [ 'strict' => false, ], ``` -------------------------------- ### Default Privacy Configuration Overrides Source: https://github.com/mradder/filament-logger/blob/main/docs/security.md Override default privacy settings for sensitive data redaction, IP address handling, user agent trimming, and notification logging. This allows fine-grained control over what information is logged and how it is protected. ```php 'redacted_placeholder' => '[REDACTED]', 'sensitive_keys' => [ 'password', 'api_token', 'client_secret', 'webhook_url', 'authorization', 'ip_address', ], 'authorization' => [ 'sensitive_ability' => 'viewSensitiveData', ], 'access' => [ 'store_ip' => true, 'anonymize_ip' => true, 'redact_ip_for_unauthorized_viewers' => false, 'store_user_agent' => true, 'user_agent_max_length' => 255, ], 'notifications' => [ 'log_recipient' => false, 'mask_recipient' => true, ], ``` -------------------------------- ### Grant Sensitive Data Visibility Source: https://github.com/mradder/filament-logger/blob/main/docs/security.md Add a `viewSensitiveData` ability to your activity policy to grant trusted reviewers access to stored sensitive values. This ability is automatically respected by the activity detail view, property sections, and exports. ```php isAdmin(); } public function view(User $user, Activity $activity): bool { return $user->isAdmin(); } public function viewSensitiveData(User $user, Activity $activity): bool { return $user->can('activity.view-sensitive'); } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.