nowendwell/app-analytics

Track your Laravel application usage

0.2.1 2025-02-26 16:16 UTC

This package is auto-updated.

Last update: 2025-02-26 16:16:55 UTC


README

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

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.