From e379bbab4c477200d1ba98a36884c481534b7ab0 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 28 May 2021 23:13:38 +0200 Subject: [PATCH] Various code cleanup. --- app/Console/Commands/Export/ExportData.php | 10 ++-- .../Authentication/RemoteUserProvider.php | 6 +- config/sentry.php | 59 +++++++++++++++++++ 3 files changed, 67 insertions(+), 8 deletions(-) create mode 100644 config/sentry.php diff --git a/app/Console/Commands/Export/ExportData.php b/app/Console/Commands/Export/ExportData.php index 5c39b6e861..5cdcea94d6 100644 --- a/app/Console/Commands/Export/ExportData.php +++ b/app/Console/Commands/Export/ExportData.php @@ -77,7 +77,6 @@ class ExportData extends Command {--force : Force overwriting of previous exports if found.}'; private AccountRepositoryInterface $accountRepository; private JournalRepositoryInterface $journalRepository; - private User $user; /** * Execute the console command. @@ -85,6 +84,7 @@ class ExportData extends Command * @return int * @throws CannotInsertRecord * @throws FireflyException + * @throws \League\Csv\Exception */ public function handle(): int { @@ -96,9 +96,9 @@ class ExportData extends Command } // set up repositories. $this->stupidLaravel(); - $this->user = $this->getUser(); - $this->journalRepository->setUser($this->user); - $this->accountRepository->setUser($this->user); + $user = $this->getUser(); + $this->journalRepository->setUser($user); + $this->accountRepository->setUser($user); // get the options. try { $options = $this->parseOptions(); @@ -110,7 +110,7 @@ class ExportData extends Command // make export object and configure it. /** @var ExportDataGenerator $exporter */ $exporter = app(ExportDataGenerator::class); - $exporter->setUser($this->user); + $exporter->setUser($user); $exporter->setStart($options['start']); $exporter->setEnd($options['end']); diff --git a/app/Support/Authentication/RemoteUserProvider.php b/app/Support/Authentication/RemoteUserProvider.php index a58b120608..c028e98895 100644 --- a/app/Support/Authentication/RemoteUserProvider.php +++ b/app/Support/Authentication/RemoteUserProvider.php @@ -74,7 +74,7 @@ class RemoteUserProvider implements UserProvider public function retrieveByToken($identifier, $token) { Log::debug(sprintf('Now at %s', __METHOD__)); - throw new FireflyException(sprintf('Did not implement %s', __METHOD__)); + throw new FireflyException(sprintf('A) Did not implement %s', __METHOD__)); } /** @@ -83,7 +83,7 @@ class RemoteUserProvider implements UserProvider public function updateRememberToken(Authenticatable $user, $token) { Log::debug(sprintf('Now at %s', __METHOD__)); - throw new FireflyException(sprintf('Did not implement %s', __METHOD__)); + throw new FireflyException(sprintf('B) Did not implement %s', __METHOD__)); } /** @@ -92,6 +92,6 @@ class RemoteUserProvider implements UserProvider public function validateCredentials(Authenticatable $user, array $credentials) { Log::debug(sprintf('Now at %s', __METHOD__)); - throw new FireflyException(sprintf('Did not implement %s', __METHOD__)); + throw new FireflyException(sprintf('C) Did not implement %s', __METHOD__)); } } diff --git a/config/sentry.php b/config/sentry.php new file mode 100644 index 0000000000..8031dad757 --- /dev/null +++ b/config/sentry.php @@ -0,0 +1,59 @@ + base64_decode(strrev('=IzLnJ3bukWap1SesZWZylmZuknc05WZzB0NmRDNhFWM1EzNlNWY3IWOkRzN0EjYygDM0UzMhBjYi9yL6MHc0RHa')), + + // capture release as git sha + // 'release' => trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')), + + // When left empty or `null` the Laravel environment will be used + 'environment' => env('SENTRY_ENVIRONMENT'), + + 'breadcrumbs' => [ + // Capture Laravel logs in breadcrumbs + 'logs' => true, + + // Capture SQL queries in breadcrumbs + 'sql_queries' => true, + + // Capture bindings on SQL queries logged in breadcrumbs + 'sql_bindings' => true, + + // Capture queue job information in breadcrumbs + 'queue_info' => true, + + // Capture command information in breadcrumbs + 'command_info' => true, + ], + + 'tracing' => [ + // Trace queue jobs as their own transactions + 'queue_job_transactions' => env('SENTRY_TRACE_QUEUE_ENABLED', false), + + // Capture queue jobs as spans when executed on the sync driver + 'queue_jobs' => true, + + // Capture SQL queries as spans + 'sql_queries' => true, + + // Try to find out where the SQL query originated from and add it to the query spans + 'sql_origin' => true, + + // Capture views as spans + 'views' => true, + + // Indicates if the tracing integrations supplied by Sentry should be loaded + 'default_integrations' => true, + ], + + // @see: https://docs.sentry.io/platforms/php/configuration/options/#send-default-pii + 'send_default_pii' => false, + + 'traces_sample_rate' => (float)(env('SENTRY_TRACES_SAMPLE_RATE', 0.0)), + + 'controllers_base_namespace' => env('SENTRY_CONTROLLERS_BASE_NAMESPACE', 'App\\Http\\Controllers'), + +];