laravel-personal-analytics
Single-project analytics integration for Laravel 13 and PostgreSQL. It deliberately contains no tenants, sites, billing or user management.
Install
Заголовок раздела «Install»composer require localzet/laravel-personal-analyticsphp artisan vendor:publish --tag=personal-analytics-configphp artisan migrateConfigure the collector and run a dedicated queue worker plus Laravel scheduler:
PERSONAL_ANALYTICS_TOKEN=replace-with-a-long-random-public-tokenPERSONAL_ANALYTICS_HOST=app.example.comPERSONAL_ANALYTICS_ORIGINS=https://app.example.comPERSONAL_ANALYTICS_DB_CONNECTION=pgsqlPERSONAL_ANALYTICS_QUEUE_CONNECTION=redisPERSONAL_ANALYTICS_QUEUE=analyticsPERSONAL_ANALYTICS_STORAGE_DISK=s3PERSONAL_ANALYTICS_MAX_PAYLOAD_BYTES=8388608PERSONAL_ANALYTICS_MAX_DECODED_PAYLOAD_BYTES=33554432PERSONAL_ANALYTICS_STORE_IP=falsephp artisan queue:work redis --queue=analyticsphp artisan schedule:workInstall @localzet/personal-analytics-tracker in the frontend and point endpoint to /api/analytics/collect. The public collector accepts bounded JSON batches and returns 202; queue jobs project visitor/session state and bulk-insert event facts.
The full analytics console is available at /admin/analytics. It includes overview charts, realtime activity, raw event drill-down, sessions, visitors, attribution, client errors, performance telemetry, playable rrweb replays, heatmaps, goals, funnels, ecommerce and pipeline health.
By default, the console is protected by the host application’s web and auth middleware. For a standalone token-protected console, use a separate random secret:
PERSONAL_ANALYTICS_ADMIN_AUTH_MODE=tokenPERSONAL_ANALYTICS_ADMIN_TOKEN=replace-with-a-separate-256-bit-secretPERSONAL_ANALYTICS_ADMIN_MIDDLEWARE=webNever reuse PERSONAL_ANALYTICS_TOKEN for admin access. It is a public ingestion identifier embedded in frontend JavaScript and cannot protect analytics data. Token mode sends the separate admin secret in the Authorization: Bearer header and retains it only in browser sessionStorage.
The browser tracker and Laravel package should be upgraded together. Tracker 0.2 compresses large replay and heatmap payloads before transport; Laravel 0.2 safely decompresses them with independent compressed and decoded size limits.
Replay rows reference compressed chunk files on PERSONAL_ANALYTICS_STORAGE_DISK. In containers, either use an S3-compatible disk or mount the selected local disk path as a persistent volume. Recreating a container with an ephemeral storage/app leaves database rows pointing to files that no longer exist; those historical recordings cannot be reconstructed.
Storage model
Заголовок раздела «Storage model»- PostgreSQL monthly partitions for raw events, with BRIN/B-tree/GIN indexes;
- visitor/session projections and daily multidimensional rollups;
- goals, conversions and configurable funnels;
- gzip replay chunks and heatmap DOM snapshots on any Laravel Filesystem disk;
- retention and future-partition maintenance via scheduled commands.
The collector never stores form/request bodies. Input values are masked by rrweb, sensitive property keys are redacted on both client and server, and IP persistence is disabled by default.
License
Заголовок раздела «License»Licensed under AGPL-3.0-or-later. Preserve the included NOTICE when redistributing the package.
Исходный код · AGPL-3.0