PHPackages                             kianisanaullah/laravel-traffic-sentinel - 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. kianisanaullah/laravel-traffic-sentinel

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

kianisanaullah/laravel-traffic-sentinel
=======================================

Traffic Sentinel for Laravel: tracks visitors + bots, online presence, and traffic stats.

v2.7.3(1mo ago)0140↓50%MITPHPPHP ^8.2

Since Feb 4Pushed 2mo agoCompare

[ Source](https://github.com/kianisanaullah/laravel-traffic-sentinel)[ Packagist](https://packagist.org/packages/kianisanaullah/laravel-traffic-sentinel)[ RSS](/packages/kianisanaullah-laravel-traffic-sentinel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (89)Used By (0)

 [![Traffic Sentinel Logo](https://raw.githubusercontent.com/kianisanaullah/laravel-traffic-sentinel/main/resources/assets/logo.svg)](https://raw.githubusercontent.com/kianisanaullah/laravel-traffic-sentinel/main/resources/assets/logo.svg)

 [ ![Latest Version](https://camo.githubusercontent.com/61f6f8c66add82128c24bc5042a2caf8bc1a70844bbeff7f13fe902bbf4ce44a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b69616e6973616e61756c6c61682f6c61726176656c2d747261666669632d73656e74696e656c) ](https://packagist.org/packages/kianisanaullah/laravel-traffic-sentinel) [ ![Downloads](https://camo.githubusercontent.com/f175c2e9462ab1635d078cb7127b7697d1c7c4d98b070b2dca7a68856a7c9892/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b69616e6973616e61756c6c61682f6c61726176656c2d747261666669632d73656e74696e656c) ](https://packagist.org/packages/kianisanaullah/laravel-traffic-sentinel) [![](https://camo.githubusercontent.com/1a1716bf63711a20b8493d316e6c06b44fa9975a10372cfbfc682f08a6829cc2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31322532422d726564)](https://camo.githubusercontent.com/1a1716bf63711a20b8493d316e6c06b44fa9975a10372cfbfc682f08a6829cc2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31322532422d726564) [![](https://camo.githubusercontent.com/5caa455d8debc46fb23abbadb45a733a937f3910a73fc875c2f7820468e1bb54/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e)](https://camo.githubusercontent.com/5caa455d8debc46fb23abbadb45a733a937f3910a73fc875c2f7820468e1bb54/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e)

Traffic Sentinel
================

[](#traffic-sentinel)

🚦 **Self-hosted Laravel traffic analytics** for **humans vs bots**, online users, pageviews, referrers, and crawler detection — **no Google Analytics, no cookies, no third-party tracking**.

🤔 Why Traffic Sentinel?
-----------------------

[](#-why-traffic-sentinel)

Most Laravel apps either:

- rely on **Google Analytics** (privacy issues, blocked by ad-blockers), or
- use **heavy analytics tools** that are hard to self-host.

**Traffic Sentinel is different:**

- ✅ 100% self-hosted (your DB, your rules)
- 🔐 Privacy-first (hashed IPs, optional raw IP, no cookies by default)
- 🤖 Built to separate **real humans vs crawlers**
- ⚡ Lightweight — no JS frameworks, no trackers, no beacons
- 🧩 Designed for **developers**, not marketers

If you want *operational visibility* instead of marketing analytics, Traffic Sentinel fits perfectly.

---

🆚 How it compares
-----------------

[](#-how-it-compares)

FeatureTraffic SentinelGoogle AnalyticsLaravel TelescopeSelf-hosted✅ Yes❌ No✅ YesPrivacy-friendly✅ Yes❌ No✅ YesBot detection✅ Built-in⚠️ Limited❌ NoOnline users✅ Yes❌ No❌ NoPageviews✅ Yes✅ Yes❌ NoProduction-safe✅ Yes✅ Yes❌ NoExternal scripts❌ None✅ Required❌ NoneTraffic Sentinel focuses on **traffic intelligence**, not debugging or marketing.

✨ Features
----------

[](#-features)

- 🔐 Privacy-first analytics (hashed IPs, optional raw IP, no cookies by default)
- ✅ Human vs Bot detection (UA keywords + heuristics)
- 👀 Online users (last N minutes)
- 📊 Pageviews (humans / all)
- 🔎 Top pages, bots &amp; referrers
- 🚫 Exclude internal paths, hosts, IPs &amp; UAs
- 🧠 Runtime IP → Country / ASN lookup (no external APIs)
- 🧹 Prune old data (`traffic:prune`)
- 🖥️ Modern dashboard (Bootstrap 5)
- ⚡ No JS framework dependency
- 🌍 Optional runtime IP lookup (Country + Flag + ASN) using offline datasets
- ⬇️ One-command dataset installer (`traffic-sentinel:ipdata:install`)
- 🧩 Click any IP in the dashboard to open a modern IP details modal (optional)

### 🔐 IP Privacy Modes (Important)

[](#-ip-privacy-modes-important)

Traffic Sentinel can store IPs in multiple ways:

- **Hashed IP** (`ip.store = hashed`) → privacy-friendly, recommended
- **Full IP** (`ip.store = full`) → store readable IP in `traffic_sessions.ip`
- **Raw IP (optional)** (`privacy.store_raw_ip = true`) → stores the real client IP in `traffic_sessions.ip_raw`

> Tip: Many apps keep `ip.store = hashed` but still want runtime geolocation. We support runtime lookup without storing location in DB.

> Traffic Sentinel never sends IPs to external services — all lookups are local.

---

📦 Installation
--------------

[](#-installation)

```
composer require kianisanaullah/laravel-traffic-sentinel
```

Publish config &amp; migrations:
--------------------------------

[](#publish-config--migrations)

```
php artisan vendor:publish --tag=traffic-sentinel-config
php artisan vendor:publish --tag=traffic-sentinel-migrations
php artisan migrate
```

🧩 Middleware
------------

[](#-middleware)

Option A — Auto register (recommended for most apps)

In config/traffic-sentinel.php:

```
'middleware' => [
'auto_register' => true,
],
```

Option B — Manually register

Add to your web middleware group: Laravel 11

```
\Kianisanaullah\TrafficSentinel\Http\Middleware\TrackTraffic::class,
```

Laravel 12 and above add in bootstrap/app.php

```
  $middleware->append(\Kianisanaullah\TrafficSentinel\Http\Middleware\TrackTraffic::class);
```

📊 Dashboard
-----------

[](#-dashboard)

/admin/traffic-sentinel

🖼️ Dashboard Preview
--------------------

[](#️-dashboard-preview)

> Clean, readable, production-ready dashboard.

[![Traffic Sentinel Dashboard](resources/docs/screenshots/dashboard.png)](resources/docs/screenshots/dashboard.png)

🔐 Protect Dashboard
-------------------

[](#-protect-dashboard)

Protect it in config: 'dashboard' =&gt; \[ 'middleware' =&gt; \['web', 'auth'\], \],

🚫 Excluding URLs
----------------

[](#-excluding-urls)

```
'exclude' => [
  'paths' => [
    'admin',
    'admin/traffic-sentinel',
    'api',
  ],

  'hosts' => [
    'localhost',
    '127.0.0.1',
  ],

  'ips' => [
    '127.0.0.1',
    '::1',
  ],

  'user_agents' => [
    'UptimeRobot',
    'Pingdom',
  ],

  // NOTE: route_names works only if your middleware supports it.
  // If you added Str::is() route exclude logic in TrackTraffic::shouldExclude(),
  // then you can use wildcards like 'admin.*'
  'route_names' => [
    // 'traffic-sentinel.*',
    // 'admin.*',
  ],
],
```

🌍 Runtime IP Lookup (Country / ASN) — Offline (No APIs)
-------------------------------------------------------

[](#-runtime-ip-lookup-country--asn--offline-no-apis)

Traffic Sentinel can optionally resolve:

- **Country code + country name + flag**
- **ASN + ASN org name**

at runtime using **offline datasets** (no external API calls).

This is useful when:

- you want *privacy-first* tracking (hashed IPs), but
- still want **country + ASN** in the dashboard at view-time.

> ✅ Datasets are stored in `storage/` (not inside `vendor/`) so Composer updates won’t delete them.

⬇️ Install IP datasets
----------------------

[](#️-install-ip-datasets)

1. Publish config (if not already):

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

2. Install datasets:

```
php artisan traffic-sentinel:ipdata:install
```

Force re-download (fresh install):

```
php artisan traffic-sentinel:ipdata:install --force
```

🌍 IP Modal + Flags (UI)
-----------------------

[](#-ip-modal--flags-ui)

Traffic Sentinel includes an optional UI helper: • Click an IP in any table → opens a modal with details (country, flag, ASN, CIDR match) • Optional: auto-hydrate small flags in tables

Enable in config:

```
'ui' => [
  'ip_modal' => [
    'enabled' => true,
    'endpoint' => '/admin/traffic-sentinel/ip/lookup?ip=__IP__',
    'hydrate_flags' => true,
  ],
],
```

What you need in tables

Render IPs like this:

```

  🌐
  {{ $ip }}

```

The `data-ts-flag` attribute will be replaced with a small flag icon if the IP is found in the dataset. The `data-ts-ip` attribute is used to trigger the IP detail modal. The `data-ts-ip` attribute is required for the modal to work. The `data-ts-flag` attribute is optional. The `data-ts-ip` attribute can be used in any table cell.

✅ Notes / Best Practices
------------------------

[](#-notes--best-practices)

If config('traffic-sentinel.privacy.store\_raw\_ip') is null, you likely haven’t published config or config is cached:

```
php artisan config:clear
php artisan cache:clear
```

When publishing config and file already exists:

```
php artisan vendor:publish --tag=traffic-sentinel-config --force
```

🧹 Prune Old Data
----------------

[](#-prune-old-data)

```
php artisan traffic:prune --days=30
```

🗄️ Database Configuration (Optional)

By default, Traffic Sentinel uses your application’s default database connection (mysql).

You can override this and store all traffic tables in a separate connection (recommended for analytics-heavy apps).

⚙️ Step 1 — Configure Connection

In config/traffic-sentinel.php:

```
'database' => [
    'connection' => env('TRAFFIC_SENTINEL_DB_CONNECTION', 'mysql'),
],
```

⚙️ Step 2 — Set in .env (Optional)

```
TRAFFIC_SENTINEL_DB_CONNECTION=analytics
```

Now all Traffic Sentinel queries will use the analytics connection instead of the default one.

👤 Who is this for?
------------------

[](#-who-is-this-for)

Traffic Sentinel is ideal for:

- Laravel SaaS &amp; dashboards
- Admin panels &amp; internal tools
- News / content websites
- APIs with crawler traffic
- Any app where you want **visibility without surveillance**

Not ideal if:

- You need ad conversion tracking
- You want marketing funnels / heatmaps

🧩 Common Use Cases
------------------

[](#-common-use-cases)

- Detect SEO crawlers vs real readers
- Monitor traffic spikes &amp; bot floods
- See which pages are actually visited by humans
- Track uptime bots &amp; monitoring tools
- Audit referrers and external traffic sources
- Lightweight alternative to GA for internal dashboards

🛣️ Roadmap
----------

[](#️-roadmap)

Planned improvements:

- IPv6 country zones expansion
- Per-route analytics
- Rate-limit &amp; bot flood alerts
- Export to CSV / JSON
- Live updates (optional)

Suggestions &amp; PRs are welcome.

⚡ Performance &amp; Safety
--------------------------

[](#-performance--safety)

- Single lightweight insert per request
- Uses indexed tables (safe for production)
- No event listeners or observers
- No cookies unless you enable them
- No outbound HTTP calls
- Designed for high-traffic Laravel apps

📄 License
---------

[](#-license)

MIT © Sanaullah Kiani
---------------------

[](#mit--sanaullah-kiani)

###  Health Score

45

—

FairBetter than 92% of packages

Maintenance87

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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

88

Last Release

53d ago

Major Versions

v1.2.1 → v2.0.82026-02-17

### Community

Maintainers

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

---

Top Contributors

[![kianisanaullah](https://avatars.githubusercontent.com/u/28821509?v=4)](https://github.com/kianisanaullah "kianisanaullah (32 commits)")

---

Tags

laravelmonitoringsecurityreal-timecrawlerdashboardanalyticsgdprprivacyasnbot-detectionself hostedtrafficip-lookuponline-usersvisitor-tracking

### Embed Badge

![Health badge](/badges/kianisanaullah-laravel-traffic-sentinel/health.svg)

```
[![Health](https://phpackages.com/badges/kianisanaullah-laravel-traffic-sentinel/health.svg)](https://phpackages.com/packages/kianisanaullah-laravel-traffic-sentinel)
```

###  Alternatives

[yadahan/laravel-authentication-log

Laravel Authentication Log provides authentication logger and notification for Laravel.

416632.8k5](/packages/yadahan-laravel-authentication-log)[muhammadsadeeq/laravel-activitylog-ui

A beautiful, modern UI for Spatie's Activity Log with advanced filtering, analytics, and real-time features.

17510.1k](/packages/muhammadsadeeq-laravel-activitylog-ui)

PHPackages © 2026

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