Analytics

This commit is contained in:
David Bomba 2021-04-24 23:19:46 +10:00
parent ac3b0dfad3
commit b4945220e8
3 changed files with 98 additions and 1 deletions

View File

@ -54,4 +54,22 @@ class EmailFailure
* @var string
*/
public $string_metric6 = '';
/**
* The counter
* set to 1.
*
* @var string
*/
public $int_metric1 = 1;
/**
* Company Key
* @var string
*/
public $string_metric7 = '';
public function __construct($string_metric7) {
$this->string_metric7 = $string_metric7;
}
}

View File

@ -0,0 +1,76 @@
<?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://opensource.org/licenses/AAL
*/
namespace App\DataMapper\Analytics;
class EmailSuccess
{
/**
* The type of Sample.
*
* Monotonically incrementing counter
*
* - counter
*
* @var string
*/
public $type = 'mixed_metric';
/**
* The name of the counter.
* @var string
*/
public $name = 'job.success.email';
/**
* 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 = '';
/**
* The exception string
* set to 0.
*
* @var string
*/
public $string_metric6 = '';
/**
* The counter
* set to 1.
*
* @var string
*/
public $int_metric1 = 1;
/**
* Company Key
* @var string
*/
public $string_metric7 = '';
public function __construct($string_metric7) {
$this->string_metric7 = $string_metric7;
}
}

View File

@ -12,6 +12,7 @@
namespace App\Jobs\Mail;
use App\DataMapper\Analytics\EmailFailure;
use App\DataMapper\Analytics\EmailSuccess;
use App\Events\Invoice\InvoiceWasEmailedAndFailed;
use App\Events\Payment\PaymentWasEmailedAndFailed;
use App\Jobs\Mail\NinjaMailerObject;
@ -180,6 +181,8 @@ class NinjaMailerJob implements ShouldQueue
$message->getHeaders()->addTextHeader('GmailToken', $token);
});
LightLogs::create(new EmailSuccess($this->nmo->company_key->company_key))
->batch();
}
private function logMailError($errors, $recipient_object)
@ -198,7 +201,7 @@ class NinjaMailerJob implements ShouldQueue
nlog('mailer job failed');
nlog($exception->getMessage());
$job_failure = new EmailFailure();
$job_failure = new EmailFailure($this->nmo->company->company_key);
$job_failure->string_metric5 = get_parent_class($this);
$job_failure->string_metric6 = $exception->getMessage();