This package allows you to integrate a simple analytics dashboard widget for panel.
You can install the package via composer:
composer require devlogx/filament-pirsch-dashboard-widget
Get the Pirsch access token and add it your env
file.
.env
file:# ...PIRSCH_CLIENT_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxPIRSCH_CLIENT_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
You can publish the config file with:
php artisan vendor:publish --tag="filament-pirsch-dashboard-widget-config"
Optionally, you can publish the translations using
php artisan vendor:publish --tag="filament-pirsch-dashboard-widget-translations"
This is the contents of the published config file:
return [ /* |-------------------------------------------------------------------------- | Pirsch Client id & Client secret |-------------------------------------------------------------------------- | | You can acquire your client id and secret id under | https://dashboard.pirsch.io/settings/integration | */ 'client_id' => env('PIRSCH_CLIENT_ID', null), 'client_secret' => env('PIRSCH_CLIENT_SECRET', null), /* |-------------------------------------------------------------------------- | Stats cache ttl |-------------------------------------------------------------------------- | | This value is the ttl for the displayed dashboard | stats values. You can increase or decrease | this value. | */ 'cache_time' => 300,];
Under Filament/Pages/
create a new file called Dashboard.php
with following contents:
<?php namespace App\Filament\Pages; use Devlogx\FilamentPirsch\Concerns\HasFilter; class Dashboard extends \Filament\Pages\Dashboard{ use HasFilter; }
->pages([ //Pages\Dashboard::class,])
Alternatively if you already have a custom Dashboard, add the HasFilter
trait to your Dashboard file.
->widgets([ Widgets\AccountWidget::class, Widgets\FilamentInfoWidget::class, \Devlogx\FilamentPirsch\Widgets\PirschStatsWidget::class,// <-- add this widget])
->plugins([ \Devlogx\FilamentPirsch\FilamentPirschPlugin::make()])
->plugins([ \Devlogx\FilamentPirsch\FilamentPirschPlugin::make() ->pirschLink(true) //Direct link to pirsch analytics page ->pollingInterval("60s") //Auto polling interval ->filterSectionIcon("heroicon-s-adjustments-vertical") ->filterSectionIconColor("primary") ->liveVisitorIcon("heroicon-s-user") //First Block | Live Visitors ->liveVisitorColor("primary") //First Block | Live Visitors ->visitorsIcon("heroicon-s-user-group") //Second Block | All Visitors ->visitorsColor("primary") //Second Block | All Visitors ->viewsIcom("heroicon-s-eye") //Third Block | All Page Views ->visitorsColor("primary") //Third Block | All Page Views ->sessionTimeIcon("heroicon-s-clock") //Fourth Block | Avg. Session Time ->sessionTimeColor("primary") //Fourth Block | Avg. Session Time])
You can use the functions for your own widgets. There are plenty more available.
public function getDashboardLink(): string{ return 'https://' . $this->client->getDomain()->subdomain . '.pirsch.io';}
use Devlogx\FilamentPirsch\Concerns\Filter;Â $filter = (new Filter()) ->setFrom(Carbon::now()->subDays(30)) ->setTo(Carbon::now()) ->setFromTime(Carbon::now()->startOfDay()) ->setToTime(Carbon::now()->endOfDay()) ->setScale(\Devlogx\FilamentPirsch\Enums\Scale::SCALE_DAY) // can be 'SCALE_DAY', 'SCALE_MONTH', 'SCALE_WEEK' or 'SCALE_YEAR' ->setEvent("name of event") ->setEventMetaKey("meta key");
use Devlogx\FilamentPirsch\Facades\FilamentPirsch;Â //Get active visitors$activeVisitors = FilamentPirsch::activeVisitors($filter,false);Â //Get avg session duration$sessionDuration = FilamentPirsch::sessionDuration($filter,false);Â //Get visitors$visitors = FilamentPirsch::visitors($filter,false);Â //Get page views$views = FilamentPirsch::views($filter,false);Â //Get avg time on page$timeOnPage = FilamentPirsch::timeOnPage($filter,false);Â //Get events$events = FilamentPirsch::events($filter,false);Â //Get event meta data$eventMetaData = FilamentPirsch::eventMetaData($filter,false);Â //Get languages$languages = FilamentPirsch::languages($filter,false);Â //Get referrer listed$referrer = FilamentPirsch::referrer($filter,false);Â //Get os listed$os = FilamentPirsch::os($filter,false);Â //Get platforms listed$platform = FilamentPirsch::platform($filter,false);Â //Get a list of used keywords$keywords = FilamentPirsch::keywords($filter,false);
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.
Develogix Agency, based in Austria, is a Fullstack web development firm specializing in the TALL stack and Filament. Known for delivering robust and efficient digital solutions, Develogix excels in creating intuitive and sophisticated web experiences tailored to diverse client needs.