PHPackages                             topoff/laravel-user-logger - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. topoff/laravel-user-logger

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

topoff/laravel-user-logger
==========================

Laravel User Logger

v10.5.1(6d ago)06.7k↓29.2%MITPHPPHP ^8.4CI passing

Since Nov 8Pushed 6d ago2 watchersCompare

[ Source](https://github.com/topoff/laravel-user-logger)[ Packagist](https://packagist.org/packages/topoff/laravel-user-logger)[ Docs](https://github.com/topoff/laravel-user-logger)[ RSS](/packages/topoff-laravel-user-logger/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (67)Versions (83)Used By (0)

Laravel User Logger
===================

[](#laravel-user-logger)

[![Latest Stable Version](https://camo.githubusercontent.com/4dd709b9ce235c22355994727bd3068791710befcd34e39d1edf3930eb544ce6/68747470733a2f2f706f7365722e707567782e6f72672f746f706f66662f6c61726176656c2d757365722d6c6f676765722f762f737461626c65)](https://packagist.org/packages/topoff/laravel-user-logger)[![Latest Unstable Version](https://camo.githubusercontent.com/01de38d350923bca750ac5ab5add3dbff92977ffe08c8937fe32d9b9e35a3ba1/68747470733a2f2f706f7365722e707567782e6f72672f746f706f66662f6c61726176656c2d757365722d6c6f676765722f762f756e737461626c65)](https://packagist.org/packages/topoff/laravel-user-logger)[![License](https://camo.githubusercontent.com/6149db7eed7df82f8f6849a24532bb7d5e0a1c9c5dece3f1d49be50e835d1bb4/68747470733a2f2f706f7365722e707567782e6f72672f746f706f66662f6c61726176656c2d757365722d6c6f676765722f6c6963656e7365)](https://packagist.org/packages/topoff/laravel-user-logger)[![Total Downloads](https://camo.githubusercontent.com/044141301763be0765e8f68fd658cf2663c0b17b70d5ec73d58ca6d91642b5ab/68747470733a2f2f706f7365722e707567782e6f72672f746f706f66662f6c61726176656c2d757365722d6c6f676765722f646f776e6c6f616473)](https://packagist.org/packages/topoff/laravel-user-logger)

Laravel User Logger with Pennant-based experiment measurement.

Requirements
------------

[](#requirements)

- Laravel
- `laravel/pennant`

Installation
------------

[](#installation)

Using Composer is currently the only supported way to install this package.

```
composer require topoff/laravel-user-logger
```

Getting started
---------------

[](#getting-started)

Publish the package config:

```
php artisan vendor:publish --tag=config
```

If you want to, create a dedicated `user-logger` database connection in `config/database.php`:

```
        'user-logger' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => 'userlogger',
            'username' => env('DB_USERNAME', ''),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],
```

Run migrations:

```
php artisan migrate
```

Set up Pennant (required for experiment variant storage/resolution):

```
php artisan vendor:publish --provider="Laravel\Pennant\PennantServiceProvider"
```

Then set the Pennant DB connection to your user-logger connection in `config/pennant.php`:

```
'stores' => [
    'database' => [
        'driver' => 'database',
        'connection' => 'user-logger',
        'table' => 'features',
    ],
],
```

Run migrations again so the Pennant `features` table is created:

```
php artisan migrate
```

Experiments
-----------

[](#experiments)

Experiment measurement uses `laravel/pennant`. Configure tracked features in `config/user-logger.php`:

```
'experiments' => [
    'enabled' => true,
    'features' => [
        'landing-page-headline',
        'checkout-flow',
    ],
    'conversion_events' => [
        'conversion',
    ],
    'conversion_entity_types' => [],
    'nova' => [
        'enabled' => true,
    ],
    'pennant' => [
        'store' => 'user-logger',
        'connection' => 'user-logger',
        'table' => 'pennant_features',
        'auto_install' => true,
        'scope' => 'session',
    ],
],
```

Pennant storage is installed by this package via migrations on the `user-logger` connection (`pennant_features` table).
This makes feature resolutions shareable across multiple apps that point to the same `user-logger` database. With `auto_install=true` (default), the package also creates the Pennant table automatically at boot if it is missing.

The package only registers its own named Pennant store (`user-logger` by default). Your app's default `database` store is left untouched - point your own features at whatever store you like in `config/pennant.php`.

Flush all measured experiment data (asks for confirmation, use `--force` to skip):

```
php artisan user-logger:flush
```

Nova
----

[](#nova)

When Nova is installed and `experiments.nova.enabled` is `true`, the package auto-registers the `ExperimentMeasurement` Nova resource.

If your app defines a fully custom `Nova::mainMenu(...)`, you must also add the resource manually in that menu.

Testing
-------

[](#testing)

```
composer test
```

Performance Profiling
---------------------

[](#performance-profiling)

You can enable runtime profiling logs in `config/user-logger.php`:

```
'performance' => [
    'enabled' => true,
    'log_queries' => true,
    'slow_ms' => 500,
    'sample_rate' => 1.0,      // fraction of requests that persist a row
    'retention_days' => 30,    // used by model:prune, 0 disables pruning
],
```

When enabled, the package logs:

- total request duration (`request_duration_ms`) - server-side time until response
- user-logger boot duration (`boot_duration_ms`)
- user-logger internal segment timings (`user_logger.segments`)
- optional query counters (`queries_total`, `queries_user_logger`)
- skip reason (`skip_reason`) when logging is bypassed

Slow request warnings can be emitted with `slow_ms` (set `0` to disable warnings). Slow-request warnings are always emitted, regardless of `sample_rate`.

Privacy &amp; Data Retention
----------------------------

[](#privacy--data-retention)

- Client ips are pseudonymized by default with a keyed HMAC-SHA256 (key: `user-logger.ip_salt`, falls back to `app.key`). Use `php artisan user-logger:haship` to compute the stored value for a given ip. Note this is pseudonymization, not anonymization.
- Set `hash_ip` to `false` to store ips in plain text instead. In that case you should configure `retention.ip_days` and schedule `php artisan user-logger:prune-ips` - it removes the stored ip from sessions older than the retention period while keeping the sessions themselves:

```
Schedule::command('user-logger:prune-ips')->daily();
```

- Logs, sessions and performance logs can be pruned via Laravel's `model:prune`. Configure `retention.logs_days`, `retention.sessions_days` and `performance.retention_days` (all default to disabled except performance logs), then schedule for example:

```
Schedule::command('model:prune', [
    '--model' => [
        \Topoff\LaravelUserLogger\Models\Log::class,
        \Topoff\LaravelUserLogger\Models\Session::class,
        \Topoff\LaravelUserLogger\Models\PerformanceLog::class,
    ],
])->daily();
```

Sessions are only pruned once they have no remaining logs, so logs should use an equal or shorter retention than sessions.

Host Header Caution
-------------------

[](#host-header-caution)

The `domains` table is keyed by `Request::getHost()`. Make sure your web server or Laravel's `TrustHosts` middleware restricts allowed hosts, otherwise spoofed Host headers create unbounded rows.

Testing the logger in a host app
--------------------------------

[](#testing-the-logger-in-a-host-app)

The logger is disabled in the `testing` environment by default. Set `user-logger.enabled_in_testing` to `true` (plus `enabled`) in tests that want to exercise it.

User-Agent Parsing Performance
------------------------------

[](#user-agent-parsing-performance)

`matomo/device-detector` supports cache-backed parsing:

```
'user_agent' => [
    'cache' => true,
],
```

- `cache`: uses Laravel's default cache store to speed up parser internals.

The package automatically skips DeviceDetector bot matching when the request was already classified as a crawler via `CrawlerDetect`.

Referer Database
----------------

[](#referer-database)

Referer detection uses the snowplow referer-parser matching logic, but the bundled database (`resources/data/referers.json`) is generated from the actively maintained [matomo/searchengine-and-social-list](https://github.com/matomo-org/searchengine-and-social-list)definitions - including search engines (with keyword parameters), social networks and AI assistants (medium `ai`: ChatGPT, Claude, Gemini, ...). Email provider entries are carried over from the snowplow database.

The data refreshes itself on three levels:

- A scheduled GitHub Action (`.github/workflows/update-referers.yml`) runs monthly, regenerates the database and - only when it changed - commits, tags the next patch release and pushes. Requires "Read and write permissions" for Actions in the repository settings.
- Every `composer update` in this package repository regenerates the file automatically (`post-update-cmd`); commit the diff if there is one.
- Manually: `composer update-referers` (updates the matomo list and regenerates in one step).

A custom database (snowplow json format) can be configured via `user-logger.referer_data_path`.

###  Health Score

62

—

FairBetter than 99% of packages

Maintenance99

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity96

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 89.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~39 days

Recently: every ~1 days

Total

82

Last Release

6d ago

Major Versions

v5.7 → v6.22024-05-15

v6.2 → v7.0.02026-02-12

v7.0.1 → v8.0.02026-02-19

v8.3.7 → v9.0.02026-05-26

v9.0.0 → v10.0.02026-06-12

PHP version history (8 changes)v0.0.1PHP &gt;=5.3.7

v0.1PHP &gt;=7.0

v0.12.0PHP &gt;=7.2

v2.0.0PHP &gt;=7.3

v3.0.0PHP ^7.4|^8.0

v4.0.0PHP ^8.0

v7.0.0PHP ^8.3

v9.0.0PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/f1546327b4f6a5440d3a984bf6e3bb771f70d61b244ad2f224f1638c570549b3?d=identicon)[topoff](/maintainers/topoff)

---

Top Contributors

[![ndberg](https://avatars.githubusercontent.com/u/13345669?v=4)](https://github.com/ndberg "ndberg (78 commits)")[![topoff-old](https://avatars.githubusercontent.com/u/26787140?v=4)](https://github.com/topoff-old "topoff-old (9 commits)")

---

Tags

laravel user logger

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/topoff-laravel-user-logger/health.svg)

```
[![Health](https://phpackages.com/badges/topoff-laravel-user-logger/health.svg)](https://phpackages.com/packages/topoff-laravel-user-logger)
```

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[illuminate/queue

The Illuminate Queue package.

21332.6M1.6k](/packages/illuminate-queue)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k91.9k1](/packages/mike-bronner-laravel-model-caching)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)[api-platform/laravel

API Platform support for Laravel

58171.8k14](/packages/api-platform-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
