1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Internal lightlogs

This commit is contained in:
David Bomba 2023-08-13 16:21:55 +10:00
parent 591d715b04
commit aa45e686ee
2 changed files with 112 additions and 3 deletions

View File

@ -0,0 +1,98 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\DataMapper\Analytics;
use Turbo124\Beacon\ExampleMetric\GenericMixedMetric;
class RevenueTrack 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 = 'app.revenue';
/**
* The datetime of the counter measurement.
*
* date("Y-m-d H:i:s")
*
*/
public $datetime;
/**
* The Client email
*
* @var string
*/
public $string_metric5 = 'email';
/**
* The AccountKey email
*
* @var string
*/
public $string_metric6 = 'key';
/**
* Product Type
*
* @var string
*/
public $string_metric7 = 'product';
/**
* Gateway Reference
*
* @var string
*/
public $string_metric8 = 'gateway_reference';
public $string_metric9 = 'entity_reference';
/**
* The counter
* set to 1.
*
* @var int
*/
public $int_metric1 = 1;
/**
* Amount Received
*
* @var double
*/
public $double_metric2 = 0;
public function __construct($string_metric5, $string_metric6, $int_metric1, $double_metric2, $string_metric7, $string_metric8, $string_metric9)
{
$this->int_metric1 = $int_metric1;
$this->double_metric2 = $double_metric2;
$this->string_metric5 = $string_metric5;
$this->string_metric6 = $string_metric6;
$this->string_metric7 = $string_metric7;
$this->string_metric8 = $string_metric8;
$this->string_metric9 = $string_metric9;
}
}

View File

@ -11,14 +11,16 @@
namespace App\Listeners\Payment;
use App\Utils\Ninja;
use App\Libraries\MultiDB;
use App\Jobs\Mail\NinjaMailer;
use App\Jobs\Mail\NinjaMailerJob;
use App\Jobs\Mail\NinjaMailerObject;
use App\Libraries\MultiDB;
use App\Mail\Admin\EntityPaidObject;
use App\Utils\Ninja;
use App\Utils\Traits\Notifications\UserNotifies;
use Turbo124\Beacon\Facades\LightLogs;
use App\DataMapper\Analytics\RevenueTrack;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\Utils\Traits\Notifications\UserNotifies;
class PaymentNotification implements ShouldQueue
{
@ -158,6 +160,15 @@ class PaymentNotification implements ShouldQueue
$url = $base."&t=item&in={$item}&ip={$amount}&iq=1";
$this->sendAnalytics($url);
$email = $client->present()->email();
$account_key = $client->custom_value2 ?? 'unknown';
$product = $item;
$gateway_reference = $client->gateway_tokens()->count() >= 1 ? ($client->gateway_tokens()->first()->gateway_customer_reference ?? '') : '';
LightLogs::create(new RevenueTrack($email, $account_key, 1, $amount, $product, $gateway_reference, $entity_number))
->batch();
}
/**