phpvms/app/Services/AnalyticsService.php

43 lines
1.0 KiB
PHP
Raw Normal View History

<?php
namespace App\Services;
use App\Contracts\Service;
2018-02-21 12:33:09 +08:00
use App\Models\Enums\AnalyticsDimensions;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
2018-02-21 12:33:09 +08:00
use Irazasyed\LaravelGAMP\Facades\GAMP;
use PDO;
class AnalyticsService extends Service
{
/**
* Send out some stats about the install
*/
public function sendInstall()
{
if (config('app.analytics') === false) {
return;
}
2018-08-27 00:40:04 +08:00
// some analytics
$gamp = GAMP::setClientId(uniqid('', true));
$gamp->setDocumentPath('/install');
$gamp->setCustomDimension(PHP_VERSION, AnalyticsDimensions::PHP_VERSION);
2018-08-27 00:40:04 +08:00
// 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());
}
}
}