Saltar al contenido
← Volver a proyectos

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.

Versión: v3 v4 v5 · branch: 3.x

Filament Metrics PostHog

#Filament Metrics PostHog

Buy Me A Coffee

Latest Version on Packagist Tests Total Downloads License

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.

Nueva versión disponible.