tracker stuff

This commit is contained in:
2019-12-25 23:21:33 -06:00
parent 3b04fff2c8
commit e6a15c04c8
36 changed files with 2142 additions and 0 deletions

View File

@@ -93,6 +93,21 @@ return [
'prefix' => '', 'prefix' => '',
], ],
'tracker' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
], ],
/* /*

374
config/tracker.php Normal file
View File

@@ -0,0 +1,374 @@
<?php
return [
/*
* Enable it?
*/
'enabled' => true,
/*
* Enable cache?
*/
'cache_enabled' => true,
/*
* Deffer booting for middleware use
*/
'use_middleware' => true,
/*
* Robots should be tracked?
*/
'do_not_track_robots' => false,
/*
* Which environments are not trackable?
*/
'do_not_track_environments' => [
// defaults to none
],
/*
* Which routes names are not trackable?
*/
'do_not_track_routes' => [
'tracker.stats.*',
],
/*
* Which route paths are not trackable?
*/
'do_not_track_paths' => [
'api/*',
],
/*
* The Do Not Track Ips is used to disable Tracker for some IP addresses:
*
* '127.0.0.1', '192.168.1.1'
*
* You can set ranges of IPs
* '192.168.0.1-192.168.0.100'
*
* And use net masks
* '10.0.0.0/32'
* '172.17.0.0/255.255.0.0'
*/
'do_not_track_ips' => [
'127.0.0.0/24', /// range 127.0.0.1 - 127.0.0.255
],
/*
* When an IP is not trackable, show a message in log.
*/
'log_untrackable_sessions' => false,
/*
* Log every single access?
*
* The log table can become huge if your site is popular, but...
*
* Log table is also responsible for storing information on:
*
* - Routes and controller actions accessed
* - HTTP method used (GET, POST...)
* - Error log
* - URL queries (including values)
*/
'log_enabled' => true,
/*
* Log artisan commands?
*/
'console_log_enabled' => false,
/*
* Log SQL queries?
*
* Log must be enabled for this option to work.
*/
'log_sql_queries' => false,
/*
* If you prefer to store Tracker data on a different database or connection,
* you can set it here.
*
* To avoid SQL queries log recursion, create a different connection for Tracker,
* point it to the same database (or not) and forbid logging of this connection in
* do_not_log_sql_queries_connections.
*/
'connection' => 'tracker',
/*
* Forbid logging of SQL queries for some connections.
*
* To avoid recursion, you better ignore Tracker connection here.
*
* Please create a separate database connection for Tracker. It can hit
* the same database of your application, but the connection itself
* has to have a different name, so the package can ignore its own queries
* and avoid recursion.
*
*/
'do_not_log_sql_queries_connections' => [
'tracker',
],
/*
* GeoIp2 database path.
*
* To get a fresh version of this file, use the command
*
* php artisan tracker:updategeoip
*
*/
'geoip_database_path' => __DIR__.'/geoip', //storage_path('geoip'),
/*
* Also log SQL query bindings?
*
* Log must be enabled for this option to work.
*/
'log_sql_queries_bindings' => false,
/*
* Log events?
*/
'log_events' => false,
/*
* Which events do you want to log exactly?
*/
'log_only_events' => [
// defaults to logging all events
],
/*
* What are the names of the id columns on your system?
*
* 'id' is the most common, but if you have one or more different,
* please add them here in your preference order.
*/
'id_columns_names' => [
'id',
],
/*
* Do not log events for the following patterns.
* Strings accepts wildcards:
*
* eloquent.*
*
*/
'do_not_log_events' => [
'illuminate.log',
'eloquent.*',
'router.*',
'composing: *',
'creating: *',
],
/*
* Do you wish to log Geo IP data?
*
* You will need to install the geoip package
*
* composer require "geoip/geoip":"~1.14"
*
* And remove the PHP module
*
* sudo apt-get purge php5-geoip
*
*/
'log_geoip' => false,
/*
* Do you wish to log the user agent?
*/
'log_user_agents' => false,
/*
* Do you wish to log your users?
*/
'log_users' => false,
/*
* Do you wish to log devices?
*/
'log_devices' => false,
/*
* Do you wish to log languages?
*/
'log_languages' => false,
/*
* Do you wish to log HTTP referers?
*/
'log_referers' => false,
/*
* Do you wish to log url paths?
*/
'log_paths' => false,
/*
* Do you wish to log url queries and query arguments?
*/
'log_queries' => false,
/*
* Do you wish to log routes and route parameters?
*/
'log_routes' => false,
/*
* Log errors and exceptions?
*/
'log_exceptions' => false,
/*
* A cookie may be created on your visitor device, so you can have information
* on everything made using that device on your site. *
*/
'store_cookie_tracker' => false,
/*
* If you are storing cookies, you better change it to a name you of your own.
*/
'tracker_cookie_name' => 'please_change_this_cookie_name',
/*
* Internal tracker session name.
*/
'tracker_session_name' => 'tracker_session',
/*
* ** IMPORTANT **
* 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',
/*
* You can use your own model for every single table Tracker has.
*/
'session_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\Session',
'log_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\Log',
'path_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\Path',
'query_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\Query',
'query_argument_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\QueryArgument',
'agent_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\Agent',
'device_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\Device',
'cookie_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\Cookie',
'domain_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\Domain',
'referer_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\Referer',
'referer_search_term_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\RefererSearchTerm',
'route_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\Route',
'route_path_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\RoutePath',
'route_path_parameter_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\RoutePathParameter',
'error_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\Error',
'geoip_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\GeoIp',
'sql_query_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\SqlQuery',
'sql_query_binding_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\SqlQueryBinding',
'sql_query_binding_parameter_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\SqlQueryBindingParameter',
'sql_query_log_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\SqlQueryLog',
'connection_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\Connection',
'event_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\Event',
'event_log_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\EventLog',
'system_class_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\SystemClass',
'language_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\Language',
/*
* Laravel internal variables on user authentication and login.
*/
'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()
'authenticated_user_id_column' => 'id', // to Auth::user()->id
'authenticated_user_username_column' => 'email', // to Auth::user()->email
/*
* Enable the Stats Panel?
*/
'stats_panel_enabled' => false,
/*
* Stats Panel routes before filter
*
*/
'stats_routes_before_filter' => '',
/*
* Stats Panel routes after filter
*
*/
'stats_routes_after_filter' => '',
/*
* Stats Panel routes middleware
*
*/
'stats_routes_middleware' => 'web',
/*
* Stats Panel template path
*/
'stats_template_path' => '/templates/sb-admin-2',
/*
* Stats Panel base uri.
*
* If your site url is http://wwww.mysite.com, then your stats page will be:
*
* http://wwww.mysite.com/stats
*
*/
'stats_base_uri' => 'stats',
/*
* Stats Panel layout view
*/
'stats_layout' => 'pragmarx/tracker::layout',
/*
* Stats Panel controllers namespace
*/
'stats_controllers_namespace' => 'PragmaRX\Tracker\Vendor\Laravel\Controllers',
];

View File

@@ -0,0 +1,44 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class CreateTrackerPathsTable extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_paths';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->create(
$this->table,
function ($table) {
$table->bigIncrements('id');
$table->string('path')->index();
$table->timestamps();
$table->index('created_at');
$table->index('updated_at');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->drop($this->table);
}
}

View File

@@ -0,0 +1,44 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class CreateTrackerQueriesTable extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_queries';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->create(
$this->table,
function ($table) {
$table->bigIncrements('id');
$table->string('query')->index();
$table->timestamps();
$table->index('created_at');
$table->index('updated_at');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->drop($this->table);
}
}

View File

@@ -0,0 +1,46 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class CreateTrackerQueriesArgumentsTable extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_query_arguments';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->create(
$this->table,
function ($table) {
$table->bigIncrements('id');
$table->bigInteger('query_id')->unsigned()->index();
$table->string('argument')->index();
$table->string('value')->index();
$table->timestamps();
$table->index('created_at');
$table->index('updated_at');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->drop($this->table);
}
}

View File

@@ -0,0 +1,45 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class CreateTrackerRoutesTable extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_routes';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->create(
$this->table,
function ($table) {
$table->bigIncrements('id');
$table->string('name')->index();
$table->string('action')->index();
$table->timestamps();
$table->index('created_at');
$table->index('updated_at');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->drop($this->table);
}
}

View File

@@ -0,0 +1,45 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class CreateTrackerRoutesPathsTable extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_route_paths';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->create(
$this->table,
function ($table) {
$table->bigIncrements('id');
$table->bigInteger('route_id')->unsigned()->index();
$table->string('path')->index();
$table->timestamps();
$table->index('created_at');
$table->index('updated_at');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->drop($this->table);
}
}

View File

@@ -0,0 +1,46 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class CreateTrackerRoutePathParametersTable extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_route_path_parameters';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->create(
$this->table,
function ($table) {
$table->bigIncrements('id');
$table->bigInteger('route_path_id')->unsigned()->index();
$table->string('parameter')->index();
$table->string('value')->index();
$table->timestamps();
$table->index('created_at');
$table->index('updated_at');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->drop($this->table);
}
}

View File

@@ -0,0 +1,46 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class CreateTrackerAgentsTable extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_agents';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->create(
$this->table,
function ($table) {
$table->bigIncrements('id');
$table->string('name')->unique();
$table->string('browser')->index();
$table->string('browser_version');
$table->timestamps();
$table->index('created_at');
$table->index('updated_at');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->drop($this->table);
}
}

View File

@@ -0,0 +1,44 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class CreateTrackerCookiesTable extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_cookies';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->create(
$this->table,
function ($table) {
$table->bigIncrements('id');
$table->string('uuid')->unique();
$table->timestamps();
$table->index('created_at');
$table->index('updated_at');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->drop($this->table);
}
}

View File

@@ -0,0 +1,50 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class CreateTrackerDevicesTable extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_devices';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->create(
$this->table,
function ($table) {
$table->bigIncrements('id');
$table->string('kind', 16)->index();
$table->string('model', 64)->index();
$table->string('platform', 64)->index();
$table->string('platform_version', 16)->index();
$table->boolean('is_mobile');
$table->unique(['kind', 'model', 'platform', 'platform_version']);
$table->timestamps();
$table->index('created_at');
$table->index('updated_at');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->drop($this->table);
}
}

View File

@@ -0,0 +1,44 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class CreateTrackerDomainsTable extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_domains';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->create(
$this->table,
function ($table) {
$table->bigIncrements('id');
$table->string('name')->index();
$table->timestamps();
$table->index('created_at');
$table->index('updated_at');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->drop($this->table);
}
}

View File

@@ -0,0 +1,46 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class CreateTrackerReferersTable extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_referers';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->create(
$this->table,
function ($table) {
$table->bigIncrements('id');
$table->bigInteger('domain_id')->unsigned()->index();
$table->string('url')->index();
$table->string('host');
$table->timestamps();
$table->index('created_at');
$table->index('updated_at');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->drop($this->table);
}
}

View File

@@ -0,0 +1,56 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class CreateTrackerGeoipTable extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_geoip';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->create(
$this->table,
function ($table) {
$table->bigIncrements('id');
$table->double('latitude')->nullable()->index();
$table->double('longitude')->nullable()->index();
$table->string('country_code', 2)->nullable()->index();
$table->string('country_code3', 3)->nullable()->index();
$table->string('country_name')->nullable()->index();
$table->string('region', 2)->nullable();
$table->string('city', 50)->nullable()->index();
$table->string('postal_code', 20)->nullable();
$table->bigInteger('area_code')->nullable();
$table->double('dma_code')->nullable();
$table->double('metro_code')->nullable();
$table->string('continent_code', 2)->nullable();
$table->timestamps();
$table->index('created_at');
$table->index('updated_at');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->drop($this->table);
}
}

View File

@@ -0,0 +1,52 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class CreateTrackerSessionsTable extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_sessions';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->create(
$this->table,
function ($table) {
$table->bigIncrements('id');
$table->string('uuid')->unique()->index();
$table->bigInteger('user_id')->unsigned()->nullable()->index();
$table->bigInteger('device_id')->unsigned()->nullable()->index();
$table->bigInteger('agent_id')->unsigned()->nullable()->index();
$table->string('client_ip')->index();
$table->bigInteger('referer_id')->unsigned()->nullable()->index();
$table->bigInteger('cookie_id')->unsigned()->nullable()->index();
$table->bigInteger('geoip_id')->unsigned()->nullable()->index();
$table->boolean('is_robot');
$table->timestamps();
$table->index('created_at');
$table->index('updated_at');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->drop($this->table);
}
}

View File

@@ -0,0 +1,45 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class CreateTrackerErrorsTable extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_errors';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->create(
$this->table,
function ($table) {
$table->bigIncrements('id');
$table->string('code')->index();
$table->string('message')->index();
$table->timestamps();
$table->index('created_at');
$table->index('updated_at');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->drop($this->table);
}
}

View File

@@ -0,0 +1,44 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class CreateTrackerSystemClassesTable extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_system_classes';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->create(
$this->table,
function ($table) {
$table->bigIncrements('id');
$table->string('name')->index();
$table->timestamps();
$table->index('created_at');
$table->index('updated_at');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->drop($this->table);
}
}

View File

@@ -0,0 +1,53 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class CreateTrackerLogTable extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_log';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->create(
$this->table,
function ($table) {
$table->bigIncrements('id');
$table->bigInteger('session_id')->unsigned()->index();
$table->bigInteger('path_id')->unsigned()->nullable()->index();
$table->bigInteger('query_id')->unsigned()->nullable()->index();
$table->string('method', 10)->index();
$table->bigInteger('route_path_id')->unsigned()->nullable()->index();
$table->boolean('is_ajax');
$table->boolean('is_secure');
$table->boolean('is_json');
$table->boolean('wants_json');
$table->bigInteger('error_id')->unsigned()->nullable()->index();
$table->timestamps();
$table->index('created_at');
$table->index('updated_at');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->drop($this->table);
}
}

View File

@@ -0,0 +1,44 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class CreateTrackerEventsTable extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_events';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->create(
$this->table,
function ($table) {
$table->bigIncrements('id');
$table->string('name')->index();
$table->timestamps();
$table->index('created_at');
$table->index('updated_at');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->drop($this->table);
}
}

View File

@@ -0,0 +1,46 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class CreateTrackerEventsLogTable extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_events_log';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->create(
$this->table,
function ($table) {
$table->bigIncrements('id');
$table->bigInteger('event_id')->unsigned()->index();
$table->bigInteger('class_id')->unsigned()->nullable()->index();
$table->bigInteger('log_id')->unsigned()->index();
$table->timestamps();
$table->index('created_at');
$table->index('updated_at');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->drop($this->table);
}
}

View File

@@ -0,0 +1,47 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class CreateTrackerSqlQueriesTable extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_sql_queries';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->create(
$this->table,
function ($table) {
$table->bigIncrements('id');
$table->string('sha1', 40)->index();
$table->text('statement');
$table->double('time')->index();
$table->integer('connection_id')->unsigned();
$table->timestamps();
$table->index('created_at');
$table->index('updated_at');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->drop($this->table);
}
}

View File

@@ -0,0 +1,45 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class CreateTrackerSqlQueryBindingsTable extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_sql_query_bindings';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->create(
$this->table,
function ($table) {
$table->bigIncrements('id');
$table->string('sha1', 40)->index();
$table->text('serialized');
$table->timestamps();
$table->index('created_at');
$table->index('updated_at');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->drop($this->table);
}
}

View File

@@ -0,0 +1,46 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class CreateTrackerSqlQueryBindingsParametersTable extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_sql_query_bindings_parameters';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->create(
$this->table,
function ($table) {
$table->bigIncrements('id');
$table->bigInteger('sql_query_bindings_id')->unsigned()->nullable();
$table->string('name')->nullable()->index();
$table->text('value')->nullable();
$table->timestamps();
$table->index('created_at');
$table->index('updated_at');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->drop($this->table);
}
}

View File

@@ -0,0 +1,45 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class CreateTrackerSqlQueriesLogTable extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_sql_queries_log';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->create(
$this->table,
function ($table) {
$table->bigIncrements('id');
$table->bigInteger('log_id')->unsigned()->index();
$table->bigInteger('sql_query_id')->unsigned()->index();
$table->timestamps();
$table->index('created_at');
$table->index('updated_at');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->drop($this->table);
}
}

View File

@@ -0,0 +1,44 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class CreateTrackerConnectionsTable extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_connections';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->create(
$this->table,
function ($table) {
$table->bigIncrements('id');
$table->string('name')->index();
$table->timestamps();
$table->index('created_at');
$table->index('updated_at');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->drop($this->table);
}
}

View File

@@ -0,0 +1,184 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class CreateTrackerTablesRelations extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->table('tracker_query_arguments', function ($table) {
$table->foreign('query_id')
->references('id')
->on('tracker_queries')
->onUpdate('cascade')
->onDelete('cascade');
});
$this->builder->table('tracker_route_paths', function ($table) {
$table->foreign('route_id')
->references('id')
->on('tracker_routes')
->onUpdate('cascade')
->onDelete('cascade');
});
$this->builder->table('tracker_route_path_parameters', function ($table) {
$table->foreign('route_path_id')
->references('id')
->on('tracker_route_paths')
->onUpdate('cascade')
->onDelete('cascade');
});
$this->builder->table('tracker_referers', function ($table) {
$table->foreign('domain_id')
->references('id')
->on('tracker_domains')
->onUpdate('cascade')
->onDelete('cascade');
});
$this->builder->table('tracker_sessions', function ($table) {
$table->foreign('device_id')
->references('id')
->on('tracker_devices')
->onUpdate('cascade')
->onDelete('cascade');
});
$this->builder->table('tracker_sessions', function ($table) {
$table->foreign('agent_id')
->references('id')
->on('tracker_agents')
->onUpdate('cascade')
->onDelete('cascade');
});
$this->builder->table('tracker_sessions', function ($table) {
$table->foreign('referer_id')
->references('id')
->on('tracker_referers')
->onUpdate('cascade')
->onDelete('cascade');
});
$this->builder->table('tracker_sessions', function ($table) {
$table->foreign('cookie_id')
->references('id')
->on('tracker_cookies')
->onUpdate('cascade')
->onDelete('cascade');
});
$this->builder->table('tracker_sessions', function ($table) {
$table->foreign('geoip_id')
->references('id')
->on('tracker_geoip')
->onUpdate('cascade')
->onDelete('cascade');
});
$this->builder->table('tracker_log', function ($table) {
$table->foreign('session_id')
->references('id')
->on('tracker_sessions')
->onUpdate('cascade')
->onDelete('cascade');
});
$this->builder->table('tracker_log', function ($table) {
$table->foreign('path_id')
->references('id')
->on('tracker_paths')
->onUpdate('cascade')
->onDelete('cascade');
});
$this->builder->table('tracker_log', function ($table) {
$table->foreign('query_id')
->references('id')
->on('tracker_queries')
->onUpdate('cascade')
->onDelete('cascade');
});
$this->builder->table('tracker_log', function ($table) {
$table->foreign('route_path_id')
->references('id')
->on('tracker_route_paths')
->onUpdate('cascade')
->onDelete('cascade');
});
$this->builder->table('tracker_log', function ($table) {
$table->foreign('error_id')
->references('id')
->on('tracker_errors')
->onUpdate('cascade')
->onDelete('cascade');
});
$this->builder->table('tracker_events_log', function ($table) {
$table->foreign('event_id')
->references('id')
->on('tracker_events')
->onUpdate('cascade')
->onDelete('cascade');
});
$this->builder->table('tracker_events_log', function ($table) {
$table->foreign('class_id')
->references('id')
->on('tracker_system_classes')
->onUpdate('cascade')
->onDelete('cascade');
});
$this->builder->table('tracker_events_log', function ($table) {
$table->foreign('log_id')
->references('id')
->on('tracker_log')
->onUpdate('cascade')
->onDelete('cascade');
});
$this->builder->table('tracker_sql_query_bindings_parameters', function ($table) {
$table->foreign('sql_query_bindings_id', 'tracker_sqlqb_parameters')
->references('id')
->on('tracker_sql_query_bindings')
->onUpdate('cascade')
->onDelete('cascade');
});
$this->builder->table('tracker_sql_queries_log', function ($table) {
$table->foreign('log_id')
->references('id')
->on('tracker_log')
->onUpdate('cascade')
->onDelete('cascade');
});
$this->builder->table('tracker_sql_queries_log', function ($table) {
$table->foreign('sql_query_id')
->references('id')
->on('tracker_sql_queries')
->onUpdate('cascade')
->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
// Tables will be dropped in the correct order... :)
}
}

View File

@@ -0,0 +1,45 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class CreateTrackerRefererSearchTermTable extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_referers_search_terms';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->create(
$this->table,
function ($table) {
$table->bigIncrements('id');
$table->bigInteger('referer_id')->unsigned()->index();
$table->string('search_term')->index();
$table->timestamps();
$table->index('created_at');
$table->index('updated_at');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->drop($this->table);
}
}

View File

@@ -0,0 +1,64 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class AddTrackerRefererColumns extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_referers';
private $foreign = 'tracker_referers_search_terms';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->table(
$this->table,
function ($table) {
$table->string('medium')->nullable()->index();
$table->string('source')->nullable()->index();
$table->string('search_terms_hash')->nullable()->index();
}
);
$this->builder->table($this->foreign, function ($table) {
$table->foreign('referer_id', 'tracker_referers_referer_id_fk')
->references('id')
->on('tracker_referers')
->onUpdate('cascade')
->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->builder->table(
$this->table,
function ($table) {
$table->dropColumn('medium');
$table->dropColumn('source');
$table->dropColumn('search_terms_hash');
}
);
$this->builder->table(
$this->foreign,
function ($table) {
$table->dropForeign('tracker_referers_referer_id_fk');
}
);
}
}

View File

@@ -0,0 +1,43 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class AddTrackerRefererColumnToLog extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_log';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->table(
$this->table,
function ($table) {
$table->integer('referer_id')->unsigned()->nullable()->index();
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->builder->table(
$this->table,
function ($table) {
$table->dropColumn('referer_id');
}
);
}
}

View File

@@ -0,0 +1,47 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class CreateTrackerLanguagesTable extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_languages';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->create(
$this->table,
function ($table) {
$table->bigIncrements('id');
$table->string('preference')->index();
$table->string('language-range')->index();
$table->unique(['preference', 'language-range']);
$table->timestamps();
$table->index('created_at');
$table->index('updated_at');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->drop($this->table);
}
}

View File

@@ -0,0 +1,43 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class AddLanguageIdColumnToSessions extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_sessions';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->table(
$this->table,
function ($table) {
$table->bigInteger('language_id')->unsigned()->nullable()->index();
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->builder->table(
$this->table,
function ($table) {
$table->dropColumn('language_id');
}
);
}
}

View File

@@ -0,0 +1,34 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class AddTrackerLanguageForeignKeyToSessions extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
$this->builder->table('tracker_sessions', function ($table) {
$table->foreign('language_id')
->references('id')
->on('tracker_languages')
->onUpdate('cascade')
->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
$this->builder->table('tracker_sessions', function ($table) {
$table->dropForeign(['language_id']);
});
}
}

View File

@@ -0,0 +1,40 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class AddNullableToTrackerError extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_errors';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
try {
$this->builder->table(
$this->table,
function ($table) {
$table->string('code')->nullable()->change();
}
);
} catch (\Exception $e) {
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
}
}

View File

@@ -0,0 +1,65 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class FixAgentName extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_agents';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
try {
$this->builder->table(
$this->table,
function ($table) {
$table->dropUnique('tracker_agents_name_unique');
}
);
$this->builder->table(
$this->table,
function ($table) {
$table->mediumText('name')->change();
}
);
$this->builder->table(
$this->table,
function ($table) {
$table->unique('id', 'tracker_agents_name_unique'); // this is a dummy index
}
);
} catch (\Exception $e) {
dd($e->getMessage());
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
try {
$this->builder->table(
$this->table,
function ($table) {
$table->string('name', 255)->change();
$table->unique('name');
}
);
} catch (\Exception $e) {
}
}
}

View File

@@ -0,0 +1,70 @@
<?php
use PragmaRX\Tracker\Support\Migration;
use PragmaRX\Tracker\Vendor\Laravel\Models\Agent;
class AddAgentNameHash extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_agents';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
try {
$this->builder->table(
$this->table,
function ($table) {
$table->dropUnique('tracker_agents_name_unique');
$table->string('name_hash', 65)->nullable();
}
);
Agent::all()->each(function ($agent) {
$agent->name_hash = hash('sha256', $agent->name);
$agent->save();
});
$this->builder->table(
$this->table,
function ($table) {
$table->unique('name_hash');
}
);
} catch (\Exception $e) {
dd($e->getMessage());
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function migrateDown()
{
try {
$this->builder->table(
$this->table,
function ($table) {
$table->dropUnique('tracker_agents_name_hash_unique');
$table->dropColumn('name_hash');
$table->mediumText('name')->unique()->change();
}
);
} catch (\Exception $e) {
}
}
}

View File

@@ -0,0 +1,51 @@
<?php
use PragmaRX\Tracker\Support\Migration;
class FixQueryArguments extends Migration
{
/**
* Table related to this migration.
*
* @var string
*/
private $table = 'tracker_query_arguments';
/**
* Run the migrations.
*
* @return void
*/
public function migrateUp()
{
try {
$this->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());
}
}
}