2018-01-30 03:16:39 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Services;
|
|
|
|
|
2018-03-20 09:50:40 +08:00
|
|
|
use App\Interfaces\Service;
|
2018-02-21 12:33:09 +08:00
|
|
|
use App\Models\Enums\AnalyticsDimensions;
|
2018-01-30 03:16:39 +08:00
|
|
|
use DB;
|
2018-02-21 12:33:09 +08:00
|
|
|
use Irazasyed\LaravelGAMP\Facades\GAMP;
|
2018-02-12 23:47:12 +08:00
|
|
|
use Log;
|
2018-01-30 03:16:39 +08:00
|
|
|
use PDO;
|
|
|
|
|
2018-03-20 09:50:40 +08:00
|
|
|
/**
|
|
|
|
* Class AnalyticsService
|
|
|
|
* @package App\Services
|
|
|
|
*/
|
|
|
|
class AnalyticsService extends Service
|
2018-01-30 03:16:39 +08:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Send out some stats about the install
|
|
|
|
*/
|
|
|
|
public function sendInstall()
|
|
|
|
{
|
2018-03-20 09:50:40 +08:00
|
|
|
if (config('app.analytics') === false) {
|
2018-01-30 03:16:39 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
# some analytics
|
|
|
|
$gamp = GAMP::setClientId(uniqid('', true));
|
|
|
|
$gamp->setDocumentPath('/install');
|
|
|
|
|
|
|
|
$gamp->setCustomDimension(PHP_VERSION, AnalyticsDimensions::PHP_VERSION);
|
|
|
|
|
|
|
|
# figure out database version
|
|
|
|
$pdo = DB::connection()->getPdo();
|
|
|
|
$gamp->setCustomDimension(
|
|
|
|
strtolower($pdo->getAttribute(PDO::ATTR_SERVER_VERSION)),
|
|
|
|
AnalyticsDimensions::DATABASE_VERSION
|
|
|
|
);
|
|
|
|
|
2018-02-12 23:47:12 +08:00
|
|
|
try {
|
|
|
|
$gamp->sendPageview();
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
Log::error($e->getMessage());
|
|
|
|
}
|
2018-01-30 03:16:39 +08:00
|
|
|
}
|
|
|
|
}
|