Limit some collection features.

This commit is contained in:
James Cole
2021-05-29 11:30:13 +02:00
parent e379bbab4c
commit 40bbed2a8b
17 changed files with 40 additions and 862 deletions

View File

@@ -132,11 +132,11 @@ class ExportData extends Command
if (0 !== count($data)) {
try {
$this->exportData($options, $data);
app('telemetry')->feature('system.command.executed', $this->signature);
app('telemetry')->feature('system.command.executed', 'firefly-iii:export-data');
} catch (FireflyException $e) {
$this->error(sprintf('Could not store data: %s', $e->getMessage()));
app('telemetry')->feature('system.command.errored', $this->signature);
app('telemetry')->feature('system.command.errored', 'firefly-iii:export-data');
$returnCode = 1;
}
}

View File

@@ -60,7 +60,7 @@ class SetLatestVersion extends Command
app('fireflyconfig')->set('ff3_version', config('firefly.version'));
$this->line('Updated version.');
app('telemetry')->feature('system.command.executed', $this->signature);
app('telemetry')->feature('system.command.executed', 'firefly-iii:set-latest-version');
return 0;
}

View File

@@ -99,7 +99,7 @@ class ApplyRules extends Command
$result = $this->verifyInput();
if (false === $result) {
app('telemetry')->feature('system.command.errored', $this->signature);
app('telemetry')->feature('system.command.errored', 'firefly-iii:apply-rules');
return 1;
}
@@ -119,7 +119,7 @@ class ApplyRules extends Command
$this->warn(' --rule_groups=1,2,...');
$this->warn(' --all_rules');
app('telemetry')->feature('system.command.errored', $this->signature);
app('telemetry')->feature('system.command.errored', 'firefly-iii:apply-rules');
return 1;
}
@@ -148,7 +148,7 @@ class ApplyRules extends Command
// file the rule(s)
$ruleEngine->fire();
app('telemetry')->feature('system.command.executed', $this->signature);
app('telemetry')->feature('system.command.executed', 'firefly-iii:apply-rules');
$this->line('');
$end = round(microtime(true) - $start, 2);

View File

@@ -25,11 +25,9 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands\Tools;
use Carbon\Carbon;
use Exception;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Support\Cronjobs\AutoBudgetCronjob;
use FireflyIII\Support\Cronjobs\RecurringCronjob;
use FireflyIII\Support\Cronjobs\TelemetryCronjob;
use Illuminate\Console\Command;
use InvalidArgumentException;
use Log;
@@ -92,20 +90,9 @@ class Cron extends Command
$this->error($e->getMessage());
}
/*
* Fire telemetry cron job
*/
try {
$this->telemetryCronJob($force, $date);
} catch (FireflyException $e) {
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
$this->error($e->getMessage());
}
$this->info('More feedback on the cron jobs can be found in the log files.');
app('telemetry')->feature('system.command.executed', $this->signature);
app('telemetry')->feature('system.command.executed', 'firefly-iii:cron');
return 0;
}
@@ -127,13 +114,13 @@ class Cron extends Command
}
$recurring->fire();
if($recurring->jobErrored) {
if ($recurring->jobErrored) {
$this->error(sprintf('Error in "create recurring transactions" cron: %s', $recurring->message));
}
if($recurring->jobFired) {
if ($recurring->jobFired) {
$this->error(sprintf('"Create recurring transactions" cron fired: %s', $recurring->message));
}
if($recurring->jobSucceeded) {
if ($recurring->jobSucceeded) {
$this->error(sprintf('"Create recurring transactions" cron ran with success: %s', $recurring->message));
}
}
@@ -154,50 +141,15 @@ class Cron extends Command
$autoBudget->fire();
if($autoBudget->jobErrored) {
if ($autoBudget->jobErrored) {
$this->error(sprintf('Error in "create auto budgets" cron: %s', $autoBudget->message));
}
if($autoBudget->jobFired) {
if ($autoBudget->jobFired) {
$this->error(sprintf('"Create auto budgets" cron fired: %s', $autoBudget->message));
}
if($autoBudget->jobSucceeded) {
if ($autoBudget->jobSucceeded) {
$this->error(sprintf('"Create auto budgets" cron ran with success: %s', $autoBudget->message));
}
}
/**
* @param bool $force
* @param Carbon|null $date
*
* @throws FireflyException
*/
private function telemetryCronJob(bool $force, ?Carbon $date): void
{
if (false === config('firefly.send_telemetry') || false === config('firefly.feature_flags.telemetry')) {
// if not configured to do anything with telemetry, do nothing.
return;
}
$telemetry = new TelemetryCronjob;
$telemetry->setForce($force);
// set date in cron job:
if (null !== $date) {
$telemetry->setDate($date);
}
$telemetry->fire();
if($telemetry->jobErrored) {
$this->error(sprintf('Error in "send telemetry" cron: %s', $telemetry->message));
}
if($telemetry->jobFired) {
$this->error(sprintf('"Send telemetry" cron fired: %s', $telemetry->message));
}
if($telemetry->jobSucceeded) {
$this->error(sprintf('"Send telemetry" cron ran with success: %s', $telemetry->message));
}
}
}

View File

@@ -69,7 +69,6 @@ class UpgradeFireflyInstructions extends Command
app('telemetry')->feature('system.os.version', PHP_OS);
app('telemetry')->feature('system.database.driver', env('DB_CONNECTION', '(unknown)'));
app('telemetry')->feature('system.os.is_docker', $isDocker);
app('telemetry')->feature('system.command.executed', $this->signature);
try {
app('telemetry')->feature('system.users.count', (string)User::count());
} catch (QueryException $e) {