Add some Google analytics for the installer and then vaCentral connections

This commit is contained in:
Nabeel Shahzad
2018-01-18 20:24:06 -05:00
parent 3da403671a
commit 467a1a1dc6
8 changed files with 166 additions and 1 deletions

View File

@@ -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', []);
}

View File

@@ -1,4 +1,5 @@
@extends('installer::app')
@section('title', 'Install phpVMS')
@section('content')
<h2>phpvms installer</h2>

View File

@@ -64,13 +64,33 @@
</tr>
<tr>
<td><p>Password Confirm</p></td>
<td width="40%"><p>Password Confirm</p></td>
<td>
{!! Form::password('password_confirmation', ['class' => 'form-control']) !!}
@include('installer::flash/check_error', ['field' => 'password_confirmation'])
</td>
</tr>
<tr>
<td colspan="2"><h4>Options</h4></td>
</tr>
<tr>
<td><p>Analytics</p></td>
<td>
<div class="form-group">
{!! Form::hidden('hidden', 0) !!}
{!! Form::checkbox('analytics', 1, true, ['class' => 'form-control']) !!}
<br />
<p>
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.
</p>
</div>
</td>
</tr>
</table>
<div id="dbtest"></div>
<p style="text-align: right">

View File

@@ -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 !!}

View File

@@ -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);