mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-04 03:43:07 +00:00
Clean up views and code
This commit is contained in:
@@ -88,7 +88,6 @@ class FixPostgresSequences extends Command
|
||||
'rules',
|
||||
'tag_transaction_journal',
|
||||
'tags',
|
||||
'telemetry',
|
||||
'transaction_currencies',
|
||||
'transaction_groups',
|
||||
'transaction_journals',
|
||||
|
@@ -136,7 +136,6 @@ class Handler extends ExceptionHandler
|
||||
*/
|
||||
public function report(Throwable $e)
|
||||
{
|
||||
// do email the user (no telemetry)
|
||||
$doMailError = config('firefly.send_error_message');
|
||||
if ($this->shouldntReportLocal($e) || !$doMailError) {
|
||||
parent::report($e);
|
||||
|
@@ -1,66 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* TelemetryController.php
|
||||
* Copyright (c) 2020 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Admin;
|
||||
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
|
||||
/**
|
||||
* Class TelemetryController
|
||||
*/
|
||||
class TelemetryController extends Controller
|
||||
{
|
||||
/**
|
||||
* TelemetryController constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if (false === config('firefly.feature_flags.telemetry')) {
|
||||
die('Telemetry is disabled.');
|
||||
}
|
||||
parent::__construct();
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string)trans('firefly.administration'));
|
||||
app('view')->share('mainTitleIcon', 'fa-hand-spock-o');
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Index
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
app('view')->share('subTitleIcon', 'fa-eye');
|
||||
app('view')->share('subTitle', (string)trans('firefly.telemetry_admin_index'));
|
||||
$version = config('firefly.version');
|
||||
$enabled = config('firefly.send_telemetry', false) && config('firefly.feature_flags.telemetry');
|
||||
return prefixView('admin.telemetry.index', compact('version', 'enabled'));
|
||||
}
|
||||
|
||||
}
|
@@ -150,7 +150,6 @@ class DebugController extends Controller
|
||||
$foundDBversion = FireflyConfig::get('db_version', 1)->data;
|
||||
|
||||
// some new vars.
|
||||
$telemetry = true === config('firefly.send_telemetry') && true === config('firefly.feature_flags.telemetry');
|
||||
$defaultLanguage = (string)config('firefly.default_language');
|
||||
$defaultLocale = (string)config('firefly.default_locale');
|
||||
$userLanguage = app('steam')->getLanguage();
|
||||
@@ -218,7 +217,6 @@ class DebugController extends Controller
|
||||
'logContent',
|
||||
'cacheDriver',
|
||||
'trustedProxies',
|
||||
'telemetry',
|
||||
'userLanguage',
|
||||
'userLocale',
|
||||
'defaultLanguage',
|
||||
|
@@ -1,75 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Telemetry.php
|
||||
* Copyright (c) 2020 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
use Eloquent;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* FireflyIII\Models\Telemetry
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $submitted
|
||||
* @property int|null $user_id
|
||||
* @property string $installation_id
|
||||
* @property string $type
|
||||
* @property string $key
|
||||
* @property array $value
|
||||
* @method static Builder|Telemetry newModelQuery()
|
||||
* @method static Builder|Telemetry newQuery()
|
||||
* @method static Builder|Telemetry query()
|
||||
* @method static Builder|Telemetry whereCreatedAt($value)
|
||||
* @method static Builder|Telemetry whereId($value)
|
||||
* @method static Builder|Telemetry whereInstallationId($value)
|
||||
* @method static Builder|Telemetry whereKey($value)
|
||||
* @method static Builder|Telemetry whereSubmitted($value)
|
||||
* @method static Builder|Telemetry whereType($value)
|
||||
* @method static Builder|Telemetry whereUpdatedAt($value)
|
||||
* @method static Builder|Telemetry whereUserId($value)
|
||||
* @method static Builder|Telemetry whereValue($value)
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Telemetry extends Model
|
||||
{
|
||||
/** @var string */
|
||||
protected $table = 'telemetry';
|
||||
|
||||
/** @var array */
|
||||
protected $fillable = ['installation_id', 'submitted', 'user_id', 'key', 'type', 'value'];
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'submitted' => 'datetime',
|
||||
'value' => 'array',
|
||||
];
|
||||
|
||||
}
|
@@ -64,7 +64,6 @@ use FireflyIII\Support\Form\RuleForm;
|
||||
use FireflyIII\Support\Navigation;
|
||||
use FireflyIII\Support\Preferences;
|
||||
use FireflyIII\Support\Steam;
|
||||
use FireflyIII\Support\Telemetry;
|
||||
use FireflyIII\TransactionRules\Engine\RuleEngineInterface;
|
||||
use FireflyIII\TransactionRules\Engine\SearchRuleEngine;
|
||||
use FireflyIII\Validation\FireflyValidator;
|
||||
@@ -165,13 +164,6 @@ class FireflyServiceProvider extends ServiceProvider
|
||||
}
|
||||
);
|
||||
|
||||
$this->app->bind(
|
||||
'telemetry',
|
||||
static function () {
|
||||
return new Telemetry;
|
||||
}
|
||||
);
|
||||
|
||||
// chart generator:
|
||||
$this->app->bind(GeneratorInterface::class, ChartJsGenerator::class);
|
||||
// other generators
|
||||
|
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Amount.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
/**
|
||||
* Class Telemetry
|
||||
*/
|
||||
class Telemetry extends Facade
|
||||
{
|
||||
/**
|
||||
* Get the registered name of the component.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected static function getFacadeAccessor(): string
|
||||
{
|
||||
return 'telemetry';
|
||||
}
|
||||
}
|
@@ -1,88 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Telemetry.php
|
||||
* Copyright (c) 2020 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\System\GeneratesInstallationId;
|
||||
use Sentry\Severity;
|
||||
use Sentry\State\Scope;
|
||||
use function Sentry\captureMessage;
|
||||
use function Sentry\configureScope;
|
||||
|
||||
/**
|
||||
* Class Telemetry
|
||||
*/
|
||||
class Telemetry
|
||||
{
|
||||
use GeneratesInstallationId;
|
||||
|
||||
/**
|
||||
* Feature telemetry stores a $value for the given $feature.
|
||||
* Will only store the given $feature / $value combination once.
|
||||
*
|
||||
*
|
||||
* Examples:
|
||||
* - execute-cli-command [value]
|
||||
* - use-help-pages
|
||||
* - has-created-bill
|
||||
* - first-time-install
|
||||
* - more
|
||||
*
|
||||
* Its use should be limited to exotic and strange use cases in Firefly III.
|
||||
* Because time and date are logged as well, useful to track users' evolution in Firefly III.
|
||||
*
|
||||
* Any meta-data stored is strictly non-financial.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
*/
|
||||
public function feature(string $key, string $value): void
|
||||
{
|
||||
if (false === config('firefly.send_telemetry') || false === config('firefly.feature_flags.telemetry')) {
|
||||
// hard stop if not allowed to do telemetry.
|
||||
// do nothing!
|
||||
return;
|
||||
}
|
||||
$this->generateInstallationId();
|
||||
$installationId = app('fireflyconfig')->get('installation_id');
|
||||
|
||||
// add some context:
|
||||
configureScope(
|
||||
function (Scope $scope) use ($installationId, $key, $value): void {
|
||||
$scope->setContext(
|
||||
'telemetry', [
|
||||
'installation_id' => $installationId->data,
|
||||
'version' => config('firefly.version'),
|
||||
'collected_at' => Carbon::now()->format('r'),
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
]
|
||||
);
|
||||
}
|
||||
);
|
||||
captureMessage(sprintf('FIT: %s/%s', $key, $value), Severity::info());
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user