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. yared/laravel-activity-tracker

ActiveLibrary

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

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

1.0.0(2mo ago)00MITPHPPHP ^8.1

Since Mar 6Pushed 2mo 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 1mo 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

37

—

LowBetter than 82% of packages

Maintenance94

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

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

64d 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

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M683](/packages/barryvdh-laravel-ide-helper)[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[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.

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

API Platform support for Laravel

59126.4k5](/packages/api-platform-laravel)[dragon-code/migrate-db

Easy data transfer from one database to another

15717.4k](/packages/dragon-code-migrate-db)[label84/laravel-auth-log

Log user authentication actions in Laravel.

3654.0k](/packages/label84-laravel-auth-log)

PHPackages © 2026

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