PHPackages                             rinvex/laravel-statistics - 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. [Database &amp; ORM](/categories/database)
4. /
5. rinvex/laravel-statistics

AbandonedArchivedLibrary[Database &amp; ORM](/categories/database)

rinvex/laravel-statistics
=========================

Rinvex Statistics is a lightweight, yet detailed package for tracking and recording user visits across your Laravel application. With only one simple query per request, important data is being stored, and later a cronjob crush numbers to extract meaningful stories from within the haystack.

v6.1.0(4y ago)2084.2k311MITPHPPHP ^8.0.0

Since Feb 18Pushed 4y ago8 watchersCompare

[ Source](https://github.com/rinvex/laravel-statistics)[ Packagist](https://packagist.org/packages/rinvex/laravel-statistics)[ Docs](https://rinvex.com)[ RSS](/packages/rinvex-laravel-statistics/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (18)Versions (25)Used By (1)

Rinvex Statistics
=================

[](#rinvex-statistics)

⚠️ This package is abandoned and no longer maintained. No replacement package was suggested. ⚠️

👉 If you are interested to step on as the main maintainer of this package, please [reach out to me](https://twitter.com/omranic)!

---

**Rinvex Statistics** is a lightweight, yet detailed package for tracking and recording user visits across your Laravel application. With only one simple query per request, important data is being stored, and later a cronjob crush numbers to extract meaningful stories from within the haystack.

Unlike other tracking packages that seriously damage your project's performance (yes, I mean that package you know 😅), our package takes a different approach by just executing only one query at the end of each request after the response is being served to the user, through the `terminate` method of an automatically attached middleware, and then later on it uses the raw data previously inserted in the database to extract meaningfull numbers. This is done based on a random lottery request, or through a scheduled job (recommended) that could be queued to offload the heavy crunching work.

**Rinvex Statistics** tracks each -valid- request, meaning only requests that goes through routing pipeline, which also means that any wrong URL that results in `NotFoundHttpException` will not be tracked. If requested page has uncaught exceptions, it won't be tracked as well. It track user's logged in account (if any), session of all users and guests (if any), device (family, model, brand), platform (family, version), browser (agent, kind, family, version), path, route (action, middleware, parameters), host, protocol, ip address, language, status codes, and many more, and still we've plenty of awesome features planned for the future.

With such a huge collected data, the `statistics_requests` database table will noticeably increase in size specially if you've a lot of visits, that's why it's recommended to clean it periodically. Other important data will stay still in their respective tables, normalized and without any performance issues, so only this table need to be cleaned. By default that will be done automatically every month.

The default implementation of **Rinvex Statistics** comes with zero configuration out-of-the-box, which means it just works once installed. But it's recommended to change the defaults and disable the "Statistics Crunching Lottery" from config file, and replace it with a [Scheduled Tasks](https://laravel.com/docs/master/scheduling) for even better performance if you've large number of visits. See [Usage](#usage) for details.

[![Packagist](https://camo.githubusercontent.com/7b32d5a21425a3e3fed457e9e444158ed89586eaa728725176aae77d63f30dd7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72696e7665782f6c61726176656c2d737461746973746963732e7376673f6c6162656c3d5061636b6167697374267374796c653d666c61742d737175617265)](https://packagist.org/packages/rinvex/laravel-statistics)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/92027c94ee4463f482ffe78abff5919eb1e4ddae8ff29135977e364c426cc28b/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f72696e7665782f6c61726176656c2d737461746973746963732e7376673f6c6162656c3d5363727574696e697a6572267374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/rinvex/laravel-statistics/)[![Travis](https://camo.githubusercontent.com/b0d299b66696ba0804b591496c64c20b1a390e16724bcdd8f998e48958d34fe2/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f72696e7665782f6c61726176656c2d737461746973746963732e7376673f6c6162656c3d5472617669734349267374796c653d666c61742d737175617265)](https://travis-ci.org/rinvex/laravel-statistics)[![StyleCI](https://camo.githubusercontent.com/d414bb39df6f03e749d6b92a02826cc9d248f20d80c9aee3531506bf55cdc4ab/68747470733a2f2f7374796c6563692e696f2f7265706f732f3131383034353130312f736869656c64)](https://styleci.io/repos/118045101)[![License](https://camo.githubusercontent.com/82a902d2f02227ac478019cfc795c1ead4f7e8c27eb5e4c1c868de80b9edd3bd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f72696e7665782f6c61726176656c2d737461746973746963732e7376673f6c6162656c3d4c6963656e7365267374796c653d666c61742d737175617265)](https://github.com/rinvex/laravel-statistics/blob/develop/LICENSE)

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

[](#installation)

1. Install the package via composer:

    ```
    composer require rinvex/laravel-statistics
    ```
2. Publish resources (migrations and config files):

    ```
    php artisan rinvex:publish:statistics
    ```
3. Execute migrations via the following command:

    ```
    php artisan rinvex:migrate:statistics
    ```
4. Done!

Usage
-----

[](#usage)

Well, this is the fun part! **Rinvex Statistics** has no usage instructions, because it just works! You install it and you are done! Seriously!!

Anyway, as a recommended performance tweak go ahead and do the following (optionally):

1. Publish config file via the following command:

    ```
    php artisan rinvex:publish:statistics

    ```
2. Disable the "Statistics Crunching Lottery" from config file.
3. Follow the default Laravel documentation about [Scheduled Tasks](https://laravel.com/docs/master/scheduling), then schedule both `\Rinvex\Statistics\Jobs\CrunchStatistics` and `\Rinvex\Statistics\Jobs\CleanStatisticsRequests` jobs at whatever intervals you see appropriate.
4. Enjoy!

> **Note:** **Rinvex Statistics** has a `\Rinvex\Statistics\Http\Middleware\TrackStatistics` middleware that attach itself automatically to the `web` middleware group, that's how it works out-of-the-box with zero configuration.

### Data retrieval

[](#data-retrieval)

You may need to build your own frontend interface to browse statistics, and for that you can utilize any of the included eloquent models as you normally do with [Laravel Eloquent](https://laravel.com/docs/master/eloquent).

All eloquent models are self explainatory:

- `\Rinvex\Statistics\Models\Agent` browser agent model
- `\Rinvex\Statistics\Models\Datum` raw statistics data (to be crunched)
- `\Rinvex\Statistics\Models\Device` user device model
- `\Rinvex\Statistics\Models\Path` request path model
- `\Rinvex\Statistics\Models\Platform` user platform model
- `\Rinvex\Statistics\Models\Request` request data model (to be cleaned periodically)
- `\Rinvex\Statistics\Models\Route` request route details model

All models are bound to the [Service Container](https://laravel.com/docs/master/container) so you can swap easily from anywhere in your application. In addition to the default normal way of using these models explicitely, you can use their respective service names as in the following example:

```
// Find first browser agent (any of these methods are valid and equivalent)
app('rinvex.statistics.agent')->first();
new \Rinvex\Statistics\Models\Agent::first();
app(\Rinvex\Statistics\Contracts\AgentContract::class)->first();
```

Same for all other eloquent models.

### Counts that matters

[](#counts-that-matters)

All agent, device, path, platform, route models have a `count` attribute, which gets updated automatically whenever a new request has been tracked.

This `count` attribute reflects number of hits. To make it clear let's explain through data samples:

#### Agents

[](#agents)

idkindfamilyversioncountname1desktopChrome63.0.3239734Mozilla/5.0 (Macintosh; Intel Mac OS X 10\_12\_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36This means there's 734 visit to our project through **Chrome** browser, version **63.0.3239**, with agent (**Mozilla/5.0 (Macintosh; Intel Mac OS X 10\_12\_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36**)

#### Devices

[](#devices)

idfamilymodelbrandcount1iPhoneiPhoneApple83This means there's 83 visits to our project through **iPhone** device.

#### Platforms

[](#platforms)

idfamilyversioncount1Mac OS X10.12.6615This means there's 615 visits to our project through **Mac OS X** operating system, with version **10.12.6**.

#### Paths

[](#paths)

idhostlocalepathparameterscount1test.homestead.localenen/adminarea/roles/admin{"role": "admin", "locale": "en"}12This means there's 12 visits to the admin dashboard roles management of the **test.homestead.local** host (in case you have multiple hosts or wildcard subdomains enabled on the same project, you can track all of them correctly here). The english interface was used, and the accessed route had two parameters, one for locale (english in this case), and updated role record (admin in this case).

This table could be used as a visit counter for all your pages. To retrieve and display page views you can use the following code for example:

```
$pageViews = app('rinvex.statistics.path')->where('path', request()->decodedPath())->first()->count;
```

And simply use the `$pageViews` variable anywhere in your views or controllers, or anywhere else. That way you have automatic visit counter for all your project's pages, very useful and performant, ready at your fingertips. You can add `host` contraint in case you have wildcard subdomains enabled.

#### Routes

[](#routes)

idnamepathactionmiddlewareparameterscount1adminarea.roles.edit{locale}/adminarea/roles/{role}App\\Http\\Controllers\\Adminarea\\RolesController@form\["web","nohttpcache","can:access-adminarea","auth","can:update-roles,roles"\]{"role": "\[a-z0-9-\]+", "locale": "\[a-z\]{2}"}41This means there's 41 visits to the `adminarea.roles.edit` route, which has the `{locale}/adminarea/roles/{role}` raw path, and served through the `App\Http\Controllers\Adminarea\RolesController@form` controller action, and has the following middleware applied `["web","nohttpcache","can:access-adminarea","auth","can:update-roles,roles"]`, knowing the route accepts two parameters with the following regex requirements `{"role": "[a-z0-9-]+", "locale": "[a-z]{2}"}`.

As you can see, this `statistics_routes` table beside the `statistics_paths` table are both complimentary, and could be used together to track which paths and routs are being accessed, how many times, and what controller actions serve it, and what parameters are required, with the actual parameter replacements used to access it. Think of routes as your raw links blueprint map, and of paths as the executed and actually used links by users.

#### Geoips

[](#geoips)

idclient\_iplatitudelongitudecountry\_codeclient\_ipsis\_from\_trusted\_proxydivision\_codepostal\_codetimezonecitycount1127.0.0.041.31-72.92USNULL0CT06510America/New\_YorkNew Haven57This means there's 57 visits to the project from IP address `127.0.0.0` with the latitude, longitude and timezone mentioned above coming from `New Haven` city, `Connecticut` state.

#### Requests

[](#requests)

idroute\_idagent\_iddevice\_idplatform\_idpath\_idgeoip\_iduser\_iduser\_typesession\_idmethodstatus\_codeprotocol\_versionrefererlanguageis\_no\_cachewants\_jsonis\_secureis\_jsonis\_ajaxis\_pjaxcreated\_at1123123123123123123123userMU22QcrzDIdj0gY27yJmUPJHNFy9Hlqvkel1KBZ1GETPOST200HTTP/1.1en\_US001000This is the most comprehensive table that records every single request made to the project, with access details as seen in the sample above. Through `session_id`, `user_id` and `user_type` you can track guests (logged out) and users (logged in) and extract unique visits/visitors with the criteria you see appropriate for you.

> **Notes:**
>
> - As a final note, this package is a data hord, and it doesn't actually do much of the math that could be done on such a valuable gathered data, so it's up to your imagination to utilize it however you see fits your goals. Implementation details is up to you.
> - We didn't explain the `statistics_data` table since it's used for temporary raw data storage until it's being crunched and processed by the package, so you should **NOT** care or mess with that table. It's used internally by the package and has no real end-user usage.
> - The `\Rinvex\Statistics\Models\Request` model has relationships to all related data such as `agent`, `device`, `path`, `platform`, and `route`. So once you grab a request instance you can access any of it's relationships as you normaly do with [Eloquent Relationships](https://laravel.com/docs/master/eloquent-relationships) like so: `$statisticsRequest->agent->version` or `$statisticsRequest->platform->family`.

Changelog
---------

[](#changelog)

Refer to the [Changelog](CHANGELOG.md) for a full history of the project.

Support
-------

[](#support)

The following support channels are available at your fingertips:

- [Chat on Slack](https://bit.ly/rinvex-slack)
- [Help on Email](mailto:help@rinvex.com)
- [Follow on Twitter](https://twitter.com/rinvex)

Contributing &amp; Protocols
----------------------------

[](#contributing--protocols)

Thank you for considering contributing to this project! The contribution guide can be found in [CONTRIBUTING.md](CONTRIBUTING.md).

Bug reports, feature requests, and pull requests are very welcome.

- [Versioning](CONTRIBUTING.md#versioning)
- [Pull Requests](CONTRIBUTING.md#pull-requests)
- [Coding Standards](CONTRIBUTING.md#coding-standards)
- [Feature Requests](CONTRIBUTING.md#feature-requests)
- [Git Flow](CONTRIBUTING.md#git-flow)

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

If you discover a security vulnerability within this project, please send an e-mail to [help@rinvex.com](help@rinvex.com). All security vulnerabilities will be promptly impressioned.

About Rinvex
------------

[](#about-rinvex)

Rinvex is a software solutions startup, specialized in integrated enterprise solutions for SMEs established in Alexandria, Egypt since June 2016. We believe that our drive The Value, The Reach, and The Impact is what differentiates us and unleash the endless possibilities of our philosophy through the power of software. We like to call it Innovation At The Speed Of Life. That’s how we do our share of advancing humanity.

License
-------

[](#license)

This software is released under [The MIT License (MIT)](LICENSE).

(c) 2016-2022 Rinvex LLC, Some rights reserved.

###  Health Score

44

—

FairBetter than 91% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community24

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 97.5% 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 ~66 days

Recently: every ~152 days

Total

23

Last Release

1545d ago

Major Versions

v1.0.2 → v2.0.02019-03-03

v2.1.1 → v3.0.02019-09-22

v3.0.2 → v4.0.02020-03-15

v4.1.0 → v5.0.02020-12-22

v5.0.1 → v6.0.02021-08-22

PHP version history (5 changes)v0.0.1PHP ^7.1.3

v2.0.0PHP ^7.2.0

v4.0.0PHP ^7.4.0

v5.0.1PHP ^7.4.0 || ^8.0.0

v6.0.0PHP ^8.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/7e54af04bcacb96e00894621335f88df7ed9895b6cc245deffdc9830a21cfe29?d=identicon)[Omranic](/maintainers/Omranic)

---

Top Contributors

[![Omranic](https://avatars.githubusercontent.com/u/406705?v=4)](https://github.com/Omranic "Omranic (198 commits)")[![akempes](https://avatars.githubusercontent.com/u/5055413?v=4)](https://github.com/akempes "akempes (1 commits)")[![amaelftah](https://avatars.githubusercontent.com/u/17250137?v=4)](https://github.com/amaelftah "amaelftah (1 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (1 commits)")[![Rattone](https://avatars.githubusercontent.com/u/7362607?v=4)](https://github.com/Rattone "Rattone (1 commits)")[![relliv](https://avatars.githubusercontent.com/u/17010054?v=4)](https://github.com/relliv "relliv (1 commits)")

---

Tags

clientbrowserlaravelloggingmodeleloquentusertrackingplatformvisitordevicestatisticsviewsagentsrinvex

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rinvex-laravel-statistics/health.svg)

```
[![Health](https://phpackages.com/badges/rinvex-laravel-statistics/health.svg)](https://phpackages.com/packages/rinvex-laravel-statistics)
```

###  Alternatives

[laravel/pulse

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

1.7k12.1M99](/packages/laravel-pulse)[rinvex/laravel-tenants

Rinvex Tenants is a contextually intelligent polymorphic Laravel package, for single db multi-tenancy. You can completely isolate tenants data with ease using the same database, with full power and control over what data to be centrally shared, and what to be tenant related and therefore isolated from others.

823.4k10](/packages/rinvex-laravel-tenants)

PHPackages © 2026

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