PHPackages                             heccubernny/activity-tracker - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. heccubernny/activity-tracker

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

heccubernny/activity-tracker
============================

A lightweight Laravel package to track user and model activities

v1.0.2(11mo ago)02MITPHPPHP &gt;=8.0

Since Sep 20Pushed 11mo agoCompare

[ Source](https://github.com/Heccubernny/laravel-user-activity-tracker)[ Packagist](https://packagist.org/packages/heccubernny/activity-tracker)[ RSS](/packages/heccubernny-activity-tracker/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (1)Versions (4)Used By (0)

Laravel User Activity Tracker
=============================

[](#laravel-user-activity-tracker)

> ⚠️ **Note:** This package is currently in development and not yet production-ready. Some bugs and issues may still exist. Use at your own risk.

A lightweight Laravel package to track user and model activities for web and API applications.

This package allows you to automatically track model events (created, updated, deleted) and route visits, as well as manually log custom activities. It supports both **JWT-based API authentication** and **web session authentication**.

---

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

[](#installation)

Install via Composer:

```
composer require heccubernny/activity-tracker
```

Publish configuration and migrations:

```
php artisan vendor:publish --provider="Heccubernny\ActivityTracker\ActivityServiceProvider" --tag="activitytracker-config"

php artisan vendor:publish --provider="Heccubernny\ActivityTracker\ActivityServiceProvider" --tag="activitytracker-migrations"

php artisan migrate
```

Middleware Setup
----------------

[](#middleware-setup)

Register the middleware in `app/Http/Kernel.php`:

```
protected $routeMiddleware = [
    // ...
    'activity.log' => \Heccubernny\ActivityTracker\Middleware\LogRouteActivity::class,
];
```

Apply middleware to routes:

```
Route::get('/dashboard', function () {
    // ...
})->middleware('activity.log:visited-dashboard');
```

You can optionally pass a subject (model) to associate with the activity:

```
Route::get('/posts/{post}', function (App\Models\Post $post) {
    // ...
})->middleware(\Heccubernny\ActivityTracker\Middleware\LogRouteActivity::class.':view-post,' . $post->id);
```

Automatic Model Logging
-----------------------

[](#automatic-model-logging)

Add the `LogsActivity` trait to any model you want to track:

```
use Heccubernny\ActivityTracker\Traits\LogsActivity;

class Post extends Model
{
    use LogsActivity;
}
```

By default, it tracks:

- created
- updated
- deleted

and logs:

- subject\_id
- subject\_type
- user\_id
- user\_type
- description
- properties (full model attributes)
- ip\_address, url, method, agent

Manual Logging
--------------

[](#manual-logging)

Use the `activity()` facade for custom events:

```
activity()->log([
    'name' => 'exported-report',
    'description' => 'User exported the monthly sales report',
    'properties' => ['report' => 'monthly-sales'],
    // Optional: user_id, user_type, subject_id, subject_type
]);
```

or directly on a model

```
$post->logActivity('published', ['description' => 'Published via admin panel']);
```

Configuration (Optional)
------------------------

[](#configuration-optional)

You can set the activity retention in your `.env`:

```
ACTIVITY_RETENTION_DAYS=null
```

- `null` keeps logs forever.
- Set to a number of days to automatically purge old logs.

Example Usage
-------------

[](#example-usage)

Manual logging:

```
activity()->log([
    'name' => 'exported-report',
    'description' => 'User exported the monthly sales report',
    'properties' => ['report' => 'monthly-sales'],
]);
```

Automatic model logging:

```
$post = Post::find(1);
$post->logActivity('published', ['description' => 'Published via admin panel']);
```

Route-based logging:

```
Route::get('/dashboard', function () {
    // ...
})->middleware('activity.log:visited-dashboard');
```

### Credits

[](#credits)

Special thanks to [Nuno Maduro](https://github.com/nunomaduro) for his [dry repository](https://github.com/nunomaduro/dry) it was the skeleton inspiration.

License: MIT

###  Health Score

27

—

LowBetter than 46% of packages

Maintenance52

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

3

Last Release

331d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/42838142?v=4)[Paul Oladayo](/maintainers/heccubernny)[@Heccubernny](https://github.com/Heccubernny)

---

Top Contributors

[![Heccubernny](https://avatars.githubusercontent.com/u/42838142?v=4)](https://github.com/Heccubernny "Heccubernny (3 commits)")

### Embed Badge

![Health badge](/badges/heccubernny-activity-tracker/health.svg)

```
[![Health](https://phpackages.com/badges/heccubernny-activity-tracker/health.svg)](https://phpackages.com/packages/heccubernny-activity-tracker)
```

###  Alternatives

[illuminate/pagination

The Illuminate Pagination package.

12234.6M1.1k](/packages/illuminate-pagination)[illuminate/pipeline

The Illuminate Pipeline package.

9350.2M311](/packages/illuminate-pipeline)[illuminate/redis

The Illuminate Redis package.

8314.8M410](/packages/illuminate-redis)[illuminate/cookie

The Illuminate Cookie package.

224.7M146](/packages/illuminate-cookie)[forjedio/inertia-table

Backend-driven dynamic tables for Laravel + Inertia.js

272.0k](/packages/forjedio-inertia-table)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

265.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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