diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 00000000..7ef28b92
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,32 @@
+---
+name: Bug report
+about: Create a report to help us improve
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+**Describe the bug**
+A clear and concise description of what the bug is.
+
+**To Reproduce**
+Steps to reproduce the behavior:
+1. Go to '...'
+2. Click on '....'
+3. Scroll down to '....'
+4. See error
+
+**Expected behavior**
+A clear and concise description of what you expected to happen.
+
+**Screenshots**
+If applicable, add screenshots to help explain your problem.
+
+**System**
+ - OS: [e.g. iOS]
+ - Browser [e.g. chrome, safari]
+ - Version [e.g. 22]
+
+**Additional context**
+Add any other context about the problem here.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 00000000..bbcbbe7d
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,20 @@
+---
+name: Feature request
+about: Suggest an idea for this project
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+**Is your feature request related to a problem? Please describe.**
+A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
+
+**Describe the solution you'd like**
+A clear and concise description of what you want to happen.
+
+**Describe alternatives you've considered**
+A clear and concise description of any alternative solutions or features you've considered.
+
+**Additional context**
+Add any other context or screenshots about the feature request here.
diff --git a/.gitignore b/.gitignore
index 16d877eb..f282dcfa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,5 @@
/vendor
composer.phar
-composer.lock
.DS_Store
.idea
.idea/
diff --git a/.travis.yml b/.travis.yml
index 50788434..7968a1b3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,11 +1,18 @@
language: php
+env:
+ - COMPOSER_MEMORY_LIMIT=-1
+
php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
+ - 7.1
+ - 7.2
+ - 7.3
+ - 7.4
- hhvm
install:
diff --git a/changelog.md b/changelog.md
index 697af203..865103c8 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,17 @@
# Changelog
+## [3.4.1] - 2019-09-11
+### Fixed
+- Removed support for Laravel 4
+
+## [3.4.0] - 2019-09-10
+### New
+- Added support for Laravel 6
+
+## [3.3] - 2018-03-19
+### Fixed
+- Laravel 5.6 compatibility
+
## [3.1.8] - 2017-07-31
### New
- Added a config to enable/disable console logging
diff --git a/composer.json b/composer.json
index 112c424b..5242e7e3 100644
--- a/composer.json
+++ b/composer.json
@@ -16,15 +16,17 @@
],
"require": {
- "php": ">=5.3.7",
- "laravel/framework": "~4|~5",
- "pragmarx/support": "~0.6|~0.7",
- "ramsey/uuid": "~3",
+ "php": ">=7.0",
+ "doctrine/dbal": "^2.6",
+ "laravel/framework": "~5|~6|~7|~8",
+ "pragmarx/support": "~0.6|~0.7|~0.8|~0.9",
+ "ramsey/uuid": "^3 || ^4",
"jenssegers/agent": "~2.1",
"ua-parser/uap-php" : "~3.4",
- "pragmarx/datatables": "1.4.11",
+ "pragmarx/datatables": "^1.4.12",
"snowplow/referer-parser": "~0.1",
- "jaybizzle/crawler-detect": "~1.0"
+ "jaybizzle/crawler-detect": "~1.0",
+ "psr/log": "~1.0"
},
"suggest": {
@@ -56,5 +58,6 @@
}
},
- "minimum-stability": "dev"
+ "minimum-stability": "dev",
+ "prefer-stable": true
}
diff --git a/readme.md b/readme.md
index 26c5cd30..3644f5bf 100644
--- a/readme.md
+++ b/readme.md
@@ -1,681 +1,734 @@
-# Laravel Stats Tracker
-
-[](https://packagist.org/packages/pragmarx/tracker) [](LICENSE) [](https://packagist.org/packages/pragmarx/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?](#why)
-- [How To Use It](#usage)
-- [Screenshots](#screenshots)
-- [Blade Views](#views)
-- [Table Schemas](#how-data-is-stored)
-- [System Requirements](#requirements)
-- [Installing](#installing)
-- [Upgrading](upgrading.md)
-- [Changelog](changelog.md)
-- [Contributing](#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 relatioships available:
-
-#### Current Session/Visitor
-
-```php
-$visitor = Tracker::currentSession();
-```
-
-Most of those methods return an Eloquent model or collection, so you can use not only its attributes, but also relational data:
-
-```php
-var_dump( $visitor->client_ip );
-
-var_dump( $visitor->device->is_mobile );
-
-var_dump( $visitor->device->platform );
-
-var_dump( $visitor->geoIp->city );
-
-var_dump( $visitor->language->preference );
-
-```
-
-#### Sessions (visits)
-
-```php
-$sessions = Tracker::sessions(60 * 24); // get sessions (visits) from the past day
-```
-
-```php
-foreach ($sessions as $session)
-{
- var_dump( $session->user->email );
-
- var_dump( $session->device->kind . ' - ' . $session->device->platform );
-
- var_dump( $session->agent->browser . ' - ' . $session->agent->browser_version );
-
- var_dump( $session->geoIp->country_name );
-
- foreach ($session->session->log as $log)
- {
- var_dump( $log->path );
- }
-}
-```
-
-#### Online Users
-
-Brings all online sessions (logged and unlogged users)
-
-```php
-$users = Tracker::onlineUsers(); // defaults to 3 minutes
-```
-
-#### Users
-
-```php
-$users = Tracker::users(60 * 24);
-```
-
-#### User Devices
-
-```php
-$users = Tracker::userDevices(60 * 24, $user->id);
-```
-
-#### Events
-
-```php
-$events = Tracker::events(60 * 24);
-```
-
-#### Errors
-
-```php
-$errors = Tracker::errors(60 * 24);
-```
-
-#### PageViews summary
-
-```php
-$pageViews = Tracker::pageViews(60 * 24 * 30);
-```
-
-#### PageViews By Country summary
-
-```php
-$pageViews = Tracker::pageViewsByCountry(60 * 24);
-```
-
-#### Filter range
-
-You can send timestamp ranges to those methods using the Minutes class:
-
-```php
-$range = new Minutes();
-
-$range->setStart(Carbon::now()->subDays(2));
-
-$range->setEnd(Carbon::now()->subDays(1));
-
-Tracker::userDevices($range);
-```
-
-#### Routes By Name
-
-Having a route of
-
-```php
-Route::get('user/{id}', ['as' => 'user.profile', 'use' => 'UsersController@profile']);
-```
-
-You can use this method to select all hits on that particular route and count them using Laravel:
-
-```php
-return Tracker::logByRouteName('user.profile')
- ->where(function($query)
- {
- $query
- ->where('parameter', 'id')
- ->where('value', 1);
- })
- ->count();
-```
-
-And if you need count how many unique visitors accessed that route, you can do:
-
-```php
-return Tracker::logByRouteName('tracker.stats.log')
- ->where(function($query)
- {
- $query
- ->where('parameter', 'uuid')
- ->where('value', '8b6faf82-00f1-4db9-88ad-32e58cfb4f9d');
- })
- ->select('tracker_log.session_id')
- ->groupBy('tracker_log.session_id')
- ->distinct()
- ->count('tracker_log.session_id');
-```
-
-## 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
-
-```
-+-----+--------------------------------------+---------+-----------+----------+-----------------+------------+-----------+----------+-------------+
-| id | uuid | user_id | device_id | agent_id | client_ip | referer_id | cookie_id | geoip_id | language_id |
-+-----+--------------------------------------+---------+-----------+----------+-----------------+------------+-----------+----------+-------------+
-| 1 | 09465be3-5930-4581-8711-5161f62c4373 | 1 | 1 | 1 | 186.228.127.245 | 2 | 1 | 2 | 3 |
-| 2 | 07399969-0a19-47f0-862d-43b06d7cde45 | | 2 | 2 | 66.240.192.138 | | 2 | 2 | 2 |
-+-----+--------------------------------------+---------+-----------+----------+-----------------+------------+-----------+----------+-------------+
-```
-
-### devices
-
-```
-+----+----------+-------------+-------------+------------------+-----------+
-| id | kind | model | platform | platform_version | is_mobile |
-+----+----------+-------------+-------------+------------------+-----------+
-| 1 | Computer | unavailable | Windows 8 | | |
-| 2 | Tablet | iPad | iOS | 7.1.1 | 1 |
-| 3 | Computer | unavailable | Windows XP | | |
-| 5 | Computer | unavailable | Other | | |
-| 6 | Computer | unavailable | Windows 7 | | |
-| 7 | Computer | unavailable | Windows 8.1 | | |
-| 8 | Phone | iPhone | iOS | 7.1 | 1 |
-+----+----------+-------------+-------------+------------------+-----------+
-```
-
-### agents
-
-```
-+----+-----------------------------------------------------------------------------------------------------------------------------------------+-------------------+-----------------+
-| id | name | browser | browser_version |
-+----+-----------------------------------------------------------------------------------------------------------------------------------------+-------------------+-----------------+
-| 1 | Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36 | Chrome | 35.0.1916 |
-| 2 | Mozilla/5.0 (iPad; CPU OS 7_1_1 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) CriOS/34.0.1847.18 Mobile/11D201 Safari/9537.53 | Chrome Mobile iOS | 34.0.1847 |
-| 3 | Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) | IE | 6.0 |
-| 4 | Python-urllib/2.6 | Other | |
-| 5 | Other | Other | |
-| 6 | Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.137 Safari/537.36 | Chrome | 34.0.1847 |
-| 7 | Mozilla/5.0 (Windows NT 6.3; rv:28.0) Gecko/20100101 Firefox/28.0 | Firefox | 28.0 |
-| 8 | Mozilla/5.0 (iPhone; CPU iPhone OS 7_1 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0 Mobile/11D169 Safari/9537.53 | Mobile Safari | 7.0 |
-+----+-----------------------------------------------------------------------------------------------------------------------------------------+-------------------+-----------------+
-```
-
-### languages
-
-```
-+----+------------+----------------+
-| id | preference | language_range |
-+----+------------+----------------+
-| 1 | en | ru=0.8,es=0.5 |
-| 2 | es | en=0.7,ru=0.3 |
-| 3 | ru | en=0.5,es=0.5 |
-+----+------------+----------------+
-```
-
-
-### domains
-
-```
-+----+--------------------------+
-| id | name |
-+----+--------------------------+
-| 1 | antoniocarlosribeiro.com |
-+----+--------------------------+
-```
-
-### errors
-
-```
-+----+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-| id | code | message |
-+----+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-| 1 | 404 | |
-| 2 | 500 | Call to undefined method PragmaRX\Tracker\Tracker::sessionLog() |
-| 3 | 500 | Trying to get property of non-object (View: /home/forge/stage.antoniocarlosribeiro.com/app/views/admin/tracker/log.blade.php) |
-| 4 | 500 | syntax error, unexpected 'foreach' (T_FOREACH) |
-| 5 | 500 | Call to undefined method PragmaRX\Tracker\Tracker::pageViewsByCountry() |
-| 6 | 500 | Class PragmaRX\Firewall\Vendor\Laravel\Artisan\Base contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Illuminate\Console\Command::fire) |
-| 7 | 405 | |
-| 8 | 500 | Trying to get property of non-object |
-| 9 | 500 | Missing argument 2 for Illuminate\Database\Eloquent\Model::setAttribute(), called in /home/forge/stage.antoniocarlosribeiro.com/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php on line 2444 and defined |
-+----+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
-```
-
-### events
-
-```
-+----+------------------------------------------------+
-| id | name |
-+----+------------------------------------------------+
-| 1 | illuminate.log |
-| 2 | router.before |
-| 3 | router.matched |
-| 4 | auth.attempt |
-| 5 | auth.login |
-| 6 | composing: admin.tracker.index |
-| 7 | creating: admin.tracker._partials.menu |
-| 8 | composing: admin.tracker._partials.menu |
-| 9 | creating: admin.layout |
-| 10 | composing: admin.layout |
-| 11 | creating: admin._partials.mainMenu |
-| 12 | composing: admin._partials.mainMenu |
-| 13 | creating: admin._partials.messages |
-| 14 | composing: admin._partials.messages |
-| 15 | creating: global._partials.google-analytics |
-| 16 | composing: global._partials.google-analytics |
-+----+------------------------------------------------+
-```
-
-### geoip
-
-```
-+----+----------+-----------+--------------+---------------+---------------------------+--------+----------------+-------------+-----------+----------+------------+----------------+
-| id | latitude | longitude | country_code | country_code3 | country_name | region | city | postal_code | area_code | dma_code | metro_code | continent_code |
-+----+----------+-----------+--------------+---------------+---------------------------+--------+----------------+-------------+-----------+----------+------------+----------------+
-| 1 | 37.4192 | -122.057 | US | USA | United States | CA | Mountain View | 94043 | 650 | 807 | 807 | NA |
-| 2 | -10 | -55 | BR | BRA | Brazil | | | | | | | SA |
-| 3 | 30.3909 | -86.3161 | US | USA | United States | FL | Miramar Beach | 32550 | 850 | 686 | 686 | NA |
-| 4 | 38.65 | -90.5334 | US | USA | United States | MO | Chesterfield | 63017 | 314 | 609 | 609 | NA |
-| 5 | 42.7257 | -84.636 | US | USA | United States | MI | Lansing | 48917 | 517 | 551 | 551 | NA |
-| 6 | 42.8884 | -78.8761 | US | USA | United States | NY | Buffalo | 14202 | 716 | 514 | 514 | NA |
-| 7 | 40.1545 | -75.3809 | US | USA | United States | PA | Norristown | 19403 | 610 | 504 | 504 | NA |
-| 8 | 47.4891 | -122.291 | US | USA | United States | WA | Seattle | 98168 | 206 | 819 | 819 | NA |
-| 9 | 33.7516 | -84.3915 | US | USA | United States | GA | Atlanta | 30303 | 404 | 524 | 524 | NA |
-| 10 | 33.7633 | -117.794 | US | USA | United States | CA | Santa Ana | 92705 | 714 | 803 | 803 | NA |
-| 11 | 33.4357 | -111.917 | US | USA | United States | AZ | Tempe | 85281 | 480 | 753 | 753 | NA |
-| 12 | 40.7421 | -74.0018 | US | USA | United States | NY | New York | 10011 | 212 | 501 | 501 | NA |
-| 13 | 28.6185 | -81.4336 | US | USA | United States | FL | Orlando | 32810 | 407 | 534 | 534 | NA |
-| 14 | 38.6312 | -90.1922 | US | USA | United States | MO | Saint Louis | 63101 | 314 | 609 | 609 | NA |
-| 15 | 51 | 9 | DE | DEU | Germany | | | | | | | EU |
-| 16 | 52.5 | 5.75 | NL | NLD | Netherlands | | | | | | | EU |
-| 17 | 48.86 | 2.35 | FR | FRA | France | | | | | | | EU |
-| 18 | 60 | 100 | RU | RUS | Russian Federation | | | | | | | EU |
-| 19 | 51.5 | -0.13 | GB | GBR | United Kingdom | | | | | | | EU |
-| 20 | 42.8333 | 12.8333 | IT | ITA | Italy | | | | | | | EU |
-| 21 | 59.3333 | 18.05 | SE | SWE | Sweden | 26 | Stockholm | | | | | EU |
-| 22 | -41 | 174 | NZ | NZL | New Zealand | | | | | | | OC |
-| 23 | 37.57 | 126.98 | KR | KOR | Korea, Republic of | | | | | | | AS |
-| 24 | 1.3667 | 103.8 | SG | SGP | Singapore | | | | | | | AS |
-| 25 | -43.5333 | 172.633 | NZ | NZL | New Zealand | E9 | Christchurch | 8023 | | | | OC |
-| 26 | -27.471 | 153.024 | AU | AUS | Australia | 04 | Brisbane | | | | | OC |
-| 27 | 26.9167 | 75.8167 | IN | IND | India | 24 | Jaipur | | | | | AS |
-| 28 | 32 | 53 | IR | IRN | Iran, Islamic Republic of | | | | | | | AS |
-| 29 | 32.0617 | 118.778 | CN | CHN | China | 04 | Nanjing | | | | | AS |
-| 30 | -22.9 | -47.0833 | BR | BRA | Brazil | 27 | Campinas | | | | | SA |
-| 31 | 32.8073 | -117.132 | US | USA | United States | CA | San Diego | 92123 | 858 | 825 | 825 | NA |
-| 32 | -22.9 | -43.2333 | BR | BRA | Brazil | 21 | Rio De Janeiro | | | | | SA |
-+----+----------+-----------+--------------+---------------+---------------------------+--------+----------------+-------------+-----------+----------+------------+----------------+
-```
-
-### log
-
-```
-+-----+------------+---------+----------+--------+---------------+---------+-----------+---------+------------+----------+
-| id | session_id | path_id | query_id | method | route_path_id | is_ajax | is_secure | is_json | wants_json | error_id |
-+-----+------------+---------+----------+--------+---------------+---------+-----------+---------+------------+----------+
-| 1 | 1 | 1 | | GET | 1 | | 1 | | | |
-| 2 | 1 | 2 | | GET | 2 | | 1 | | | |
-| 3 | 1 | 3 | | GET | 3 | | 1 | | | |
-| 4 | 1 | 3 | | POST | 4 | | 1 | | | |
-+-----+------------+---------+----------+--------+---------------+---------+-----------+---------+------------+----------+
-```
-
-### paths
-
-```
-+----+--------------------------------------------------------+
-| id | path |
-+----+--------------------------------------------------------+
-| 1 | / |
-| 2 | admin |
-| 3 | login |
-| 4 | admin/languages |
-| 5 | admin/tracker |
-| 6 | admin/pages |
-| 7 | jmx-console |
-| 8 | manager/html |
-| 9 | administrator |
-| 10 | joomla/administrator |
-| 11 | cms/administrator |
-| 12 | Joomla/administrator |
-| 13 | phpmyadmin |
-| 14 | phpMyAdmin |
-| 15 | mysql |
-| 16 | sql |
-| 17 | myadmin |
-| 18 | webdav |
-+----+--------------------------------------------------------+
-```
-
-### route_paths
-
-```
-+----+----------+--------------------------------------------------------+
-| id | route_id | path |
-+----+----------+--------------------------------------------------------+
-| 1 | 1 | / |
-| 2 | 2 | admin |
-| 3 | 3 | login |
-| 4 | 4 | login |
-| 5 | 5 | admin/languages |
-| 6 | 6 | admin/tracker |
-| 7 | 7 | admin/pages |
-+----+----------+--------------------------------------------------------+
-```
-
-### routes
-
-```
-+----+--------------------------------------+----------------------------------------------------------+
-| id | name | action |
-+----+--------------------------------------+----------------------------------------------------------+
-| 1 | home | ACR\Controllers\Home@index |
-| 2 | admin | ACR\Controllers\Admin\Admin@index |
-| 3 | login.form | ACR\Controllers\Logon@form |
-| 4 | login.do | ACR\Controllers\Logon@login |
-| 5 | admin.languages.index | ACR\Controllers\Admin\Languages@index |
-| 6 | admin.tracker.index | ACR\Controllers\Admin\Tracker@index |
-| 7 | admin.pages.index | ACR\Controllers\Admin\Pages@index |
-| 8 | admin.tracker.log | ACR\Controllers\Admin\Tracker@log |
-| 9 | technology | ACR\Controllers\Technology@index |
-| 10 | technology.articles.show | ACR\Controllers\Technology@show |
-| 11 | language.select | ACR\Controllers\Language@select |
-| 12 | admin.tracker.summary | ACR\Controllers\Admin\Tracker@summary |
-| 13 | admin.tracker.api.pageviews | ACR\Controllers\Admin\Tracker@apiPageviews |
-| 14 | admin.tracker.api.pageviewsbycountry | ACR\Controllers\Admin\Tracker@apiPageviewsByCountry |
-| 15 | admin.pages.create | ACR\Controllers\Admin\Pages@create |
-| 16 | api.markdown | ACR\Controllers\Api@markdown |
-| 17 | admin.pages.store | ACR\Controllers\Admin\Pages@store |
-| 18 | bio | ACR\Controllers\StaticPages@show |
-| 19 | logout.do | ACR\Controllers\Logon@logout |
-| 20 | admin.tracker.index | ACR\Controllers\Admin\UsageTracker@index |
-| 21 | admin.tracker.api.pageviewsbycountry | ACR\Controllers\Admin\UsageTracker@apiPageviewsByCountry |
-| 22 | admin.tracker.api.pageviews | ACR\Controllers\Admin\UsageTracker@apiPageviews |
-+----+--------------------------------------+----------------------------------------------------------+
-```
-
-### sql_queries ;
-
-```
-+----+------------------------------------------+-------------------------------------------------------------------------------------------------+-------+---------------+
-| id | sha1 | statement | time | connection_id |
-+----+------------------------------------------+-------------------------------------------------------------------------------------------------+-------+---------------+
-| 1 | 5aee121018ac16dbf26dbbe0cf35fd44a29a5d7e | select * from "users" where "id" = ? limit 1 | 3.13 | 1 |
-| 2 | 0fc3f3a722b0f9ef38e6bee44fc3fde9fb1fd1d9 | select "created_at" from "articles" where "published_at" is not null order by "created_at" desc | 1.99 | 1 |
-+----+------------------------------------------+-------------------------------------------------------------------------------------------------+-------+---------------+
-```
-
-## Manually log things
-
-If your application has special needs, you can manually log things like:
-
-#### Events
-
-```php
-Tracker::trackEvent(['event' => 'cart.add']);
-Tracker::trackEvent(['event' => 'cart.add', 'object' => 'App\Cart\Events\Add']);
-```
-
-#### Routes
-
-```php
-Tracker::trackVisit(
- [
- 'name' => 'my.dynamic.route.name',
- 'action' => 'MyDynamic@url'
- ],
- ['path' => 'my/dynamic/url']
-);
-```
-
-## 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 pragmarx/tracker
-
-#### Add the service provider to your app/config/app.php:
-
-```php
-'PragmaRX\Tracker\Vendor\Laravel\ServiceProvider',
-```
-
-#### Add the alias to the facade on your app/config/app.php:
-
-```php
-'Tracker' => 'PragmaRX\Tracker\Vendor\Laravel\Facade',
-```
-
-#### Publish tracker configuration:
-
-**Laravel 4**
-
- php artisan config:publish pragmarx/tracker
-
-**Laravel 5**
-
- php artisan vendor:publish --provider=PragmaRX\\Tracker\\Vendor\\Laravel\\ServiceProvider
-
-#### Enable the Middleware (Laravel 5)
-
-```php
-'use_middleware' => true,
-```
-
-#### Add the Middleware to Laravel Kernel (Laravel 5)
-
-Open the file `app/Http/Kernel.php` and add the following to your web middlewares:
-
-```php
-\PragmaRX\Tracker\Vendor\Laravel\Middlewares\Tracker::class,
-```
-
-#### Enable Tracker in your config.php (Laravel 4) or tracker.php (Laravel 5)
-
-```php
-'enabled' => true,
-```
-
-#### 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`
-
-```php
-'connections' => [
- 'mysql' => [
- ...
- ],
-
- 'tracker' => [
- 'driver' => '...',
- 'host' => '...',
- 'database' => ...,
- 'strict' => false, // to avoid problems on some MySQL installs
- ...
- ],
-],
-```
-
-#### 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:
-
-```php
-'log_enabled' => true,
-```
-
-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:
-
-```php
-'authentication_ioc_binding' => ['auth', 'admin'],
-```
-
-## 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:
-
-```php
-'stats_panel_enabled' => true,
-```
-
-Set the web middleware for stats routes (Laravel 5)
-
-```php
-'stats_routes_middleware' => 'web',
-```
-
-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:
-
-```php
-public function getIsAdminAttribute()
- {
- return true;
- }
-```
-
-It can be 'admin', 'is_admin', 'root' or 'is_root'.
-
-## Troubleshooting
-
-### 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
-
-```sql
-set session sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
-```
-
-You may need to change your Tracker database connection configuration to
-
-```php
-'connections' => [
- ...
-
- 'tracker' => [
- ...
-
- 'strict' => false,
- ],
-],
-
-```
-
-## Author
-
-[Antonio Carlos Ribeiro](http://twitter.com/iantonioribeiro)
-
-## 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.
-
+# Laravel Stats Tracker
+
+[](https://packagist.org/packages/pragmarx/tracker) [](LICENSE) [](https://packagist.org/packages/pragmarx/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?](#why)
+- [How To Use It](#usage)
+- [Screenshots](#screenshots)
+- [Blade Views](#views)
+- [Table Schemas](#how-data-is-stored)
+- [System Requirements](#requirements)
+- [Installing](#installing)
+- [Upgrading](upgrading.md)
+- [Changelog](changelog.md)
+- [Contributing](#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
+
+```php
+$visitor = Tracker::currentSession();
+```
+
+Most of those methods return an Eloquent model or collection, so you can use not only its attributes, but also relational data:
+
+```php
+var_dump( $visitor->client_ip );
+
+var_dump( $visitor->device->is_mobile );
+
+var_dump( $visitor->device->platform );
+
+var_dump( $visitor->geoIp->city );
+
+var_dump( $visitor->language->preference );
+
+```
+
+#### Sessions (visits)
+
+```php
+$sessions = Tracker::sessions(60 * 24); // get sessions (visits) from the past day
+```
+
+```php
+foreach ($sessions as $session)
+{
+ var_dump( $session->user->email );
+
+ var_dump( $session->device->kind . ' - ' . $session->device->platform );
+
+ var_dump( $session->agent->browser . ' - ' . $session->agent->browser_version );
+
+ var_dump( $session->geoIp->country_name );
+
+ foreach ($session->session->log as $log)
+ {
+ var_dump( $log->path );
+ }
+}
+```
+
+#### Online Users
+
+Brings all online sessions (logged and unlogged users)
+
+```php
+$users = Tracker::onlineUsers(); // defaults to 3 minutes
+```
+
+#### Users
+
+```php
+$users = Tracker::users(60 * 24);
+```
+
+#### User Devices
+
+```php
+$users = Tracker::userDevices(60 * 24, $user->id);
+```
+
+#### Events
+
+```php
+$events = Tracker::events(60 * 24);
+```
+
+#### Errors
+
+```php
+$errors = Tracker::errors(60 * 24);
+```
+
+#### PageViews summary
+
+```php
+$pageViews = Tracker::pageViews(60 * 24 * 30);
+```
+
+#### PageViews By Country summary
+
+```php
+$pageViews = Tracker::pageViewsByCountry(60 * 24);
+```
+
+#### Filter range
+
+You can send timestamp ranges to those methods using the Minutes class:
+
+```php
+$range = new Minutes();
+
+$range->setStart(Carbon::now()->subDays(2));
+
+$range->setEnd(Carbon::now()->subDays(1));
+
+Tracker::userDevices($range);
+```
+
+#### Routes By Name
+
+Having a route of
+
+```php
+Route::get('user/{id}', ['as' => 'user.profile', 'use' => 'UsersController@profile']);
+```
+
+You can use this method to select all hits on that particular route and count them using Laravel:
+
+```php
+return Tracker::logByRouteName('user.profile')
+ ->where(function($query)
+ {
+ $query
+ ->where('parameter', 'id')
+ ->where('value', 1);
+ })
+ ->count();
+```
+
+And if you need count how many unique visitors accessed that route, you can do:
+
+```php
+return Tracker::logByRouteName('tracker.stats.log')
+ ->where(function($query)
+ {
+ $query
+ ->where('parameter', 'uuid')
+ ->where('value', '8b6faf82-00f1-4db9-88ad-32e58cfb4f9d');
+ })
+ ->select('tracker_log.session_id')
+ ->groupBy('tracker_log.session_id')
+ ->distinct()
+ ->count('tracker_log.session_id');
+```
+
+## 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
+
+```
++-----+--------------------------------------+---------+-----------+----------+-----------------+------------+-----------+----------+-------------+
+| id | uuid | user_id | device_id | agent_id | client_ip | referer_id | cookie_id | geoip_id | language_id |
++-----+--------------------------------------+---------+-----------+----------+-----------------+------------+-----------+----------+-------------+
+| 1 | 09465be3-5930-4581-8711-5161f62c4373 | 1 | 1 | 1 | 186.228.127.245 | 2 | 1 | 2 | 3 |
+| 2 | 07399969-0a19-47f0-862d-43b06d7cde45 | | 2 | 2 | 66.240.192.138 | | 2 | 2 | 2 |
++-----+--------------------------------------+---------+-----------+----------+-----------------+------------+-----------+----------+-------------+
+```
+
+### devices
+
+```
++----+----------+-------------+-------------+------------------+-----------+
+| id | kind | model | platform | platform_version | is_mobile |
++----+----------+-------------+-------------+------------------+-----------+
+| 1 | Computer | unavailable | Windows 8 | | |
+| 2 | Tablet | iPad | iOS | 7.1.1 | 1 |
+| 3 | Computer | unavailable | Windows XP | | |
+| 5 | Computer | unavailable | Other | | |
+| 6 | Computer | unavailable | Windows 7 | | |
+| 7 | Computer | unavailable | Windows 8.1 | | |
+| 8 | Phone | iPhone | iOS | 7.1 | 1 |
++----+----------+-------------+-------------+------------------+-----------+
+```
+
+### agents
+
+```
++----+-----------------------------------------------------------------------------------------------------------------------------------------+-------------------+-----------------+
+| id | name | browser | browser_version |
++----+-----------------------------------------------------------------------------------------------------------------------------------------+-------------------+-----------------+
+| 1 | Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36 | Chrome | 35.0.1916 |
+| 2 | Mozilla/5.0 (iPad; CPU OS 7_1_1 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) CriOS/34.0.1847.18 Mobile/11D201 Safari/9537.53 | Chrome Mobile iOS | 34.0.1847 |
+| 3 | Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) | IE | 6.0 |
+| 4 | Python-urllib/2.6 | Other | |
+| 5 | Other | Other | |
+| 6 | Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.137 Safari/537.36 | Chrome | 34.0.1847 |
+| 7 | Mozilla/5.0 (Windows NT 6.3; rv:28.0) Gecko/20100101 Firefox/28.0 | Firefox | 28.0 |
+| 8 | Mozilla/5.0 (iPhone; CPU iPhone OS 7_1 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0 Mobile/11D169 Safari/9537.53 | Mobile Safari | 7.0 |
++----+-----------------------------------------------------------------------------------------------------------------------------------------+-------------------+-----------------+
+```
+
+### languages
+
+```
++----+------------+----------------+
+| id | preference | language_range |
++----+------------+----------------+
+| 1 | en | ru=0.8,es=0.5 |
+| 2 | es | en=0.7,ru=0.3 |
+| 3 | ru | en=0.5,es=0.5 |
++----+------------+----------------+
+```
+
+
+### domains
+
+```
++----+--------------------------+
+| id | name |
++----+--------------------------+
+| 1 | antoniocarlosribeiro.com |
++----+--------------------------+
+```
+
+### errors
+
+```
++----+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+| id | code | message |
++----+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+| 1 | 404 | |
+| 2 | 500 | Call to undefined method PragmaRX\Tracker\Tracker::sessionLog() |
+| 3 | 500 | Trying to get property of non-object (View: /home/forge/stage.antoniocarlosribeiro.com/app/views/admin/tracker/log.blade.php) |
+| 4 | 500 | syntax error, unexpected 'foreach' (T_FOREACH) |
+| 5 | 500 | Call to undefined method PragmaRX\Tracker\Tracker::pageViewsByCountry() |
+| 6 | 500 | Class PragmaRX\Firewall\Vendor\Laravel\Artisan\Base contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Illuminate\Console\Command::fire) |
+| 7 | 405 | |
+| 8 | 500 | Trying to get property of non-object |
+| 9 | 500 | Missing argument 2 for Illuminate\Database\Eloquent\Model::setAttribute(), called in /home/forge/stage.antoniocarlosribeiro.com/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php on line 2444 and defined |
++----+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+```
+
+### events
+
+```
++----+------------------------------------------------+
+| id | name |
++----+------------------------------------------------+
+| 1 | illuminate.log |
+| 2 | router.before |
+| 3 | router.matched |
+| 4 | auth.attempt |
+| 5 | auth.login |
+| 6 | composing: admin.tracker.index |
+| 7 | creating: admin.tracker._partials.menu |
+| 8 | composing: admin.tracker._partials.menu |
+| 9 | creating: admin.layout |
+| 10 | composing: admin.layout |
+| 11 | creating: admin._partials.mainMenu |
+| 12 | composing: admin._partials.mainMenu |
+| 13 | creating: admin._partials.messages |
+| 14 | composing: admin._partials.messages |
+| 15 | creating: global._partials.google-analytics |
+| 16 | composing: global._partials.google-analytics |
++----+------------------------------------------------+
+```
+
+### geoip
+
+```
++----+----------+-----------+--------------+---------------+---------------------------+--------+----------------+-------------+-----------+----------+------------+----------------+
+| id | latitude | longitude | country_code | country_code3 | country_name | region | city | postal_code | area_code | dma_code | metro_code | continent_code |
++----+----------+-----------+--------------+---------------+---------------------------+--------+----------------+-------------+-----------+----------+------------+----------------+
+| 1 | 37.4192 | -122.057 | US | USA | United States | CA | Mountain View | 94043 | 650 | 807 | 807 | NA |
+| 2 | -10 | -55 | BR | BRA | Brazil | | | | | | | SA |
+| 3 | 30.3909 | -86.3161 | US | USA | United States | FL | Miramar Beach | 32550 | 850 | 686 | 686 | NA |
+| 4 | 38.65 | -90.5334 | US | USA | United States | MO | Chesterfield | 63017 | 314 | 609 | 609 | NA |
+| 5 | 42.7257 | -84.636 | US | USA | United States | MI | Lansing | 48917 | 517 | 551 | 551 | NA |
+| 6 | 42.8884 | -78.8761 | US | USA | United States | NY | Buffalo | 14202 | 716 | 514 | 514 | NA |
+| 7 | 40.1545 | -75.3809 | US | USA | United States | PA | Norristown | 19403 | 610 | 504 | 504 | NA |
+| 8 | 47.4891 | -122.291 | US | USA | United States | WA | Seattle | 98168 | 206 | 819 | 819 | NA |
+| 9 | 33.7516 | -84.3915 | US | USA | United States | GA | Atlanta | 30303 | 404 | 524 | 524 | NA |
+| 10 | 33.7633 | -117.794 | US | USA | United States | CA | Santa Ana | 92705 | 714 | 803 | 803 | NA |
+| 11 | 33.4357 | -111.917 | US | USA | United States | AZ | Tempe | 85281 | 480 | 753 | 753 | NA |
+| 12 | 40.7421 | -74.0018 | US | USA | United States | NY | New York | 10011 | 212 | 501 | 501 | NA |
+| 13 | 28.6185 | -81.4336 | US | USA | United States | FL | Orlando | 32810 | 407 | 534 | 534 | NA |
+| 14 | 38.6312 | -90.1922 | US | USA | United States | MO | Saint Louis | 63101 | 314 | 609 | 609 | NA |
+| 15 | 51 | 9 | DE | DEU | Germany | | | | | | | EU |
+| 16 | 52.5 | 5.75 | NL | NLD | Netherlands | | | | | | | EU |
+| 17 | 48.86 | 2.35 | FR | FRA | France | | | | | | | EU |
+| 18 | 60 | 100 | RU | RUS | Russian Federation | | | | | | | EU |
+| 19 | 51.5 | -0.13 | GB | GBR | United Kingdom | | | | | | | EU |
+| 20 | 42.8333 | 12.8333 | IT | ITA | Italy | | | | | | | EU |
+| 21 | 59.3333 | 18.05 | SE | SWE | Sweden | 26 | Stockholm | | | | | EU |
+| 22 | -41 | 174 | NZ | NZL | New Zealand | | | | | | | OC |
+| 23 | 37.57 | 126.98 | KR | KOR | Korea, Republic of | | | | | | | AS |
+| 24 | 1.3667 | 103.8 | SG | SGP | Singapore | | | | | | | AS |
+| 25 | -43.5333 | 172.633 | NZ | NZL | New Zealand | E9 | Christchurch | 8023 | | | | OC |
+| 26 | -27.471 | 153.024 | AU | AUS | Australia | 04 | Brisbane | | | | | OC |
+| 27 | 26.9167 | 75.8167 | IN | IND | India | 24 | Jaipur | | | | | AS |
+| 28 | 32 | 53 | IR | IRN | Iran, Islamic Republic of | | | | | | | AS |
+| 29 | 32.0617 | 118.778 | CN | CHN | China | 04 | Nanjing | | | | | AS |
+| 30 | -22.9 | -47.0833 | BR | BRA | Brazil | 27 | Campinas | | | | | SA |
+| 31 | 32.8073 | -117.132 | US | USA | United States | CA | San Diego | 92123 | 858 | 825 | 825 | NA |
+| 32 | -22.9 | -43.2333 | BR | BRA | Brazil | 21 | Rio De Janeiro | | | | | SA |
++----+----------+-----------+--------------+---------------+---------------------------+--------+----------------+-------------+-----------+----------+------------+----------------+
+```
+
+### log
+
+```
++-----+------------+---------+----------+--------+---------------+---------+-----------+---------+------------+----------+
+| id | session_id | path_id | query_id | method | route_path_id | is_ajax | is_secure | is_json | wants_json | error_id |
++-----+------------+---------+----------+--------+---------------+---------+-----------+---------+------------+----------+
+| 1 | 1 | 1 | | GET | 1 | | 1 | | | |
+| 2 | 1 | 2 | | GET | 2 | | 1 | | | |
+| 3 | 1 | 3 | | GET | 3 | | 1 | | | |
+| 4 | 1 | 3 | | POST | 4 | | 1 | | | |
++-----+------------+---------+----------+--------+---------------+---------+-----------+---------+------------+----------+
+```
+
+### paths
+
+```
++----+--------------------------------------------------------+
+| id | path |
++----+--------------------------------------------------------+
+| 1 | / |
+| 2 | admin |
+| 3 | login |
+| 4 | admin/languages |
+| 5 | admin/tracker |
+| 6 | admin/pages |
+| 7 | jmx-console |
+| 8 | manager/html |
+| 9 | administrator |
+| 10 | joomla/administrator |
+| 11 | cms/administrator |
+| 12 | Joomla/administrator |
+| 13 | phpmyadmin |
+| 14 | phpMyAdmin |
+| 15 | mysql |
+| 16 | sql |
+| 17 | myadmin |
+| 18 | webdav |
++----+--------------------------------------------------------+
+```
+
+### route_paths
+
+```
++----+----------+--------------------------------------------------------+
+| id | route_id | path |
++----+----------+--------------------------------------------------------+
+| 1 | 1 | / |
+| 2 | 2 | admin |
+| 3 | 3 | login |
+| 4 | 4 | login |
+| 5 | 5 | admin/languages |
+| 6 | 6 | admin/tracker |
+| 7 | 7 | admin/pages |
++----+----------+--------------------------------------------------------+
+```
+
+### routes
+
+```
++----+--------------------------------------+----------------------------------------------------------+
+| id | name | action |
++----+--------------------------------------+----------------------------------------------------------+
+| 1 | home | ACR\Controllers\Home@index |
+| 2 | admin | ACR\Controllers\Admin\Admin@index |
+| 3 | login.form | ACR\Controllers\Logon@form |
+| 4 | login.do | ACR\Controllers\Logon@login |
+| 5 | admin.languages.index | ACR\Controllers\Admin\Languages@index |
+| 6 | admin.tracker.index | ACR\Controllers\Admin\Tracker@index |
+| 7 | admin.pages.index | ACR\Controllers\Admin\Pages@index |
+| 8 | admin.tracker.log | ACR\Controllers\Admin\Tracker@log |
+| 9 | technology | ACR\Controllers\Technology@index |
+| 10 | technology.articles.show | ACR\Controllers\Technology@show |
+| 11 | language.select | ACR\Controllers\Language@select |
+| 12 | admin.tracker.summary | ACR\Controllers\Admin\Tracker@summary |
+| 13 | admin.tracker.api.pageviews | ACR\Controllers\Admin\Tracker@apiPageviews |
+| 14 | admin.tracker.api.pageviewsbycountry | ACR\Controllers\Admin\Tracker@apiPageviewsByCountry |
+| 15 | admin.pages.create | ACR\Controllers\Admin\Pages@create |
+| 16 | api.markdown | ACR\Controllers\Api@markdown |
+| 17 | admin.pages.store | ACR\Controllers\Admin\Pages@store |
+| 18 | bio | ACR\Controllers\StaticPages@show |
+| 19 | logout.do | ACR\Controllers\Logon@logout |
+| 20 | admin.tracker.index | ACR\Controllers\Admin\UsageTracker@index |
+| 21 | admin.tracker.api.pageviewsbycountry | ACR\Controllers\Admin\UsageTracker@apiPageviewsByCountry |
+| 22 | admin.tracker.api.pageviews | ACR\Controllers\Admin\UsageTracker@apiPageviews |
++----+--------------------------------------+----------------------------------------------------------+
+```
+
+### sql_queries ;
+
+```
++----+------------------------------------------+-------------------------------------------------------------------------------------------------+-------+---------------+
+| id | sha1 | statement | time | connection_id |
++----+------------------------------------------+-------------------------------------------------------------------------------------------------+-------+---------------+
+| 1 | 5aee121018ac16dbf26dbbe0cf35fd44a29a5d7e | select * from "users" where "id" = ? limit 1 | 3.13 | 1 |
+| 2 | 0fc3f3a722b0f9ef38e6bee44fc3fde9fb1fd1d9 | select "created_at" from "articles" where "published_at" is not null order by "created_at" desc | 1.99 | 1 |
++----+------------------------------------------+-------------------------------------------------------------------------------------------------+-------+---------------+
+```
+
+## Manually log things
+
+If your application has special needs, you can manually log things like:
+
+#### Events
+
+```php
+Tracker::trackEvent(['event' => 'cart.add']);
+Tracker::trackEvent(['event' => 'cart.add', 'object' => 'App\Cart\Events\Add']);
+```
+
+#### Routes
+
+```php
+Tracker::trackVisit(
+ [
+ 'name' => 'my.dynamic.route.name',
+ 'action' => 'MyDynamic@url'
+ ],
+ ['path' => 'my/dynamic/url']
+);
+```
+
+## 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 pragmarx/tracker
+
+#### Add the service provider to your app/config/app.php:
+
+```php
+ PragmaRX\Tracker\Vendor\Laravel\ServiceProvider::class,
+```
+
+#### Add the alias to the facade on your app/config/app.php:
+
+```php
+'Tracker' => 'PragmaRX\Tracker\Vendor\Laravel\Facade',
+```
+
+#### Publish tracker configuration:
+
+**Laravel 4**
+
+ php artisan config:publish pragmarx/tracker
+
+**Laravel 5**
+
+ php artisan vendor:publish --provider="PragmaRX\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`:
+
+```php
+'use_middleware' => true,
+```
+
+#### Add the Middleware to Laravel Kernel (Laravel 5)
+
+Open the file `app/Http/Kernel.php` and add the following to your web middlewares:
+
+```php
+\PragmaRX\Tracker\Vendor\Laravel\Middlewares\Tracker::class,
+```
+
+#### Enable Tracker in your config.php (Laravel 4) or tracker.php (Laravel 5)
+
+```php
+'enabled' => true,
+```
+
+#### 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`
+
+```php
+'connections' => [
+ 'mysql' => [
+ ...
+ ],
+
+ 'tracker' => [
+ 'driver' => '...',
+ 'host' => '...',
+ 'database' => ...,
+ 'strict' => false, // to avoid problems on some MySQL installs
+ ...
+ ],
+],
+```
+
+#### 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:
+
+```php
+'log_enabled' => true,
+```
+
+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:
+
+```php
+'authentication_ioc_binding' => ['auth', 'admin'],
+```
+
+## 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:
+
+```php
+'stats_panel_enabled' => true,
+```
+
+Set the web middleware for stats routes (Laravel 5)
+
+```php
+'stats_routes_middleware' => 'web',
+```
+
+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:
+
+```php
+public function getIsAdminAttribute()
+{
+ return true;
+}
+```
+
+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
+
+``` php
+tail -f storage/logs/laravel.log
+```
+
+Usually non-trackable IP addresses and other messages will appear in the log:
+
+```
+[2018-03-19 21:28:08] local.WARNING: TRACKER (unable to track item): 127.0.0.1 is not trackable.
+```
+
+### 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
+
+```sql
+set session sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
+```
+
+You may need to change your Tracker database connection configuration to
+
+```php
+'connections' => [
+ ...
+
+ 'tracker' => [
+ ...
+
+ 'strict' => false,
+ ],
+],
+
+```
+
+## 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' => 'PragmaRX\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' => [
+ .......
+ \PragmaRX\Tracker\Vendor\Laravel\Middlewares\Tracker::class,
+ ],
+
+ 'api' => [
+ .......
+ \PragmaRX\Tracker\Vendor\Laravel\Middlewares\Tracker::class,
+ ],
+ ];
+
+
+## Author
+
+[Antonio Carlos Ribeiro](http://twitter.com/iantonioribeiro)
+[All Contributors](https://github.com/antonioribeiro/tracker/graphs/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.
diff --git a/src/Data/Repositories/Cookie.php b/src/Data/Repositories/Cookie.php
index 2a70df09..f7227062 100644
--- a/src/Data/Repositories/Cookie.php
+++ b/src/Data/Repositories/Cookie.php
@@ -33,7 +33,7 @@ public function getId()
}
if (!$cookie = $this->request->cookie($this->config->get('tracker_cookie_name'))) {
- $cookie = (string) UUID::uuid4();
+ $cookie = UUID::uuid4()->toString();
$this->cookieJar->queue($this->config->get('tracker_cookie_name'), $cookie, 0);
}
diff --git a/src/Data/Repositories/Error.php b/src/Data/Repositories/Error.php
index b9d20e45..5eaa1157 100644
--- a/src/Data/Repositories/Error.php
+++ b/src/Data/Repositories/Error.php
@@ -4,22 +4,22 @@
class Error extends Repository
{
- public function getMessageFromException($exception)
+ public function getMessageFromThrowable($throwable)
{
- if ($message = $exception->getMessage()) {
+ if ($message = $throwable->getMessage()) {
return $message;
}
return $message;
}
- public function getCodeFromException($exception)
+ public function getCodeFromThrowable($throwable)
{
- if (method_exists($exception, 'getCode') && $code = $exception->getCode()) {
+ if (method_exists($throwable, 'getCode') && $code = $throwable->getCode()) {
return $code;
}
- if (method_exists($exception, 'getStatusCode') && $code = $exception->getStatusCode()) {
+ if (method_exists($throwable, 'getStatusCode') && $code = $throwable->getStatusCode()) {
return $code;
}
}
diff --git a/src/Data/Repositories/Event.php b/src/Data/Repositories/Event.php
index d32c9f71..f586eb6e 100644
--- a/src/Data/Repositories/Event.php
+++ b/src/Data/Repositories/Event.php
@@ -165,9 +165,9 @@ private function getEventId($event)
{
return $event['event']
? $this->findOrCreate(
- ['name' => $event['event']],
- ['name']
- )
+ ['name' => $event['event']],
+ ['name']
+ )
: null;
}
diff --git a/src/Data/Repositories/Log.php b/src/Data/Repositories/Log.php
index f84c9c73..b3cad69d 100644
--- a/src/Data/Repositories/Log.php
+++ b/src/Data/Repositories/Log.php
@@ -4,9 +4,9 @@
class Log extends Repository
{
- private $currentLogId;
+ protected $currentLogId;
- private $route_path_id;
+ protected $route_path_id;
public function updateRoute($route_path_id = null)
{
diff --git a/src/Data/Repositories/Session.php b/src/Data/Repositories/Session.php
index 36d8731c..34c4ed4c 100644
--- a/src/Data/Repositories/Session.php
+++ b/src/Data/Repositories/Session.php
@@ -132,6 +132,9 @@ private function ensureSessionDataIsComplete()
$wasComplete = true;
foreach ($this->sessionInfo as $key => $value) {
+ if ($key === 'user_agent') {
+ continue;
+ }
if ($sessionData[$key] !== $value) {
if (!isset($model)) {
$model = $this->find($this->sessionInfo['id']);
@@ -175,7 +178,7 @@ private function getSystemSessionId()
return $sessionData['uuid'];
}
- return (string) UUID::uuid4();
+ return UUID::uuid4()->toString();
}
private function regenerateSystemSession($data = null)
diff --git a/src/Data/Repositories/SqlQuery.php b/src/Data/Repositories/SqlQuery.php
index 34dd0cd7..afe18d40 100644
--- a/src/Data/Repositories/SqlQuery.php
+++ b/src/Data/Repositories/SqlQuery.php
@@ -38,13 +38,14 @@ class SqlQuery extends Repository
*/
private $config;
- public function __construct($model,
- SqlQueryLog $sqlQueryLogRepository,
- SqlQueryBinding $sqlQueryBindingRepository,
- SqlQueryBindingParameter $sqlQueryBindingParameterRepository,
- Connection $connectionRepository,
- Log $logRepository,
- Config $config
+ public function __construct(
+ $model,
+ SqlQueryLog $sqlQueryLogRepository,
+ SqlQueryBinding $sqlQueryBindingRepository,
+ SqlQueryBindingParameter $sqlQueryBindingParameterRepository,
+ Connection $connectionRepository,
+ Log $logRepository,
+ Config $config
) {
parent::__construct($model);
diff --git a/src/Data/RepositoryManager.php b/src/Data/RepositoryManager.php
index 7a5ee4d7..fbc15211 100644
--- a/src/Data/RepositoryManager.php
+++ b/src/Data/RepositoryManager.php
@@ -316,7 +316,7 @@ public function findOrCreateQuery($data)
[
'query_id' => $id,
'argument' => $argument,
- 'value' => $value,
+ 'value' => empty($value) ? '' : $value,
]
);
}
@@ -642,12 +642,12 @@ public function getSessionLog($uuid, $results = true)
return $this->logRepository->bySession($session->id, $results);
}
- public function handleException($exception)
+ public function handleThrowable($throwable)
{
$error_id = $this->errorRepository->findOrCreate(
[
- 'message' => $this->errorRepository->getMessageFromException($exception),
- 'code' => $this->errorRepository->getCodeFromException($exception),
+ 'message' => $this->errorRepository->getMessageFromThrowable($throwable),
+ 'code' => $this->errorRepository->getCodeFromThrowable($throwable),
],
['message', 'code']
);
diff --git a/src/Services/Authentication.php b/src/Services/Authentication.php
index 633e0bff..76b60b8c 100644
--- a/src/Services/Authentication.php
+++ b/src/Services/Authentication.php
@@ -27,7 +27,19 @@ public function check()
private function executeAuthMethod($method)
{
+ $guards = $this->config->get('authentication_guards');
+ // Make sure authentication_guards at least contains a null value to DRY code
+ if (empty($guards)) {
+ $guards[] = null;
+ }
+
foreach ($this->getAuthentication() as $auth) {
+ foreach ($guards as $guard) {
+ // Call guard() if not null
+ if ($guard && $guard != 'null') {
+ $auth = $auth->guard($guard);
+ }
+ }
if (is_callable([$auth, $method], true, $callable_name)) {
if ($data = $auth->$method()) {
return $data;
diff --git a/src/Support/Exceptions/Handler.php b/src/Support/Exceptions/Handler.php
index b2111d65..f95cf6b8 100644
--- a/src/Support/Exceptions/Handler.php
+++ b/src/Support/Exceptions/Handler.php
@@ -2,9 +2,9 @@
namespace PragmaRX\Tracker\Support\Exceptions;
-use Exception;
use Illuminate\Contracts\Debug\ExceptionHandler;
use PragmaRX\Tracker\Tracker;
+use Throwable;
class Handler implements ExceptionHandler
{
@@ -27,21 +27,21 @@ public function __construct(Tracker $tracker, $illuminateHandler = null)
private function initializeHandlers()
{
- $this->originalExceptionHandler = set_exception_handler([$this, 'handleException']);
+ $this->originalExceptionHandler = set_exception_handler([$this, 'handleThrowable']);
$this->originalErrorHandler = set_error_handler([$this, 'handleError']);
}
- public function handleException(Exception $exception)
+ public function handleThrowable(Throwable $throwable)
{
try {
- $this->tracker->handleException($exception, $exception->getCode());
+ $this->tracker->handleThrowable($throwable);
} catch (\Exception $e) {
// Ignore Tracker exceptions
}
// Call Laravel Exception Handler
- return call_user_func($this->originalExceptionHandler, $exception);
+ return call_user_func($this->originalExceptionHandler, $throwable);
}
public function handleError($err_severity, $err_msg, $err_file, $err_line, array $err_context)
@@ -49,7 +49,7 @@ public function handleError($err_severity, $err_msg, $err_file, $err_line, array
try {
$error = ExceptionFactory::make($err_severity, $err_msg);
- $this->tracker->handleException($error, $error->getCode());
+ $this->tracker->handleThrowable($error);
} catch (\Exception $e) {
// Ignore Tracker exceptions
}
@@ -58,10 +58,10 @@ public function handleError($err_severity, $err_msg, $err_file, $err_line, array
return call_user_func($this->originalErrorHandler, $err_severity, $err_msg, $err_file, $err_line);
}
- public function report(Exception $e)
+ public function report(Throwable $e)
{
try {
- $this->tracker->handleException($e);
+ $this->tracker->handleThrowable($e);
} catch (Exception $exception) {
// ignore
}
@@ -69,12 +69,17 @@ public function report(Exception $e)
$this->illuminateHandler->report($e);
}
- public function render($request, Exception $e)
+ public function shouldReport(Throwable $e)
+ {
+ return $this->illuminateHandler->shouldReport($e);
+ }
+
+ public function render($request, Throwable $e)
{
return $this->illuminateHandler->render($request, $e);
}
- public function renderForConsole($output, Exception $e)
+ public function renderForConsole($output, Throwable $e)
{
return $this->illuminateHandler->renderForConsole($output, $e);
}
diff --git a/src/Support/Migration.php b/src/Support/Migration.php
index a0993e37..787cf552 100644
--- a/src/Support/Migration.php
+++ b/src/Support/Migration.php
@@ -10,7 +10,7 @@ protected function checkConnection()
{
$this->manager = app()->make('db');
- $this->connection = $this->manager->connection('tracker');
+ $this->connection = $this->manager->connection(config('tracker.connection'));
parent::checkConnection();
}
diff --git a/src/Support/MobileDetect.php b/src/Support/MobileDetect.php
index 06173166..1bed6d92 100644
--- a/src/Support/MobileDetect.php
+++ b/src/Support/MobileDetect.php
@@ -14,11 +14,11 @@ class MobileDetect extends Agent
public function detectDevice()
{
return [
- 'kind' => $this->getDeviceKind(),
- 'model' => $this->device(),
- 'is_mobile' => $this->isMobile(),
- 'is_robot' => $this->isRobot(),
- ];
+ 'kind' => $this->getDeviceKind(),
+ 'model' => $this->device(),
+ 'is_mobile' => $this->isMobile(),
+ 'is_robot' => $this->isRobot(),
+ ];
}
/**
diff --git a/src/Support/UserAgentParser.php b/src/Support/UserAgentParser.php
index addd4d7e..d6c975c4 100644
--- a/src/Support/UserAgentParser.php
+++ b/src/Support/UserAgentParser.php
@@ -16,13 +16,9 @@ class UserAgentParser
public $originalUserAgent;
- public function __construct($basePath, $userAgent = null)
+ public function __construct($basePath, $userAgent = '')
{
- if (!$userAgent && isset($_SERVER['HTTP_USER_AGENT'])) {
- $userAgent = $_SERVER['HTTP_USER_AGENT'];
- }
-
- $this->parser = Parser::create()->parse($userAgent);
+ $this->parser = Parser::create()->parse($this->getUserAgent($userAgent));
$this->userAgent = $this->parser->ua;
@@ -42,6 +38,19 @@ public function getOperatingSystemVersion()
($this->operatingSystem->patch !== null ? '.'.$this->operatingSystem->patch : '');
}
+ protected function getUserAgent($userAgent)
+ {
+ if (!empty($userAgent)) {
+ return $userAgent;
+ }
+
+ if (isset($_SERVER['HTTP_USER_AGENT']) && !empty($_SERVER['HTTP_USER_AGENT'])) {
+ return $_SERVER['HTTP_USER_AGENT'];
+ }
+
+ return config('tracker.default_user_agent', '');
+ }
+
public function getUserAgentVersion()
{
return $this->userAgent->major.
diff --git a/src/Tracker.php b/src/Tracker.php
index 176e3252..7fde4dd0 100644
--- a/src/Tracker.php
+++ b/src/Tracker.php
@@ -4,7 +4,6 @@
use Illuminate\Foundation\Application as Laravel;
use Illuminate\Http\Request;
-use Illuminate\Log\Writer as Logger;
use Illuminate\Routing\Router;
use PragmaRX\Support\Config;
use PragmaRX\Support\GeoIp\Updater as GeoIpUpdater;
@@ -12,6 +11,7 @@
use PragmaRX\Tracker\Data\RepositoryManager as DataRepositoryManager;
use PragmaRX\Tracker\Repositories\Message as MessageRepository;
use PragmaRX\Tracker\Support\Minutes;
+use Psr\Log\LoggerInterface;
class Tracker
{
@@ -23,6 +23,7 @@ class Tracker
protected $route;
protected $logger;
+
/**
* @var \Illuminate\Foundation\Application
*/
@@ -32,20 +33,21 @@ class Tracker
protected $sessionData;
- private $loggedItems = [];
+ protected $loggedItems = [];
+
+ protected $booted = false;
- private $booted = false;
/**
* @var MessageRepository
*/
- private $messageRepository;
+ protected $messageRepository;
public function __construct(
Config $config,
DataRepositoryManager $dataRepositoryManager,
Request $request,
Router $route,
- Logger $logger,
+ LoggerInterface $logger,
Laravel $laravel,
MessageRepository $messageRepository
) {
@@ -113,7 +115,7 @@ public function events($minutes, $results = true)
return $this->dataRepositoryManager->events(Minutes::make($minutes), $results);
}
- protected function getAgentId()
+ public function getAgentId()
{
return $this->config->get('log_user_agents')
? $this->dataRepositoryManager->getAgentId()
@@ -153,7 +155,7 @@ public function getDomainId($domain)
return $this->dataRepositoryManager->getDomainId($domain);
}
- protected function getGeoIpId()
+ public function getGeoIpId()
{
return $this->config->get('log_geoip')
? $this->dataRepositoryManager->getGeoIpId($this->request->getClientIp())
@@ -163,7 +165,7 @@ protected function getGeoIpId()
/**
* @return array
*/
- protected function getLogData()
+ public function getLogData()
{
return [
'session_id' => $this->getSessionId(true),
@@ -178,7 +180,7 @@ protected function getLogData()
];
}
- private function getLogger()
+ public function getLogger()
{
return $this->logger;
}
@@ -208,7 +210,7 @@ public function getQueryId()
}
}
- protected function getRefererId()
+ public function getRefererId()
{
return $this->config->get('log_referers')
? $this->dataRepositoryManager->getRefererId(
@@ -217,12 +219,12 @@ protected function getRefererId()
: null;
}
- protected function getRoutePathId()
+ public function getRoutePathId()
{
return $this->dataRepositoryManager->getRoutePathId($this->route, $this->request);
}
- private function logUntrackable($item)
+ protected function logUntrackable($item)
{
if ($this->config->get('log_untrackable_sessions') && !isset($this->loggedItems[$item])) {
$this->getLogger()->warning('TRACKER (unable to track item): '.$item);
@@ -272,12 +274,12 @@ public function getUserId()
}
/**
- * @param \Exception $exception
+ * @param \Throwable $throwable
*/
- public function handleException($exception)
+ public function handleThrowable($throwable)
{
if ($this->config->get('log_enabled')) {
- $this->dataRepositoryManager->handleException($exception);
+ $this->dataRepositoryManager->handleThrowable($throwable);
}
}
@@ -299,7 +301,7 @@ protected function isSqlQueriesLoggableConnection($name)
);
}
- protected function isTrackable()
+ public function isTrackable()
{
return $this->config->get('enabled') &&
$this->logIsEnabled() &&
@@ -312,7 +314,7 @@ protected function isTrackable()
$this->notRobotOrTrackable();
}
- protected function isTrackableEnvironment()
+ public function isTrackableEnvironment()
{
$trackable = !in_array(
$this->laravel->environment(),
@@ -326,7 +328,7 @@ protected function isTrackableEnvironment()
return $trackable;
}
- protected function isTrackableIp()
+ public function isTrackableIp()
{
$trackable = !IpAddress::ipv4InRange(
$ipAddress = $this->request->getClientIp(),
@@ -360,7 +362,7 @@ public function logEvents()
}
}
- protected function logIsEnabled()
+ public function logIsEnabled()
{
$enabled =
$this->config->get('log_enabled') ||
@@ -438,7 +440,7 @@ public function parserIsAvailable()
return true;
}
- private function routeIsTrackable()
+ public function routeIsTrackable()
{
if (!$this->route) {
return false;
@@ -451,7 +453,7 @@ private function routeIsTrackable()
return $trackable;
}
- private function pathIsTrackable()
+ public function pathIsTrackable()
{
if (!$trackable = $this->dataRepositoryManager->pathIsTrackable($this->request->path())) {
$this->logUntrackable('path '.$this->request->path().' is not trackable.');
@@ -515,7 +517,7 @@ public function trackVisit($route, $request)
$this->dataRepositoryManager->trackRoute($route, $request);
}
- protected function turnOff()
+ public function turnOff()
{
$this->enabled = false;
}
diff --git a/src/Vendor/Laravel/Artisan/Tables.php b/src/Vendor/Laravel/Artisan/Tables.php
index 0c78241a..0ec6f4d9 100644
--- a/src/Vendor/Laravel/Artisan/Tables.php
+++ b/src/Vendor/Laravel/Artisan/Tables.php
@@ -18,6 +18,16 @@ class Tables extends Base
*/
protected $description = 'Create the migrations for Tracker database tables and columns';
+ /**
+ * Execute the command.
+ *
+ * @return void
+ */
+ public function handle()
+ {
+ $this->fire();
+ }
+
/**
* Execute the command.
*
@@ -34,12 +44,6 @@ public function fire()
$this->info("Migration created: $destination");
}
}
-
- if (isLaravel5()) {
- $this->call('optimize');
- } else {
- $this->call('dump-autoload');
- }
}
/**
@@ -63,11 +67,7 @@ protected function getBaseMigrationsPath()
{
$path = 'database'.DIRECTORY_SEPARATOR.'migrations';
- if (isLaravel5()) {
- return base_path($path);
- }
-
- return app_path($path);
+ return base_path($path);
}
/**
diff --git a/src/Vendor/Laravel/Controllers/Stats.php b/src/Vendor/Laravel/Controllers/Stats.php
index 98c64ca7..f5171833 100644
--- a/src/Vendor/Laravel/Controllers/Stats.php
+++ b/src/Vendor/Laravel/Controllers/Stats.php
@@ -5,6 +5,7 @@
use Bllim\Datatables\Facade\Datatables;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\View;
+use Illuminate\Support\Str;
use PragmaRX\Tracker\Vendor\Laravel\Facade as Tracker;
use PragmaRX\Tracker\Vendor\Laravel\Support\Session;
@@ -79,10 +80,7 @@ public function visits(Session $session)
public function log($uuid)
{
- $session = Tracker::sessionLog($uuid);
-
return View::make('pragmarx/tracker::log')
- ->with('log', Tracker::sessionLog($uuid))
->with('uuid', $uuid)
->with('title', 'log');
}
@@ -108,19 +106,19 @@ public function apiLog($uuid)
$query = Tracker::sessionLog($uuid, false);
$query->select([
- 'id',
- 'session_id',
- 'method',
- 'path_id',
- 'query_id',
- 'route_path_id',
- 'is_ajax',
- 'is_secure',
- 'is_json',
- 'wants_json',
- 'error_id',
- 'created_at',
- ]);
+ 'id',
+ 'session_id',
+ 'method',
+ 'path_id',
+ 'query_id',
+ 'route_path_id',
+ 'is_ajax',
+ 'is_secure',
+ 'is_json',
+ 'wants_json',
+ 'error_id',
+ 'created_at',
+ ]);
return Datatables::of($query)
->edit_column('route_name', function ($row) {
@@ -205,12 +203,12 @@ public function apiErrors(Session $session)
$query = Tracker::errors($session->getMinutes(), false);
$query->select([
- 'id',
- 'error_id',
- 'session_id',
- 'path_id',
- 'updated_at',
- ]);
+ 'id',
+ 'error_id',
+ 'session_id',
+ 'path_id',
+ 'updated_at',
+ ]);
return Datatables::of($query)
->edit_column('updated_at', function ($row) {
@@ -247,22 +245,22 @@ public function apiVisits(Session $session)
$query = Tracker::sessions($session->getMinutes(), false);
$query->select([
- 'id',
- 'uuid',
- 'user_id',
- 'device_id',
- 'agent_id',
- 'client_ip',
- 'referer_id',
- 'cookie_id',
- 'geoip_id',
- 'language_id',
- 'is_robot',
- 'updated_at',
+ 'id',
+ 'uuid',
+ 'user_id',
+ 'device_id',
+ 'agent_id',
+ 'client_ip',
+ 'referer_id',
+ 'cookie_id',
+ 'geoip_id',
+ 'language_id',
+ 'is_robot',
+ 'updated_at',
]);
return Datatables::of($query)
- ->edit_column('id', function ($row) use ($username_column) {
+ ->edit_column('id', function ($row) {
$uri = route('tracker.stats.log', $row->uuid);
return ''.$row->id.'';
@@ -286,7 +284,7 @@ public function apiVisits(Session $session)
return $row->user ? $row->user->$username_column : 'guest';
})
- ->add_column('device', function ($row) use ($username_column) {
+ ->add_column('device', function ($row) {
$model = ($row->device && $row->device->model && $row->device->model !== 'unavailable' ? '['.$row->device->model.']' : '');
$platform = ($row->device && $row->device->platform ? ' ['.trim($row->device->platform.' '.$row->device->platform_version).']' : '');
@@ -298,27 +296,27 @@ public function apiVisits(Session $session)
: '';
})
- ->add_column('browser', function ($row) use ($username_column) {
+ ->add_column('browser', function ($row) {
return $row->agent && $row->agent
? $row->agent->browser.' ('.$row->agent->browser_version.')'
: '';
})
- ->add_column('language', function ($row) use ($username_column) {
+ ->add_column('language', function ($row) {
return $row->language && $row->language
? $row->language->preference
: '';
})
- ->add_column('referer', function ($row) use ($username_column) {
+ ->add_column('referer', function ($row) {
return $row->referer ? $row->referer->domain->name : '';
})
- ->add_column('pageViews', function ($row) use ($username_column) {
+ ->add_column('pageViews', function ($row) {
return $row->page_views;
})
- ->add_column('lastActivity', function ($row) use ($username_column) {
+ ->add_column('lastActivity', function ($row) {
return $row->updated_at->diffForHumans();
})
@@ -335,7 +333,7 @@ private function hasAdminProperty()
$user = $this->authentication->user();
foreach ($this->adminProperties as $property) {
- $propertyCamel = camel_case($property);
+ $propertyCamel = Str::camel($property);
if (
isset($user->$property) ||
@@ -355,7 +353,7 @@ private function isAdmin()
$user = $this->authentication->user();
foreach ($this->adminProperties as $property) {
- $propertyCamel = camel_case($property);
+ $propertyCamel = Str::camel($property);
if (
(isset($user->$property) && $user->$property) ||
diff --git a/src/Vendor/Laravel/Models/Log.php b/src/Vendor/Laravel/Models/Log.php
index ac723070..1b62cd10 100644
--- a/src/Vendor/Laravel/Models/Log.php
+++ b/src/Vendor/Laravel/Models/Log.php
@@ -48,10 +48,10 @@ public function routePath()
public function pageViews($minutes, $results)
{
$query = $this->select(
- $this->getConnection()->raw('DATE(created_at) as date, count(*) as total')
- )->groupBy(
- $this->getConnection()->raw('DATE(created_at)')
- )
+ $this->getConnection()->raw('DATE(created_at) as date, count(*) as total')
+ )->groupBy(
+ $this->getConnection()->raw('DATE(created_at)')
+ )
->period($minutes)
->orderBy('date');
@@ -67,7 +67,8 @@ public function pageViewsByCountry($minutes, $results)
$query =
$this
->select(
- 'tracker_geoip.country_name as label', $this->getConnection()->raw('count(tracker_log.id) as value')
+ 'tracker_geoip.country_name as label',
+ $this->getConnection()->raw('count(tracker_log.id) as value')
)
->join('tracker_sessions', 'tracker_log.session_id', '=', 'tracker_sessions.id')
->join('tracker_geoip', 'tracker_sessions.geoip_id', '=', 'tracker_geoip.id')
diff --git a/src/Vendor/Laravel/Models/Session.php b/src/Vendor/Laravel/Models/Session.php
index 03c00314..2047b554 100644
--- a/src/Vendor/Laravel/Models/Session.php
+++ b/src/Vendor/Laravel/Models/Session.php
@@ -19,11 +19,6 @@ class Session extends Base
'is_robot',
];
- public function __construct(array $attributes = [])
- {
- parent::__construct($attributes);
- }
-
public function user()
{
return $this->belongsTo($this->getConfig()->get('user_model'));
diff --git a/src/Vendor/Laravel/ServiceProvider.php b/src/Vendor/Laravel/ServiceProvider.php
index 7e3a729f..7fdcf347 100644
--- a/src/Vendor/Laravel/ServiceProvider.php
+++ b/src/Vendor/Laravel/ServiceProvider.php
@@ -51,6 +51,8 @@ class ServiceProvider extends PragmaRXServiceProvider
protected $packageNameCapitalized = 'Tracker';
+ protected $repositoryManagerIsBooted = false;
+
/**
* Indicates if loading of the provider is deferred.
*
@@ -79,13 +81,23 @@ public function boot()
$this->registerErrorHandler();
- if (!isLaravel5()) {
+ if (!$this->getConfig('use_middleware')) {
$this->bootTracker();
}
$this->loadTranslations();
}
+ /**
+ * Check if the service provider is full booted.
+ *
+ * @return void
+ */
+ public function isFullyBooted()
+ {
+ return $this->repositoryManagerIsBooted;
+ }
+
/**
* Register the service provider.
*
@@ -146,14 +158,14 @@ protected function registerTracker()
$app['tracker.loaded'] = true;
return new Tracker(
- $app['tracker.config'],
- $app['tracker.repositories'],
- $app['request'],
- $app['router'],
- $app['log'],
- $app,
- $app['tracker.messages']
- );
+ $app['tracker.config'],
+ $app['tracker.repositories'],
+ $app['request'],
+ $app['router'],
+ $app['log'],
+ $app,
+ $app['tracker.messages']
+ );
});
}
@@ -259,81 +271,58 @@ public function registerRepositories()
$app['request']->server('HTTP_USER_AGENT')
);
- return new RepositoryManager(
+ $manager = new RepositoryManager(
new GeoIp($this->getConfig('geoip_database_path')),
-
new MobileDetect(),
-
$uaParser,
-
$app['tracker.authentication'],
-
$app['session.store'],
-
$app['tracker.config'],
-
- new Session($sessionModel,
- $app['tracker.config'],
- new PhpSession()),
-
+ new Session(
+ $sessionModel,
+ $app['tracker.config'],
+ new PhpSession()
+ ),
$logRepository,
-
new Path($pathModel),
-
new Query($queryModel),
-
new QueryArgument($queryArgumentModel),
-
new Agent($agentModel),
-
new Device($deviceModel),
-
- new Cookie($cookieModel,
- $app['tracker.config'],
- $app['request'],
- $app['cookie']),
-
+ new Cookie(
+ $cookieModel,
+ $app['tracker.config'],
+ $app['request'],
+ $app['cookie']
+ ),
new Domain($domainModel),
-
new Referer(
$refererModel,
$refererSearchTermModel,
$this->getAppUrl(),
$app->make('PragmaRX\Tracker\Support\RefererParser')
),
-
$routeRepository,
-
new RoutePath($routePathModel),
-
new RoutePathParameter($routePathParameterModel),
-
new Error($errorModel),
-
new GeoIpRepository($geoipModel),
-
$sqlQueryRepository,
-
$sqlQueryBindingRepository,
-
$sqlQueryBindingParameterRepository,
-
$sqlQueryLogRepository,
-
$connectionRepository,
-
$eventRepository,
-
$eventLogRepository,
-
$systemClassRepository,
-
$crawlerDetect,
-
new Language($languageModel),
-
new LanguageDetect()
);
+
+ $this->repositoryManagerIsBooted = true;
+
+ return $manager;
});
}
@@ -377,25 +366,15 @@ protected function registerExecutionCallback()
protected function registerErrorHandler()
{
if ($this->getConfig('log_exceptions')) {
- if (isLaravel5()) {
- $illuminateHandler = 'Illuminate\Contracts\Debug\ExceptionHandler';
-
- $handler = new TrackerExceptionHandler(
- $this->getTracker(),
- $this->app[$illuminateHandler]
- );
-
- // Replace original Illuminate Exception Handler by Tracker's
- $this->app[$illuminateHandler] = $handler;
- } else {
- $me = $this;
-
- $this->app->error(
- function (\Exception $exception, $code) use ($me) {
- $me->app['tracker']->handleException($exception, $code);
- }
- );
- }
+ $illuminateHandler = 'Illuminate\Contracts\Debug\ExceptionHandler';
+
+ $handler = new TrackerExceptionHandler(
+ $this->getTracker(),
+ $this->app[$illuminateHandler]
+ );
+
+ // Replace original Illuminate Exception Handler by Tracker's
+ $this->app[$illuminateHandler] = $handler;
}
}
@@ -430,10 +409,12 @@ protected function registerSqlQueryLogWatcher()
$me = $this;
if (!class_exists('Illuminate\Database\Events\QueryExecuted')) {
- $this->app['events']->listen('illuminate.query', function ($query,
- $bindings,
- $time,
- $name) use ($me) {
+ $this->app['events']->listen('illuminate.query', function (
+ $query,
+ $bindings,
+ $time,
+ $name
+ ) use ($me) {
$me->logSqlQuery($query, $bindings, $time, $name);
});
} else {
@@ -473,7 +454,7 @@ protected function registerGlobalEventLogger()
});
$this->app['events']->listen('*', function ($object = null) use ($me) {
- if ($me->app['tracker.events']->isOff()) {
+ if ($me->app['tracker.events']->isOff() || !$me->isFullyBooted()) {
return;
}
diff --git a/src/Vendor/Laravel/Support/Session.php b/src/Vendor/Laravel/Support/Session.php
index 3e00462d..19c47ad9 100644
--- a/src/Vendor/Laravel/Support/Session.php
+++ b/src/Vendor/Laravel/Support/Session.php
@@ -2,7 +2,7 @@
namespace PragmaRX\Tracker\Vendor\Laravel\Support;
-use Illuminate\Support\Facades\Input;
+use Illuminate\Support\Facades\Request;
use PragmaRX\Tracker\Support\Minutes;
use Session as LaravelSession;
@@ -29,8 +29,8 @@ public function getMinutes()
public function getValue($variable, $default = null)
{
- if (Input::has($variable)) {
- $value = Input::get($variable);
+ if (Request::has($variable)) {
+ $value = Request::get($variable);
} else {
$value = LaravelSession::get('tracker.stats.'.$variable, $default);
}
diff --git a/src/config/config.php b/src/config/config.php
index a3ec47d3..38ca17fc 100644
--- a/src/config/config.php
+++ b/src/config/config.php
@@ -246,7 +246,12 @@
/*
* ** IMPORTANT **
- * Change the user model to your own.
+ * Change the user model to your own.
+ * If the model is under a different connection, be specific.
+ * ...
+ * class ModelName {
+ * protected $connection = 'mysql';
+ * ...
*/
'user_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\User',
@@ -309,6 +314,8 @@
*/
'authentication_ioc_binding' => ['auth'], // defaults to 'auth' in Illuminate\Support\Facades\Auth
+ 'authentication_guards' => [], // defaults to []
+
'authenticated_check_method' => 'check', // to Auth::check()
'authenticated_user_method' => 'user', // to Auth::user()
@@ -364,4 +371,9 @@
* Stats Panel controllers namespace
*/
'stats_controllers_namespace' => 'PragmaRX\Tracker\Vendor\Laravel\Controllers',
+
+ /*
+ * Set a default user agent
+ */
+ 'default_user_agent' => '',
];
diff --git a/src/migrations/2015_03_07_311070_create_tracker_paths_table.php b/src/migrations/2015_03_07_311070_create_tracker_paths_table.php
index 75adcacd..a329679e 100644
--- a/src/migrations/2015_03_07_311070_create_tracker_paths_table.php
+++ b/src/migrations/2015_03_07_311070_create_tracker_paths_table.php
@@ -25,8 +25,9 @@ function ($table) {
$table->string('path')->index();
- $table->timestamp('created_at')->index();
- $table->timestamp('updated_at')->index();
+ $table->timestamps();
+ $table->index('created_at');
+ $table->index('updated_at');
}
);
}
diff --git a/src/migrations/2015_03_07_311071_create_tracker_queries_table.php b/src/migrations/2015_03_07_311071_create_tracker_queries_table.php
index 8f621f08..605c36f0 100644
--- a/src/migrations/2015_03_07_311071_create_tracker_queries_table.php
+++ b/src/migrations/2015_03_07_311071_create_tracker_queries_table.php
@@ -25,8 +25,9 @@ function ($table) {
$table->string('query')->index();
- $table->timestamp('created_at')->index();
- $table->timestamp('updated_at')->index();
+ $table->timestamps();
+ $table->index('created_at');
+ $table->index('updated_at');
}
);
}
diff --git a/src/migrations/2015_03_07_311072_create_tracker_queries_arguments_table.php b/src/migrations/2015_03_07_311072_create_tracker_queries_arguments_table.php
index b49cd5fa..ef4ce579 100644
--- a/src/migrations/2015_03_07_311072_create_tracker_queries_arguments_table.php
+++ b/src/migrations/2015_03_07_311072_create_tracker_queries_arguments_table.php
@@ -27,8 +27,9 @@ function ($table) {
$table->string('argument')->index();
$table->string('value')->index();
- $table->timestamp('created_at')->index();
- $table->timestamp('updated_at')->index();
+ $table->timestamps();
+ $table->index('created_at');
+ $table->index('updated_at');
}
);
}
diff --git a/src/migrations/2015_03_07_311073_create_tracker_routes_table.php b/src/migrations/2015_03_07_311073_create_tracker_routes_table.php
index f6b5cfbb..4b36d393 100644
--- a/src/migrations/2015_03_07_311073_create_tracker_routes_table.php
+++ b/src/migrations/2015_03_07_311073_create_tracker_routes_table.php
@@ -26,8 +26,9 @@ function ($table) {
$table->string('name')->index();
$table->string('action')->index();
- $table->timestamp('created_at')->index();
- $table->timestamp('updated_at')->index();
+ $table->timestamps();
+ $table->index('created_at');
+ $table->index('updated_at');
}
);
}
diff --git a/src/migrations/2015_03_07_311074_create_tracker_routes_paths_table.php b/src/migrations/2015_03_07_311074_create_tracker_routes_paths_table.php
index 0d2b5357..b5cb6b1e 100644
--- a/src/migrations/2015_03_07_311074_create_tracker_routes_paths_table.php
+++ b/src/migrations/2015_03_07_311074_create_tracker_routes_paths_table.php
@@ -26,8 +26,9 @@ function ($table) {
$table->bigInteger('route_id')->unsigned()->index();
$table->string('path')->index();
- $table->timestamp('created_at')->index();
- $table->timestamp('updated_at')->index();
+ $table->timestamps();
+ $table->index('created_at');
+ $table->index('updated_at');
}
);
}
diff --git a/src/migrations/2015_03_07_311075_create_tracker_route_path_parameters_table.php b/src/migrations/2015_03_07_311075_create_tracker_route_path_parameters_table.php
index 272db65c..1a8c0489 100644
--- a/src/migrations/2015_03_07_311075_create_tracker_route_path_parameters_table.php
+++ b/src/migrations/2015_03_07_311075_create_tracker_route_path_parameters_table.php
@@ -27,8 +27,9 @@ function ($table) {
$table->string('parameter')->index();
$table->string('value')->index();
- $table->timestamp('created_at')->index();
- $table->timestamp('updated_at')->index();
+ $table->timestamps();
+ $table->index('created_at');
+ $table->index('updated_at');
}
);
}
diff --git a/src/migrations/2015_03_07_311076_create_tracker_agents_table.php b/src/migrations/2015_03_07_311076_create_tracker_agents_table.php
index c9e1c538..a24a1c9e 100644
--- a/src/migrations/2015_03_07_311076_create_tracker_agents_table.php
+++ b/src/migrations/2015_03_07_311076_create_tracker_agents_table.php
@@ -27,8 +27,9 @@ function ($table) {
$table->string('browser')->index();
$table->string('browser_version');
- $table->timestamp('created_at')->index();
- $table->timestamp('updated_at')->index();
+ $table->timestamps();
+ $table->index('created_at');
+ $table->index('updated_at');
}
);
}
diff --git a/src/migrations/2015_03_07_311077_create_tracker_cookies_table.php b/src/migrations/2015_03_07_311077_create_tracker_cookies_table.php
index d7850e91..69568abf 100644
--- a/src/migrations/2015_03_07_311077_create_tracker_cookies_table.php
+++ b/src/migrations/2015_03_07_311077_create_tracker_cookies_table.php
@@ -25,8 +25,9 @@ function ($table) {
$table->string('uuid')->unique();
- $table->timestamp('created_at')->index();
- $table->timestamp('updated_at')->index();
+ $table->timestamps();
+ $table->index('created_at');
+ $table->index('updated_at');
}
);
}
diff --git a/src/migrations/2015_03_07_311078_create_tracker_devices_table.php b/src/migrations/2015_03_07_311078_create_tracker_devices_table.php
index e05bacfa..fab18a61 100644
--- a/src/migrations/2015_03_07_311078_create_tracker_devices_table.php
+++ b/src/migrations/2015_03_07_311078_create_tracker_devices_table.php
@@ -31,8 +31,9 @@ function ($table) {
$table->unique(['kind', 'model', 'platform', 'platform_version']);
- $table->timestamp('created_at')->index();
- $table->timestamp('updated_at')->index();
+ $table->timestamps();
+ $table->index('created_at');
+ $table->index('updated_at');
}
);
}
diff --git a/src/migrations/2015_03_07_311079_create_tracker_domains_table.php b/src/migrations/2015_03_07_311079_create_tracker_domains_table.php
index 91a2bc1e..313aa658 100644
--- a/src/migrations/2015_03_07_311079_create_tracker_domains_table.php
+++ b/src/migrations/2015_03_07_311079_create_tracker_domains_table.php
@@ -25,8 +25,9 @@ function ($table) {
$table->string('name')->index();
- $table->timestamp('created_at')->index();
- $table->timestamp('updated_at')->index();
+ $table->timestamps();
+ $table->index('created_at');
+ $table->index('updated_at');
}
);
}
diff --git a/src/migrations/2015_03_07_311080_create_tracker_referers_table.php b/src/migrations/2015_03_07_311080_create_tracker_referers_table.php
index c0a96eaf..3c38f478 100644
--- a/src/migrations/2015_03_07_311080_create_tracker_referers_table.php
+++ b/src/migrations/2015_03_07_311080_create_tracker_referers_table.php
@@ -27,8 +27,9 @@ function ($table) {
$table->string('url')->index();
$table->string('host');
- $table->timestamp('created_at')->index();
- $table->timestamp('updated_at')->index();
+ $table->timestamps();
+ $table->index('created_at');
+ $table->index('updated_at');
}
);
}
diff --git a/src/migrations/2015_03_07_311081_create_tracker_geoip_table.php b/src/migrations/2015_03_07_311081_create_tracker_geoip_table.php
index ef9b0bcc..8f200da2 100644
--- a/src/migrations/2015_03_07_311081_create_tracker_geoip_table.php
+++ b/src/migrations/2015_03_07_311081_create_tracker_geoip_table.php
@@ -37,8 +37,9 @@ function ($table) {
$table->double('metro_code')->nullable();
$table->string('continent_code', 2)->nullable();
- $table->timestamp('created_at')->index();
- $table->timestamp('updated_at')->index();
+ $table->timestamps();
+ $table->index('created_at');
+ $table->index('updated_at');
}
);
}
diff --git a/src/migrations/2015_03_07_311082_create_tracker_sessions_table.php b/src/migrations/2015_03_07_311082_create_tracker_sessions_table.php
index f7554166..4676730d 100644
--- a/src/migrations/2015_03_07_311082_create_tracker_sessions_table.php
+++ b/src/migrations/2015_03_07_311082_create_tracker_sessions_table.php
@@ -33,8 +33,9 @@ function ($table) {
$table->bigInteger('geoip_id')->unsigned()->nullable()->index();
$table->boolean('is_robot');
- $table->timestamp('created_at')->index();
- $table->timestamp('updated_at')->index();
+ $table->timestamps();
+ $table->index('created_at');
+ $table->index('updated_at');
}
);
}
diff --git a/src/migrations/2015_03_07_311083_create_tracker_errors_table.php b/src/migrations/2015_03_07_311083_create_tracker_errors_table.php
index 49344419..abf2136b 100644
--- a/src/migrations/2015_03_07_311083_create_tracker_errors_table.php
+++ b/src/migrations/2015_03_07_311083_create_tracker_errors_table.php
@@ -26,8 +26,9 @@ function ($table) {
$table->string('code')->index();
$table->string('message')->index();
- $table->timestamp('created_at')->index();
- $table->timestamp('updated_at')->index();
+ $table->timestamps();
+ $table->index('created_at');
+ $table->index('updated_at');
}
);
}
diff --git a/src/migrations/2015_03_07_311084_create_tracker_system_classes_table.php b/src/migrations/2015_03_07_311084_create_tracker_system_classes_table.php
index ad02f90b..0b100a82 100644
--- a/src/migrations/2015_03_07_311084_create_tracker_system_classes_table.php
+++ b/src/migrations/2015_03_07_311084_create_tracker_system_classes_table.php
@@ -25,8 +25,9 @@ function ($table) {
$table->string('name')->index();
- $table->timestamp('created_at')->index();
- $table->timestamp('updated_at')->index();
+ $table->timestamps();
+ $table->index('created_at');
+ $table->index('updated_at');
}
);
}
diff --git a/src/migrations/2015_03_07_311085_create_tracker_log_table.php b/src/migrations/2015_03_07_311085_create_tracker_log_table.php
index 7421cfd3..7b60b920 100644
--- a/src/migrations/2015_03_07_311085_create_tracker_log_table.php
+++ b/src/migrations/2015_03_07_311085_create_tracker_log_table.php
@@ -34,8 +34,9 @@ function ($table) {
$table->boolean('wants_json');
$table->bigInteger('error_id')->unsigned()->nullable()->index();
- $table->timestamp('created_at')->index();
- $table->timestamp('updated_at')->index();
+ $table->timestamps();
+ $table->index('created_at');
+ $table->index('updated_at');
}
);
}
diff --git a/src/migrations/2015_03_07_311086_create_tracker_events_table.php b/src/migrations/2015_03_07_311086_create_tracker_events_table.php
index 95736728..a4090782 100644
--- a/src/migrations/2015_03_07_311086_create_tracker_events_table.php
+++ b/src/migrations/2015_03_07_311086_create_tracker_events_table.php
@@ -25,8 +25,9 @@ function ($table) {
$table->string('name')->index();
- $table->timestamp('created_at')->index();
- $table->timestamp('updated_at')->index();
+ $table->timestamps();
+ $table->index('created_at');
+ $table->index('updated_at');
}
);
}
diff --git a/src/migrations/2015_03_07_311087_create_tracker_events_log_table.php b/src/migrations/2015_03_07_311087_create_tracker_events_log_table.php
index a4370d54..74cbf607 100644
--- a/src/migrations/2015_03_07_311087_create_tracker_events_log_table.php
+++ b/src/migrations/2015_03_07_311087_create_tracker_events_log_table.php
@@ -27,8 +27,9 @@ function ($table) {
$table->bigInteger('class_id')->unsigned()->nullable()->index();
$table->bigInteger('log_id')->unsigned()->index();
- $table->timestamp('created_at')->index();
- $table->timestamp('updated_at')->index();
+ $table->timestamps();
+ $table->index('created_at');
+ $table->index('updated_at');
}
);
}
diff --git a/src/migrations/2015_03_07_311088_create_tracker_sql_queries_table.php b/src/migrations/2015_03_07_311088_create_tracker_sql_queries_table.php
index cf47576f..9b878dec 100644
--- a/src/migrations/2015_03_07_311088_create_tracker_sql_queries_table.php
+++ b/src/migrations/2015_03_07_311088_create_tracker_sql_queries_table.php
@@ -28,8 +28,9 @@ function ($table) {
$table->double('time')->index();
$table->integer('connection_id')->unsigned();
- $table->timestamp('created_at')->index();
- $table->timestamp('updated_at')->index();
+ $table->timestamps();
+ $table->index('created_at');
+ $table->index('updated_at');
}
);
}
diff --git a/src/migrations/2015_03_07_311089_create_tracker_sql_query_bindings_table.php b/src/migrations/2015_03_07_311089_create_tracker_sql_query_bindings_table.php
index b86d0e9f..6f953640 100644
--- a/src/migrations/2015_03_07_311089_create_tracker_sql_query_bindings_table.php
+++ b/src/migrations/2015_03_07_311089_create_tracker_sql_query_bindings_table.php
@@ -26,8 +26,9 @@ function ($table) {
$table->string('sha1', 40)->index();
$table->text('serialized');
- $table->timestamp('created_at')->index();
- $table->timestamp('updated_at')->index();
+ $table->timestamps();
+ $table->index('created_at');
+ $table->index('updated_at');
}
);
}
diff --git a/src/migrations/2015_03_07_311090_create_tracker_sql_query_bindings_parameters_table.php b/src/migrations/2015_03_07_311090_create_tracker_sql_query_bindings_parameters_table.php
index 9dbb4026..fe794e39 100644
--- a/src/migrations/2015_03_07_311090_create_tracker_sql_query_bindings_parameters_table.php
+++ b/src/migrations/2015_03_07_311090_create_tracker_sql_query_bindings_parameters_table.php
@@ -27,8 +27,9 @@ function ($table) {
$table->string('name')->nullable()->index();
$table->text('value')->nullable();
- $table->timestamp('created_at')->index();
- $table->timestamp('updated_at')->index();
+ $table->timestamps();
+ $table->index('created_at');
+ $table->index('updated_at');
}
);
}
diff --git a/src/migrations/2015_03_07_311091_create_tracker_sql_queries_log_table.php b/src/migrations/2015_03_07_311091_create_tracker_sql_queries_log_table.php
index 4f4952e7..3f7ad653 100644
--- a/src/migrations/2015_03_07_311091_create_tracker_sql_queries_log_table.php
+++ b/src/migrations/2015_03_07_311091_create_tracker_sql_queries_log_table.php
@@ -26,8 +26,9 @@ function ($table) {
$table->bigInteger('log_id')->unsigned()->index();
$table->bigInteger('sql_query_id')->unsigned()->index();
- $table->timestamp('created_at')->index();
- $table->timestamp('updated_at')->index();
+ $table->timestamps();
+ $table->index('created_at');
+ $table->index('updated_at');
}
);
}
diff --git a/src/migrations/2015_03_07_311092_create_tracker_connections_table.php b/src/migrations/2015_03_07_311092_create_tracker_connections_table.php
index 71c71d3a..ba1173d8 100644
--- a/src/migrations/2015_03_07_311092_create_tracker_connections_table.php
+++ b/src/migrations/2015_03_07_311092_create_tracker_connections_table.php
@@ -25,8 +25,9 @@ function ($table) {
$table->string('name')->index();
- $table->timestamp('created_at')->index();
- $table->timestamp('updated_at')->index();
+ $table->timestamps();
+ $table->index('created_at');
+ $table->index('updated_at');
}
);
}
diff --git a/src/migrations/2015_03_13_311094_create_tracker_referer_search_term_table.php b/src/migrations/2015_03_13_311094_create_tracker_referer_search_term_table.php
index 79b77191..80db0aa9 100644
--- a/src/migrations/2015_03_13_311094_create_tracker_referer_search_term_table.php
+++ b/src/migrations/2015_03_13_311094_create_tracker_referer_search_term_table.php
@@ -26,8 +26,9 @@ function ($table) {
$table->bigInteger('referer_id')->unsigned()->index();
$table->string('search_term')->index();
- $table->timestamp('created_at')->index();
- $table->timestamp('updated_at')->index();
+ $table->timestamps();
+ $table->index('created_at');
+ $table->index('updated_at');
}
);
}
diff --git a/src/migrations/2015_11_23_311097_create_tracker_languages_table.php b/src/migrations/2015_11_23_311097_create_tracker_languages_table.php
index 66372b39..eeabf1b4 100644
--- a/src/migrations/2015_11_23_311097_create_tracker_languages_table.php
+++ b/src/migrations/2015_11_23_311097_create_tracker_languages_table.php
@@ -28,8 +28,9 @@ function ($table) {
$table->unique(['preference', 'language-range']);
- $table->timestamp('created_at')->index();
- $table->timestamp('updated_at')->index();
+ $table->timestamps();
+ $table->index('created_at');
+ $table->index('updated_at');
}
);
}
diff --git a/src/migrations/2017_12_13_150000_fix_query_arguments.php b/src/migrations/2017_12_13_150000_fix_query_arguments.php
new file mode 100644
index 00000000..71ced306
--- /dev/null
+++ b/src/migrations/2017_12_13_150000_fix_query_arguments.php
@@ -0,0 +1,51 @@
+builder->table(
+ $this->table,
+ function ($table) {
+ $table->string('value')->nullable()->change();
+ }
+ );
+ } catch (\Exception $e) {
+ dd($e->getMessage());
+ }
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function migrateDown()
+ {
+ try {
+ $this->builder->table(
+ $this->table,
+ function ($table) {
+ $table->string('value')->change();
+ }
+ );
+ } catch (\Exception $e) {
+ dd($e->getMessage());
+ }
+ }
+}
diff --git a/src/views/html.blade.php b/src/views/html.blade.php
index ad6b8fd0..4db44e8a 100644
--- a/src/views/html.blade.php
+++ b/src/views/html.blade.php
@@ -27,7 +27,7 @@