nowendwell / app-analytics
Track your Laravel application usage
Fund package maintenance!
nowendwell
Requires
- php: ^8.3
- illuminate/contracts: ^10.0||^11.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9||^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^2.0||^3.0
- pestphp/pest-plugin-arch: ^2.0||^3.0
- pestphp/pest-plugin-laravel: ^2.0||^3.0
- phpstan/extension-installer: ^1.3||^2.0
- phpstan/phpstan-deprecation-rules: ^1.1||^2.0
- phpstan/phpstan-phpunit: ^1.3||^2.0
README
Track usage analytics for your Laravel application.
Installation
You can install the package via composer:
composer require nowendwell/app-analytics
You can publish the config file with:
php artisan vendor:publish --tag="app-analytics-config"
You can publish and run the migrations with:
php artisan vendor:publish --tag="app-analytics-migrations"
php artisan migrate
Usage
Simply add the included middleware \Nowendwell\AppAnalytics\Middleware\TrackAnalyticsMiddleware
to your Http Kernel middleware list and let the package do the rest.
protected $middlewareGroups = [ 'web' => [ // ... \Nowendwell\AppAnalytics\Middleware\TrackAnalyticsMiddleware::class, ],
If you want to keep track of your own custom events, outside of the default page view tracking, you can use the TrackEvent
facade.
use Nowendwell\AppAnalytics\Facades\AppAnalytics; class InvoicePaymentController extends Controller { public function store(Invoice $invoice): RedirectResponse { // Track a custom event AppAnalytics::event('Invoice Paid', ['invoice_id' => 123, 'amount' => 1000]); return response()->redirect(route('invoices.show', $invoice)); } }
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.