PHPackages                             94dikshaverma/laravel-login-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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. 94dikshaverma/laravel-login-tracker

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

94dikshaverma/laravel-login-tracker
===================================

Automatic login activity tracking, device fingerprinting, and new-device alerts for Laravel applications.

v1.0.0(today)02↑2900%MITPHPPHP ^8.1CI passing

Since Aug 6Pushed todayCompare

[ Source](https://github.com/94dikshaverma/laravel-login-tracker)[ Packagist](https://packagist.org/packages/94dikshaverma/laravel-login-tracker)[ RSS](/packages/94dikshaverma-laravel-login-tracker/feed)WikiDiscussions main Synced today

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

Laravel Login Tracker
=====================

[](#laravel-login-tracker)

Automatic login activity tracking, device fingerprinting, and new-device alerts for Laravel applications — no listeners to write yourself.

[![Tests](https://github.com/94dikshaverma/laravel-login-tracker/actions/workflows/tests.yml/badge.svg)](https://github.com/94dikshaverma/laravel-login-tracker/actions)

Features
--------

[](#features)

- Records every `Login`, `Logout`, and `Failed` auth event automatically — nothing to wire up.
- Captures IP address (proxy-aware), device type, browser, browser version, and platform.
- `HasLoginActivity` trait for querying a user's login history like any Eloquent relation.
- Detects logins from a new device and sends a queued notification.
- Configurable retention with a `login-tracker:prune` command (and `model:prune` support).
- Never stores passwords. IP anonymization and configurable failed-attempt storage for privacy/GDPR.

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

[](#requirements)

- PHP 8.1+
- Laravel 10.x, 11.x, or 12.x

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

[](#installation)

```
composer require 94dikshaverma/laravel-login-tracker
php artisan migrate
```

That's it — login activity is now being recorded. The migration is loaded automatically; publish it only if you want to customize the schema.

Usage
-----

[](#usage)

Add the trait to your `User` model:

```
use LoginTracker\Concerns\HasLoginActivity;

class User extends Authenticatable
{
    use HasLoginActivity;
}
```

Query login history:

```
$user->loginActivities; // newest first
$user->lastLoginAt();
$user->lastLoginIp();

LoginActivity::failed()->fromIp('203.0.113.4')->get();
LoginActivity::successful()->between(now()->subWeek(), now())->get();
```

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

[](#configuration)

Publish the config file:

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

Key options in `config/login-tracker.php`:

KeyDescription`events.*`Enable/disable tracking for `login`, `logout`, `failed``store_unknown_failed_attempts`Store failed logins for emails that don't match a user (`user_id` will be `null`)`new_device_detection.strategy``user_agent` (default) or `user_agent_and_ip_subnet``new_device_detection.skip_first_login`Don't alert on a user's first-ever login (default `true`)`notifications.class`Override the notification class`notifications.channels`Notification channels (default `['mail']`)`geoip.driver``null` (no location), `http` (free IP lookup), or custom `GeoIpDriver` class`geoip.http.*`HTTP GeoIP endpoint / timeout / response keys (default: ip-api.com)`privacy.anonymize_ip`Zero the last IP octet before storing`write_mode``sync` or `queue``retention_days`Used by the prune command (default `365`)### Country &amp; city (GeoIP)

[](#country--city-geoip)

By default the package uses the free **http** driver (`ip-api.com`) for public IPs only. Loopback/private IPs stay `null` (normal on local `php artisan serve` / Docker: `127.0.0.1`).

```
LOGIN_TRACKER_GEOIP_DRIVER=http
# LOGIN_TRACKER_GEOIP_DRIVER=null   # disable lookups
```

Publish config if you need a different provider:

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

### Identifier

[](#identifier)

- **Login / logout:** user email (or username) is stored in `identifier`
- **Failed:** attempted email/username from credentials (never the password)

Local development with `127.0.0.1` will always show `country`/`city` as `null` — that is expected.

Customizing the notification
----------------------------

[](#customizing-the-notification)

Publish and edit the translation strings:

```
php artisan vendor:publish --tag=login-tracker-translations
```

Or swap the notification class entirely via `notifications.class` in the config — it must extend `Illuminate\Notifications\Notification` and accept a `LoginTracker\Models\LoginActivity` in its constructor.

Pruning old records
-------------------

[](#pruning-old-records)

```
php artisan login-tracker:prune
php artisan login-tracker:prune --days=90
```

`LoginActivity` also implements `MassPrunable`, so `php artisan model:prune` works if you schedule it.

Privacy &amp; GDPR
------------------

[](#privacy--gdpr)

- Passwords are never recorded.
- `session_id` is stored as a SHA-256 hash, never the raw session ID.
- Set `privacy.anonymize_ip` to `true` to zero the last IPv4 octet (or trailing IPv6 groups) before storing.
- Set `store_unknown_failed_attempts` to `false` to avoid persisting attacker-supplied email addresses for accounts that don't exist.
- Login activity rows reference `user_id` with a foreign key; delete them (via a model event, observer, or `onDelete('cascade')` migration edit) when a user is deleted, per your app's data-retention policy.
- Review whether recording IP/device data requires a documented lawful basis (e.g. legitimate interest for account security) under your applicable privacy regulation.

Testing
-------

[](#testing)

```
composer test
composer analyse
composer format
```

License
-------

[](#license)

MIT

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance100

Actively maintained with recent releases

Popularity3

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

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/154681967?v=4)[Diksha Verma](/maintainers/94dikshaverma)[@94dikshaverma](https://github.com/94dikshaverma)

---

Top Contributors

[![94dikshaverma](https://avatars.githubusercontent.com/u/154681967?v=4)](https://github.com/94dikshaverma "94dikshaverma (7 commits)")

---

Tags

laravelsecurityAuthenticationAuditlogindevice tracking

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/94dikshaverma-laravel-login-tracker/health.svg)

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

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k107.5M1.6k](/packages/spatie-laravel-permission)[spatie/laravel-health

Monitor the health of a Laravel application

88212.7M180](/packages/spatie-laravel-health)[laravel/ai

The official AI SDK for Laravel.

1.1k4.6M279](/packages/laravel-ai)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k30.2M156](/packages/laravel-cashier)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k16.3M146](/packages/laravel-pulse)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9872.4M142](/packages/roots-acorn)

PHPackages © 2026

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