simplestats-io/filament-plugin
Official Filament v5 plugin for SimpleStats.io. View analytics inside your Filament panel: visitors, registrations, revenue, top sources, and countries. PHP 8.2+, Laravel 12+. Configure via API token with optional caching and navigation settings.
Install the package:
composer require simplestats-io/filament-plugin
Add API token to .env:
SIMPLESTATS_API_TOKEN=your_api_token_here
Register the plugin in your PanelProvider:
public function panel(Panel $panel): Panel
{
return $panel
->plugin(SimplestatsPlugin::make());
}
Access the dashboard at /admin/simplestats (or your Filament panel path + /simplestats).
Plugin Registration Customize navigation and appearance:
SimplestatsPlugin::make()
->navigationGroup('Analytics')
->navigationLabel('Business Stats')
->navigationIcon('heroicon-o-chart-pie')
->cacheTtl(300); // 5-minute cache
Self-Hosted Integration Override API URL for private instances:
SimplestatsPlugin::make()
->apiUrl('https://your-simplestats.com/api/v1');
Dynamic Widget Usage Reuse widgets in custom Filament pages:
use SimpleStatsIo\FilamentPlugin\Widgets\StatsOverview;
public function getWidgets(): array
{
return [
StatsOverview::class,
// Other widgets...
];
}
cacheTtl to balance freshness vs. API calls (e.g., 60 for 1-minute updates)..env for tokens/URLs to avoid hardcoding:
SIMPLESTATS_API_URL=https://custom-api.example.com
SIMPLESTATS_API_TOKEN=${SIMPLESTATS_TOKEN}
API Token Errors
401 Unauthorized..env token and check SimpleStats.io for token validity.cacheTtl=0) to rule out stale responses.Navigation Missing
PanelProvider.->plugin(SimplestatsPlugin::make()) is called in panel() method.Chart Data Stale
cacheTtl or clear cache:
php artisan cache:clear
APP_DEBUG=true) to inspect HTTP requests.StatsOverview) in isolation to identify misbehaving components.// Example: Compare "This Month" vs. "Last Month"
SimplestatsPlugin::make()->enableComparison();
Custom Metrics Extend the plugin by adding new widgets. Example:
// app/Filament/Widgets/CustomMetric.php
use SimpleStatsIo\FilamentPlugin\Widgets\BaseWidget;
class CustomMetric extends BaseWidget {
protected static string $view = 'filament.simplestats.custom-metric';
// ...
}
Override Views Publish and modify views:
php artisan vendor:publish --tag="simplestats-filament-views"
Then edit resources/views/vendor/filament/simplestats/....
API Response Hooks Intercept responses via a service provider:
public function boot()
{
SimpleStatsIo\FilamentPlugin\Services\ApiClient::macro('beforeRequest', function ($request) {
// Modify request/response (e.g., add headers)
});
}
cacheTtl=0): Disables caching entirely; useful for development but impacts performance.navigationSort(1) for top priority)./api/v1 to match the plugin’s expectations.How can I help you explore Laravel packages today?