Download the PHP package netesy/tracker without Composer
On this page you can find all versions of the php package netesy/tracker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download netesy/tracker
More information about netesy/tracker
Files in netesy/tracker
Package tracker
Short Description A Comphrehensive Laravel Visitor Tracker
License MIT
Informations about the package tracker
Laravel Stats Tracker
Tracker gathers a lot of information from your requests to identify and store:
- Sessions
- Page Views (hits on routes)
- Users (logged users)
- Devices (computer, smartphone, tablet...)
- Languages (preference, language range)
- User Devices (by, yeah, storing a cookie on each device)
- Browsers (Chrome, Mozilla Firefox, Safari, Internet Explorer...)
- Operating Systems (iOS, Mac OS, Linux, Windows...)
- Geo Location Data (Latitute, Longitude, Country and City)
- Routes and all its parameters
- Events
- Referers (url, medium, source, search term...)
- Exceptions/Errors
- Sql queries and all its bindings
- Url queries and all its arguments
- Database connections
Index
- Why?
- How To Use It
- Screenshots
- Blade Views
- Table Schemas
- System Requirements
- Installing
- Upgrading
- Changelog
- Contributing
Why?
Storing user tracking information, on indexed and normalized database tables, wastes less disk space and ease the extract of valuable information about your application and business.
Usage
As soon as you install and enable it, Tracker will start storing all information you tell it to, then you can in your application use the Tracker Facade to access everything. Here are some of the methods and relationships available:
Current Session/Visitor
Most of those methods return an Eloquent model or collection, so you can use not only its attributes, but also relational data:
Sessions (visits)
Online Users
Brings all online sessions (logged and unlogged users)
Users
User Devices
Events
Errors
PageViews summary
PageViews By Country summary
Filter range
You can send timestamp ranges to those methods using the Minutes class:
Routes By Name
Having a route of
You can use this method to select all hits on that particular route and count them using Laravel:
And if you need count how many unique visitors accessed that route, you can do:
Screenshots
Visits
Charts
Users
Events
Errors
Blade Views
The views above are available in this package, but you need to install the sb-admin
panel on your public folder, please look at the instructions below.
How data is stored
All tables are prefixed by tracker_
, and here's an extract of some of them, showing columns and contents:
sessions
devices
agents
languages
domains
errors
events
geoip
log
paths
route_paths
routes
sql_queries ;
Manually log things
If your application has special needs, you can manually log things like:
Events
Routes
Requirements
- Laravel 5+
- PHP 5.3.7+
- Package "geoip/geoip":"~1.14" or "geoip2/geoip2":"~2.0" (If you are planning to store Geo IP information)
For Laravel 4+ please use version 2.0.10.
Installing
Require the tracker
package by executing the following command in your command line:
composer require Netesy/tracker
Add the service provider to your app/config/app.php:
Add the alias to the facade on your app/config/app.php:
Publish tracker configuration:
Laravel 4
php artisan config:publish netesy/tracker
Laravel 5
php artisan vendor:publish --provider="Netesy\Tracker\Vendor\Laravel\ServiceProvider"
Enable the Middleware (Laravel 5)
Open the newly published config file found at app/config/tracker.php
and enable use_middleware
:
Add the Middleware to Laravel Kernel (Laravel 5)
Open the file app/Http/Kernel.php
and add the following to your web middlewares:
Enable Tracker in your config.php (Laravel 4) or tracker.php (Laravel 5)
Publish the migration
php artisan tracker:tables
This is only needed if you are on Laravel 4, because vendor:publish
does it for you in Laravel 5.
Create a database connection for it on your config/database.php
Migrate it
If you have set the default connection to tracker
, you can
php artisan migrate
Otherwise you'll have to
php artisan migrate --database=tracker
If you are planning to store Geo IP information, also install the geoip package:
composer require "geoip/geoip":"~1.14"
or
composer require "geoip2/geoip2":"~2.0"
And make sure you don't have the PHP module installed. This is a Debian/Ubuntu example:
sudo apt-get purge php5-geoip
Everything Is Disabled By Default
Tracker has a lot of logging options, but you need to decide what you want to log. Starting by enabling this one:
It is responsible for logging page hits and sessions, basically the client IP address.
Multiple authentication drivers
You just have to all your auth IOC bidings to the array:
Stats Panel
To use the stats panel on your website you'll need to download the sb-admin 2 sources to your public folder:
git clone https://github.com/BlackrockDigital/startbootstrap-sb-admin-2.git public/templates/sb-admin-2
cd public/templates/sb-admin-2
git checkout tags/v3.3.7+1
git checkout -b v3.3.7+1
And enabled in your config file:
Set the web middleware for stats routes (Laravel 5)
Only admins can view the stats, so if you don't have an is_admin attribute on your user model, you'll have to add one:
It can be 'admin', 'is_admin', 'root' or 'is_root'.
Troubleshooting
Is everything enabled?
Make sure Tracker is enabled in the config file. Usually this is the source of most problems.
Tail your laravel.log file
Usually non-trackable IP addresses and other messages will appear in the log:
SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'field name'
This is probably related to SQL modes on MySQL, specifically with NO_ZERO_IN_DATE
and NO_ZERO_DATE
modes:
https://stackoverflow.com/questions/36882149/error-1067-42000-invalid-default-value-for-created-at
Because Laravel's defaults to
You may need to change your Tracker database connection configuration to
Not able to track users?
If you get an error like:
Base table or view not found: 1146 Table 'tracker.users' doesn't exist
You probably need to change:
'user_model' => 'Netesy\Tracker\Vendor\Laravel\Models\User',
To create (or use a current) a User model:
'user_model' => 'App\TrackerUser',
And configure the Connection related to your users table:
protected $connection = 'mysql';
Not able to track API's?
In your kernel
protected $middlewareGroups = [
'web' => [
.......
\Netesy\Tracker\Vendor\Laravel\Middlewares\Tracker::class,
],
'api' => [
.......
\Netesy\Tracker\Vendor\Laravel\Middlewares\Tracker::class,
],
];
Author
Antonio Carlos Ribeiro All Contributors
License
Tracker is licensed under the BSD 3-Clause License - see the LICENSE
file for details
Contributing
Pull requests and issues are more than welcome.
All versions of tracker with dependencies
doctrine/dbal Version ^2.6|^3.1
laravel/framework Version ~5|~6|~7|~8
netesy/support Version ~0.6|~0.7|~0.8|~0.9
ramsey/uuid Version ^3 || ^4
jenssegers/agent Version ~2.1
ua-parser/uap-php Version ~3.4
pragmarx/datatables Version ^1.4.12
snowplow/referer-parser Version ~0.1
jaybizzle/crawler-detect Version ~1.0
psr/log Version ~1.0