syofyanzuhad/lumina-core

Core models, migrations, and shared logic for Lumina analytics.

Maintainers

Package info

github.com/syofyanzuhad/lumina-core

pkg:composer/syofyanzuhad/lumina-core

Transparency log

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-08-09 10:35 UTC

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, AnalyticsService query 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.