syofyanzuhad / lumina-core
Core models, migrations, and shared logic for Lumina analytics.
Requires
- php: ^8.3
- filament/filament: ^5.7
- inertiajs/inertia-laravel: ^3.0
- jenssegers/agent: ^2.6
- laravel/chisel: ^0.1.0
- laravel/fortify: ^1.37.2
- laravel/framework: ^13.17
- laravel/nightwatch: ^1.28
- laravel/tinker: ^3.0
- laravel/wayfinder: ^0.1.14
- livewire/livewire: ^4.3
- lumina/core: @dev
Requires (Dev)
- fakerphp/faker: ^1.24
- larastan/larastan: ^3.9
- laravel/boost: ^2.2
- laravel/pail: ^1.2.5
- laravel/pao: ^1.1
- laravel/pint: ^1.27
- laravel/sail: ^1.53
- mockery/mockery: ^1.6
- nunomaduro/collision: ^8.9.3
- pestphp/pest: ^4.7
- pestphp/pest-plugin-laravel: ^4.1
This package is auto-updated.
Last update: 2026-08-17 02:04:25 UTC
README
Core package for Lumina web analytics. Provides models, migrations, server-side tracking middleware, JS ingestion collector,
AnalyticsServicequery engine, and embedded Livewire dashboard components.
๐ฆ Installation
Require lumina/core via Composer:
composer require lumina/core
Publish and run migrations:
php artisan vendor:publish --tag=lumina-core-migrations php artisan migrate
๐ ๏ธ Middleware & Tracking
Server-Side Middleware (Path A)
Track pageviews directly from your host application's HTTP requests:
use Lumina\Core\Middleware\TrackPageview; Route::middleware([TrackPageview::class])->group(function () { Route::get('/', [HomeController::class, 'index']); });
Client-Side JS Script (Path B)
Include the lightweight < 2KB vanilla script tag:
<script defer data-domain="yourdomain.com" src="https://your-lumina.com/js/script.js"></script>
Custom Event Tracking API
// Dispatch custom event to /api/collect window.lumina('event_name', { key: 'value' });
๐ AnalyticsService Query API
The Lumina\Core\Services\AnalyticsService class provides high-performance cached aggregation queries (60s default TTL):
use Lumina\Core\Services\AnalyticsService; $analytics = app(AnalyticsService::class); // Dashboard overview payload (Pageviews, Visitors, Referrers, Devices, OS, Browsers, Countries, Goals) $overview = $analytics->getOverview($site, $start, $end); // Enhanced Data Detection aggregations $topBrowsers = $analytics->getTopBrowsers($site, $start, $end, limit: 10); $topOS = $analytics->getTopOperatingSystems($site, $start, $end, limit: 10); $topCountries = $analytics->getTopCountries($site, $start, $end, limit: 10); // Custom Event tracking metrics $customEvents = $analytics->getCustomEvents($site, $start, $end); $propertyBreakdown = $analytics->getCustomEventPropertyBreakdown($site, 'signup_completed', 'plan', $start, $end); // Goal & Conversion calculation $goals = $analytics->getGoals($site, $start, $end);
๐ผ๏ธ Embedded Livewire Component
Embed the full Lumina analytics dashboard in your Blade layouts:
<livewire:lumina-dashboard :site="$site" />
๐งช Testing Package Core
Run package feature tests using Pest:
vendor/bin/pest packages/lumina-core/tests/
๐ License
MIT License.
๐งช Testing
The package test suite runs standalone with Orchestra Testbench against an in-memory SQLite database โ no host Laravel application required:
composer install
composer test
CI runs the same command on every push/PR (see .github/workflows/tests.yml).
The same test files also run inside the host monorepo via php artisan test: tests/TestCase.php binds to the host application when Testbench is absent, and to Testbench when run standalone.