Pular para o conteúdo
← Voltar para projetos

Filament Analytics Core

Shared base classes for jeffersongoncalves Filament analytics-injector plugins (script render-hook injection + optional Spatie settings page).

Filament Analytics Core

#Filament Analytics Core

Buy Me A Coffee

Latest Version on Packagist GitHub Code Style Action Status Total Downloads License

Shared base classes for the jeffersongoncalves Filament analytics-injector plugins (Fathom, GA4/gtag, GTM, Matomo, Mixpanel, Meta Pixel, Plausible, Umami). Built on top of filament-plugin-core.

#Version Compatibility

Branch Filament PHP Laravel
1.x 3.x ^8.2 ^11.0
2.x 4.x ^8.2 ^11.0
3.x 5.x ^8.2 ^11.0

#Requirements

  • PHP 8.2 or higher
  • Laravel 11.0 or higher
  • Filament 5.x (3.x branch)

#Installation

You can install the package via composer:

composer require jeffersongoncalves/filament-analytics-core:"^3.0"

#What it provides

  • AbstractAnalyticsPlugin — registers an optional settings page and exposes the settingsPage(bool) toggle. Subclass declares getId() and getSettingsPageClass().
  • AbstractAnalyticsServiceProvider — wires hasTranslations() and injects the tracking script(s) via render hooks. Subclass declares packageName() and renderHooks().

#Usage

#Plugin

use JeffersonGoncalves\FilamentAnalyticsCore\AbstractAnalyticsPlugin;

class FathomPlugin extends AbstractAnalyticsPlugin
{
    public function getId(): string
    {
        return 'filament-fathom';
    }

    protected function getSettingsPageClass(): ?string
    {
        return FathomSettingsPage::class;
    }
}

#Service Provider

use Filament\View\PanelsRenderHook;
use JeffersonGoncalves\FilamentAnalyticsCore\AbstractAnalyticsServiceProvider;

class FathomServiceProvider extends AbstractAnalyticsServiceProvider
{
    protected function packageName(): string
    {
        return 'filament-fathom';
    }

    protected function renderHooks(): array
    {
        return [
            PanelsRenderHook::HEAD_START => 'fathom::script',
        ];
    }
}

#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.

Nova versão disponível.