mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 06:04:34 -04:00
Additional analytic metrics
This commit is contained in:
parent
370d932eb1
commit
048b792da0
61
app/DataMapper/Analytics/AccountPlatform.php
Normal file
61
app/DataMapper/Analytics/AccountPlatform.php
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com).
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\DataMapper\Analytics;
|
||||||
|
|
||||||
|
use Turbo124\Beacon\ExampleMetric\GenericMixedMetric;
|
||||||
|
|
||||||
|
class AccountPlatform extends GenericMixedMetric
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The type of Sample.
|
||||||
|
*
|
||||||
|
* Monotonically incrementing counter
|
||||||
|
*
|
||||||
|
* - counter
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $type = 'mixed_metric';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the counter.
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $name = 'account.platform';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The datetime of the counter measurement.
|
||||||
|
*
|
||||||
|
* date("Y-m-d H:i:s")
|
||||||
|
*
|
||||||
|
* @var DateTime
|
||||||
|
*/
|
||||||
|
public $datetime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class failure name
|
||||||
|
* set to 0.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $string_metric5 = 'platform';
|
||||||
|
|
||||||
|
public $string_metric6 = 'user_agent';
|
||||||
|
|
||||||
|
public $string_metric7 = 'ip_address';
|
||||||
|
|
||||||
|
public function __construct($string_metric5, $string_metric6, $string_metric7) {
|
||||||
|
$this->string_metric5 = $string_metric5;
|
||||||
|
$this->string_metric6 = $string_metric6;
|
||||||
|
$this->string_metric7 = $string_metric7;
|
||||||
|
}
|
||||||
|
}
|
@ -12,6 +12,7 @@
|
|||||||
namespace App\Jobs\Account;
|
namespace App\Jobs\Account;
|
||||||
|
|
||||||
use App\DataMapper\Analytics\AccountCreated as AnalyticsAccountCreated;
|
use App\DataMapper\Analytics\AccountCreated as AnalyticsAccountCreated;
|
||||||
|
use App\DataMapper\Analytics\AccountPlatform;
|
||||||
use App\Events\Account\AccountCreated;
|
use App\Events\Account\AccountCreated;
|
||||||
use App\Jobs\Company\CreateCompany;
|
use App\Jobs\Company\CreateCompany;
|
||||||
use App\Jobs\Company\CreateCompanyPaymentTerms;
|
use App\Jobs\Company\CreateCompanyPaymentTerms;
|
||||||
@ -137,52 +138,55 @@ class CreateAccount
|
|||||||
LightLogs::create(new AnalyticsAccountCreated())
|
LightLogs::create(new AnalyticsAccountCreated())
|
||||||
->increment()
|
->increment()
|
||||||
->queue();
|
->queue();
|
||||||
|
|
||||||
|
$ip = request()->hasHeader('Cf-Connecting-Ip') ? request()->header('Cf-Connecting-Ip') : request()->getClientIp();
|
||||||
|
$platform = request()->has('platform') ? request()->input('platform') : 'www';
|
||||||
|
|
||||||
|
LightLogs::create(new AccountPlatform($platform, request()->server('HTTP_USER_AGENT'), $ip))
|
||||||
|
->queue();
|
||||||
|
|
||||||
return $sp794f3f;
|
return $sp794f3f;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function processSettings($settings)
|
// private function processSettings($settings)
|
||||||
{
|
// {
|
||||||
if(Ninja::isHosted() && Cache::get('currencies'))
|
// if(Ninja::isHosted() && Cache::get('currencies'))
|
||||||
{
|
// {
|
||||||
|
|
||||||
$currency = Cache::get('currencies')->filter(function ($item) use ($currency_code) {
|
// $currency = Cache::get('currencies')->filter(function ($item) use ($currency_code) {
|
||||||
return strtolower($item->code) == $currency_code;
|
// return strtolower($item->code) == $currency_code;
|
||||||
})->first();
|
// })->first();
|
||||||
|
|
||||||
if ($currency) {
|
// if ($currency) {
|
||||||
$settings->currency_id = (string)$currency->id;
|
// $settings->currency_id = (string)$currency->id;
|
||||||
}
|
// }
|
||||||
|
|
||||||
$country = Cache::get('countries')->filter(function ($item) use ($country_code) {
|
// $country = Cache::get('countries')->filter(function ($item) use ($country_code) {
|
||||||
return strtolower($item->iso_3166_2) == $country_code || strtolower($item->iso_3166_3) == $country_code;
|
// return strtolower($item->iso_3166_2) == $country_code || strtolower($item->iso_3166_3) == $country_code;
|
||||||
})->first();
|
// })->first();
|
||||||
|
|
||||||
if ($country) {
|
// if ($country) {
|
||||||
$settings->country_id = (string)$country->id;
|
// $settings->country_id = (string)$country->id;
|
||||||
}
|
// }
|
||||||
|
|
||||||
$language = Cache::get('languages')->filter(function ($item) use ($currency_code) {
|
// $language = Cache::get('languages')->filter(function ($item) use ($currency_code) {
|
||||||
return strtolower($item->locale) == $currency_code;
|
// return strtolower($item->locale) == $currency_code;
|
||||||
})->first();
|
// })->first();
|
||||||
|
|
||||||
if ($language) {
|
// if ($language) {
|
||||||
$settings->language_id = (string)$language->id;
|
// $settings->language_id = (string)$language->id;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if($timezone) {
|
// if($timezone) {
|
||||||
$settings->timezone_id = (string)$timezone->id;
|
// $settings->timezone_id = (string)$timezone->id;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return $settings;
|
// return $settings;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
return $settings;
|
// return $settings;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user