diff --git a/config/app.php b/config/app.php index 07f27fc5..3f9530c8 100755 --- a/config/app.php +++ b/config/app.php @@ -63,6 +63,7 @@ return [ SebastiaanLuca\Helpers\Collections\CollectionMacrosServiceProvider::class, Toin0u\Geotools\GeotoolsServiceProvider::class, Jackiedo\Timezonelist\TimezonelistServiceProvider::class, + Irazasyed\LaravelGAMP\LaravelGAMPServiceProvider::class, /* * Application Service Providers... diff --git a/config/gamp.php b/config/gamp.php new file mode 100644 index 00000000..c812666e --- /dev/null +++ b/config/gamp.php @@ -0,0 +1,96 @@ + 'UA-100567975-1', + + /* + |-------------------------------------------------------------------------- + | Measurement Protocol Version [REQUIRED] + |-------------------------------------------------------------------------- + | + | The Protocol version. The current value is '1'. + | This will only change when there are changes made that are not backwards compatible. + | + | Refer: + | https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#v + | + | Default: 1 + | + */ + 'protocol_version' => 1, + + /* + |-------------------------------------------------------------------------- + | URL Endpoint - SSL Support: Send Data over SSL [Optional] + |-------------------------------------------------------------------------- + | + | This option controls the URL endpoint of the Measurement Protocol. + | To send data over SSL, set true. + | + | Refer: + | https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#tid + | + | Default: false + | Valid Values: (Boolean) "true" OR "false" + | + */ + 'is_ssl' => false, + + /* + |-------------------------------------------------------------------------- + | Disable Hits [Optional] + |-------------------------------------------------------------------------- + | + | This option controls enabling or disabling the library. + | Useful in Staging/Dev environments when you don't want to actually send hits to GA. + | When disabled, it returns a AnalyticsResponseInterface object that returns empty values. + | + | To disable library hits, set true. + | + | Default: false + | Valid Values: (Boolean) "true" OR "false" + | + */ + 'is_disabled' => false, + + /* + |-------------------------------------------------------------------------- + | Anonymize IP [Optional] + |-------------------------------------------------------------------------- + | + | When set to True, the IP address of the sender will be anonymized. + | + | Refer: + | https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#aip + | + | Default: false + | Valid Values: (Boolean) "true" OR "false" + | + */ + 'anonymize_ip' => false, + + /* + |-------------------------------------------------------------------------- + | Asynchronous Requests [Optional] + |-------------------------------------------------------------------------- + | + | When set to True, All the requests would be made non-blocking (Async). + | + | Default: false + | Valid Values: (Boolean) "true" OR "false" + | + */ + 'async_requests' => false, +]; diff --git a/env.php.example b/env.php.example index 6a6349b4..90dde3b1 100644 --- a/env.php.example +++ b/env.php.example @@ -23,6 +23,8 @@ APP_LOG=daily APP_LOG_LEVEL=debug APP_LOG_MAX_FILES=3 +APP_ENABLE_ANALYTICS=true + DB_CONNECTION=mysql DB_HOST=localhost DB_PORT=3306 diff --git a/modules/Installer/Http/Controllers/InstallerController.php b/modules/Installer/Http/Controllers/InstallerController.php index ec80c41a..0b18e7da 100644 --- a/modules/Installer/Http/Controllers/InstallerController.php +++ b/modules/Installer/Http/Controllers/InstallerController.php @@ -2,6 +2,7 @@ namespace Modules\Installer\Http\Controllers; +use Irazasyed\LaravelGAMP\Facades\GAMP; use Log; use Illuminate\Http\Request; use Illuminate\Support\Facades\Hash; @@ -52,6 +53,11 @@ class InstallerController extends Controller return view('installer::errors/already-installed'); } + /*$gamp = GAMP::setClientId(uniqid('', true)); + $gamp->setDocumentPath('/install'); + $gamp->setCustomDimension(PHP_VERSION, 1); + $gamp->sendPageview();*/ + return view('installer::index-start'); } @@ -204,6 +210,10 @@ class InstallerController extends Controller */ public function step3(Request $request) { + /*$this->envService->updateKeyInFile([ + 'APP_ENABLE_ANALYTICS' => 'false' + ]);*/ + return view('installer::steps/step3-user', []); } diff --git a/modules/Installer/Resources/views/index-start.blade.php b/modules/Installer/Resources/views/index-start.blade.php index 0afcd42e..e657f9f6 100644 --- a/modules/Installer/Resources/views/index-start.blade.php +++ b/modules/Installer/Resources/views/index-start.blade.php @@ -1,4 +1,5 @@ @extends('installer::app') +@section('title', 'Install phpVMS') @section('content')

phpvms installer

diff --git a/modules/Installer/Resources/views/steps/step3-user.blade.php b/modules/Installer/Resources/views/steps/step3-user.blade.php index ac58d31c..50cfed5f 100644 --- a/modules/Installer/Resources/views/steps/step3-user.blade.php +++ b/modules/Installer/Resources/views/steps/step3-user.blade.php @@ -64,13 +64,33 @@ -

Password Confirm

+

Password Confirm

{!! Form::password('password_confirmation', ['class' => 'form-control']) !!} @include('installer::flash/check_error', ['field' => 'password_confirmation']) + + +

Options

+ + + +

Analytics

+ +
+ {!! Form::hidden('hidden', 0) !!} + {!! Form::checkbox('analytics', 1, true, ['class' => 'form-control']) !!} +
+

+ Allow collection of analytics. They're anonymized, and helps us track + the PHP and database versions that are used, and help to figure out problems + and slowdowns when vaCentral integration is enabled. +

+
+ +

diff --git a/modules/Installer/Resources/views/stubs/env.blade.php b/modules/Installer/Resources/views/stubs/env.blade.php index 32111a22..981ced84 100644 --- a/modules/Installer/Resources/views/stubs/env.blade.php +++ b/modules/Installer/Resources/views/stubs/env.blade.php @@ -19,6 +19,8 @@ APP_LOG=daily APP_LOG_LEVEL=debug APP_LOG_MAX_FILES=3 +APP_ENABLE_ANALYTICS=true + DB_CONNECTION={!! $DB_CONN !!} DB_HOST={!! $DB_HOST !!} DB_PORT={!! $DB_PORT !!} diff --git a/modules/Installer/Services/EnvironmentService.php b/modules/Installer/Services/EnvironmentService.php index 9ed59148..877de2cb 100644 --- a/modules/Installer/Services/EnvironmentService.php +++ b/modules/Installer/Services/EnvironmentService.php @@ -41,6 +41,33 @@ class EnvironmentService return true; } + /** + * Update the environment file and update certain keys/values + * @param array $kvp + * @return void + */ + public function updateKeysInEnv(array $kvp) + { + $app = app(); + + $env_file = file_get_contents($app->environmentFilePath()); + foreach($kvp as $key => $value) { + + # cast + if(\is_bool($value)) { + $value = $value === true ? 'true' : 'false'; + } + + $env_file = preg_replace( + '/^' . $key . '(.*)?/m', + $key . '=' . $value, + $env_file + ); + } + + file_put_contents($app->environmentFilePath(), $env_file); + } + /** * Generate a fresh new APP_KEY * @return string @@ -51,11 +78,17 @@ class EnvironmentService } /** + * Change a few options within the PDO driver, depending on the version + * of mysql/maria, etc used. ATM, only make a change for MariaDB * @param $opts * @return mixed */ protected function determinePdoOptions($opts) { + if($opts['DB_CONN'] !== 'mysql') { + return $opts; + } + $dsn = "mysql:host=$opts[DB_HOST];port=$opts[DB_PORT];"; Log::info('Connection string: ' . $dsn);