Additional analytic metrics

This commit is contained in:
David Bomba 2022-01-23 10:28:13 +11:00
parent 370d932eb1
commit 048b792da0
2 changed files with 96 additions and 31 deletions

View 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;
}
}

View File

@ -12,6 +12,7 @@
namespace App\Jobs\Account;
use App\DataMapper\Analytics\AccountCreated as AnalyticsAccountCreated;
use App\DataMapper\Analytics\AccountPlatform;
use App\Events\Account\AccountCreated;
use App\Jobs\Company\CreateCompany;
use App\Jobs\Company\CreateCompanyPaymentTerms;
@ -137,52 +138,55 @@ class CreateAccount
LightLogs::create(new AnalyticsAccountCreated())
->increment()
->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;
}
private function processSettings($settings)
{
if(Ninja::isHosted() && Cache::get('currencies'))
{
// private function processSettings($settings)
// {
// if(Ninja::isHosted() && Cache::get('currencies'))
// {
$currency = Cache::get('currencies')->filter(function ($item) use ($currency_code) {
return strtolower($item->code) == $currency_code;
})->first();
// $currency = Cache::get('currencies')->filter(function ($item) use ($currency_code) {
// return strtolower($item->code) == $currency_code;
// })->first();
if ($currency) {
$settings->currency_id = (string)$currency->id;
}
// if ($currency) {
// $settings->currency_id = (string)$currency->id;
// }
$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;
})->first();
// $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;
// })->first();
if ($country) {
$settings->country_id = (string)$country->id;
}
// if ($country) {
// $settings->country_id = (string)$country->id;
// }
$language = Cache::get('languages')->filter(function ($item) use ($currency_code) {
return strtolower($item->locale) == $currency_code;
})->first();
// $language = Cache::get('languages')->filter(function ($item) use ($currency_code) {
// return strtolower($item->locale) == $currency_code;
// })->first();
if ($language) {
$settings->language_id = (string)$language->id;
}
// if ($language) {
// $settings->language_id = (string)$language->id;
// }
if($timezone) {
$settings->timezone_id = (string)$timezone->id;
}
// if($timezone) {
// $settings->timezone_id = (string)$timezone->id;
// }
return $settings;
}
// return $settings;
// }
return $settings;
}
// return $settings;
// }
}