jeffersongoncalves / filament-metrics-posthog
Filament plugin with PostHog dashboard widgets (realtime visitors, visitors chart, top pages, sources, countries, browsers and devices) and a Settings Page powered by Spatie Laravel Settings.
Package info
github.com/jeffersongoncalves/filament-metrics-posthog
pkg:composer/jeffersongoncalves/filament-metrics-posthog
Requires
- php: ^8.2
- filament/filament: ^5.3
- jeffersongoncalves/filament-analytics-core: ^3.0
- jeffersongoncalves/laravel-metrics-posthog: ^1.0
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.0
- orchestra/testbench: ^9.0|^10.0|^11.0
- pestphp/pest: ^3.0|^4.0
- pestphp/pest-plugin-laravel: ^3.0|^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Filament Metrics PostHog
PostHog web analytics dashboard widgets for Filament, with a settings page powered by Spatie Laravel Settings to manage your PostHog personal API key, project ID and host directly from the admin panel. Works with PostHog Cloud (US/EU) and self-hosted instances.
Built on top of jeffersongoncalves/laravel-metrics-posthog (HogQL query API).
Compatibility
| Branch | Filament | Package version |
|---|---|---|
| 1.x | 3.x | ^1.0 |
| 2.x | 4.x | ^2.0 |
| 3.x | 5.x | ^3.0 |
Installation
You can install the package via composer:
composer require jeffersongoncalves/filament-metrics-posthog:"^3.0"
Publish the settings migrations and run them:
php artisan vendor:publish --tag=metrics-posthog-settings-migrations php artisan migrate
Usage
Add the plugin to your Filament panel provider:
use JeffersonGoncalves\Filament\MetricsPostHog\PostHogMetricsPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ PostHogMetricsPlugin::make(), ]); }
Then open Settings > PostHog in your panel and fill in a personal API key (with the query:read scope) and the project ID. Change the host under Advanced Settings for the EU cloud or a self-hosted instance.
Widgets
All widgets cover the last 30 days and are cached (15s for realtime, 5 minutes for the rest):
| Widget | Shows |
|---|---|
RealtimeVisitorsWidget |
Visitors in the last 5 minutes, unique visitors, pageviews, bounce rate and session duration |
VisitorsChartWidget |
Daily visitors and pageviews line chart |
TopPagesWidget |
Top 10 pages by visitors |
TopSourcesWidget |
Top 10 referring domains |
TopCountriesWidget |
Top 10 countries |
TopBrowsersWidget |
Browsers doughnut chart |
TopDevicesWidget |
Device types doughnut chart |
Customization
PostHogMetricsPlugin::make() ->settingsPage(false) // hide the settings page ->widgets(false), // don't register the dashboard widgets
With widgets(false) you can still place the widget classes on any page yourself.
Requirements
- PHP 8.2 or higher
- Filament 5.x
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
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.
