edrisranjbar / filament-product-analytics
Laravel SaaS product analytics with a Filament-native dashboard.
Package info
github.com/edrisranjbar/filament-product-analytics
pkg:composer/edrisranjbar/filament-product-analytics
Requires
- php: ^8.2
- laravel/framework: ^12.0|^13.0
Requires (Dev)
- filament/filament: ^5.0
- orchestra/testbench: ^10.0
- phpunit/phpunit: ^11.5
Suggests
- filament/filament: Required for the Filament dashboard integration (^4.0|^5.0).
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-09 10:17:10 UTC
README
Product usage analytics inside your Laravel SaaS admin panel. Store events in your own database, associate them with users and tenants, and explore usage without adding a hosted analytics service.
Public beta. MIT licensed. The free package includes tracking, a dashboard, and an event explorer with date and event filters. Release notes · Revenue plan · Planned Pro edition
Screenshots
Install
Install the free beta from Packagist:
composer require edrisranjbar/filament-product-analytics:0.2.0-beta.1 php artisan vendor:publish --tag=product-analytics-migrations php artisan migrate
Use Laravel 12 or 13. Install Filament 4 or 5 in the host application before registering the plugin. Compatibility is exercised by the repository's CI matrix; consult its results for each combination.
use EdrisRanjbar\FilamentProductAnalytics\FilamentProductAnalyticsPlugin; public function panel(\Filament\Panel $panel): \Filament\Panel { return $panel->plugin(FilamentProductAnalyticsPlugin::make()); }
Required authorization
Both pages are denied by default. Define the viewProductAnalytics gate in your application's service provider using your actual permissions:
use App\Models\User; use Illuminate\Support\Facades\Gate; Gate::define('viewProductAnalytics', function (User $user): bool { return $user->is_admin; // Replace with your app's existing authorization rule. });
In a Filament tenant panel, all dashboard and explorer queries are restricted to the current tenant's model type and ID, and membership is checked on every query. A missing tenant returns no events. A non-tenant panel shows application-wide analytics to gate-authorized users; reserve it for your internal administrators. The user model must implement Filament's normal panel and tenant access contracts.
Track events
analytics('dashboard.viewed'); analytics()->track('invoice.paid', ['amount' => 9900, 'plan' => 'pro']); analytics()->for($user)->tenant($team)->track('report.exported', ['format' => 'pdf']);
Authenticated actors and the current Filament tenant are resolved automatically when available. Explicit context overrides resolution. A null context currently falls back to automatic resolution; disable the corresponding config option when anonymous tracking is required. Scalar IDs use the type scalar; for Filament tenant isolation, pass the tenant model instead.
Event names contain 1–191 characters. Properties accept JSON-compatible arrays and scalar values, not objects or resources. Sensitive keys in the configured list are removed recursively and case-insensitively before queue dispatch. This is a key denylist, not a guarantee that arbitrary personal data or secrets in free text will be removed. Send only the fields you need.
Queue
Queued persistence is enabled by default and uses Laravel's configured connection. With a sync connection it executes immediately. For asynchronous persistence, configure a queue and run its worker:
PRODUCT_ANALYTICS_QUEUE=true PRODUCT_ANALYTICS_QUEUE_CONNECTION=database PRODUCT_ANALYTICS_QUEUE_NAME=analytics
php artisan queue:work --queue=analytics
Set PRODUCT_ANALYTICS_QUEUE=false for direct persistence. Retries of the same event UUID are idempotent. Calling track() twice generates two distinct events. Tracking/storage failures propagate; applications decide how to handle unavailable infrastructure. Dispatch after your business transaction commits when events depend on committed records.
Dashboard and explorer
- Total events: all time, within the authorized tenant scope.
- Active users and tenants: distinct type/ID pairs over the last rolling 30 days.
- Top events: the same 30-day window.
- Recent activity: the latest 15 events.
- Event explorer: 25 rows per page, inclusive calendar dates in the application timezone, and an optional exact event-name filter. Defaults to the last 30 calendar days. Properties are escaped and expandable.
Publish configuration with php artisan vendor:publish --tag=product-analytics-config. A custom event model must retain the package schema and casts; both reads and writes use that model's table and connection.
Development
composer install
composer test
Tests use Orchestra Testbench and SQLite locally. CI also exercises MySQL and PostgreSQL and multiple framework versions. See verification and demo setup.
Beta boundaries
No automatic resource tracking, funnels, retention/cohorts, scheduled reports, or revenue calculations yet. Database retention and cleanup are managed by the host application. Start with selected business events; high-volume performance has not been benchmarked. The package makes no claim of compatibility beyond the tested matrix.
Planned Pro edition
This version is completely free. A separate Pro extension is planned, with crypto payments once the paid features and checkout are ready. No payment is required for this beta, and Pro is not yet on sale. Tell us which paid workflow you need.