PHPackages                             yared/laravel-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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. yared/laravel-activity-tracker

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

yared/laravel-activity-tracker
==============================

Advanced activity logging for Laravel with IP, browser, location, and model change tracking

1.0.0(3mo ago)00MITPHPPHP ^8.1

Since Mar 6Pushed 3mo agoCompare

[ Source](https://github.com/yared-ayele-debela/Laravel-Activity-Tracker)[ Packagist](https://packagist.org/packages/yared/laravel-activity-tracker)[ RSS](/packages/yared-laravel-activity-tracker/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

Yared Laravel Activity Tracker
==============================

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

Advanced activity logging for Laravel with IP, browser, location, device detection, and automatic model change tracking.

Features
--------

[](#features)

- **Rich activity data** — IP, browser, device, URL, location
- **Automatic model logging** — Track created, updated, deleted with `LogsActivity` trait
- **Model change detection** — Log what changed (e.g. "Price: 100 → 120")
- **Geolocation** — City and country from IP (via ip-api.com)
- **Activity timeline** — Query and display admin activity feed
- **Log cleanup** — `php artisan activity:clean` to remove old logs
- **Configurable** — Custom table name, location API, cleanup days

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

[](#installation)

```
composer require yared/laravel-activity-tracker
```

Publish config and run migrations:

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

Usage
-----

[](#usage)

### Manual Tracking

[](#manual-tracking)

```
use Yared\ActivityTracker\Facades\Activity;

// In a controller
Activity::track(auth()->user(), "created order #2001");

// With extra properties
Activity::track(auth()->user(), "exported report", [
    'format' => 'pdf',
    'rows' => 150,
]);
```

### Automatic Model Logging

[](#automatic-model-logging)

Add the trait to any model:

```
use Illuminate\Database\Eloquent\Model;
use Yared\ActivityTracker\Traits\LogsActivity;

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

Now every create, update, and delete is logged automatically. Updates include what changed:

```
{
  "changes": {
    "status": ["pending", "shipped"],
    "price": [100, 120]
  }
}
```

### Activity Timeline

[](#activity-timeline)

```
use Yared\ActivityTracker\Models\ActivityLog;

// Latest activities
$activities = ActivityLog::latest()->take(50)->get();

// For a specific user
$activities = ActivityLog::forUser($userId)->latest()->get();

// Last 7 days
$activities = ActivityLog::recent(7)->get();
```

### Clean Old Logs

[](#clean-old-logs)

```
# Use config value (default: 90 days)
php artisan activity:clean

# Custom days
php artisan activity:clean --days=30
```

Example Output
--------------

[](#example-output)

```
User 5 created order #2001
IP: 192.168.1.1
Browser: Chrome
Device: Linux Desktop
Location: Venice, IT
URL: /orders

```

Configuration
-------------

[](#configuration)

Edit `config/activity.php`:

KeyDescription`table`Database table name`location_enabled`Fetch location from IP`location_api_url`IP geolocation API`cleanup_days`Default days for `activity:clean` (0 = disabled)`track_requests`Log every request when using middlewareMiddleware (Optional)
---------------------

[](#middleware-optional)

To log every API request, register the middleware:

```
// app/Http/Kernel.php
protected $middlewareAliases = [
    'activity.track' => \Yared\ActivityTracker\Middleware\TrackRequest::class,
];
```

Then enable in config: `'track_requests' => true` and apply to routes.

License
-------

[](#license)

MIT

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance79

Regular maintenance activity

Popularity0

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

Unknown

Total

1

Last Release

109d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5727fb2630a34a7641505a6a706230943683ed204aa0fa244343ae5622f61872?d=identicon)[yared-ayele-debela](/maintainers/yared-ayele-debela)

---

Top Contributors

[![yared-ayele-debela](https://avatars.githubusercontent.com/u/112660399?v=4)](https://github.com/yared-ayele-debela "yared-ayele-debela (1 commits)")

---

Tags

activity-trackerlaravellaravel-packagephp

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

87411.3M152](/packages/spatie-laravel-health)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)

PHPackages © 2026

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