mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-23 20:38:46 +00:00
Enable the feature flag for telemetry.
This commit is contained in:
@@ -24,6 +24,7 @@ namespace FireflyIII\Jobs;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Telemetry;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
@@ -33,7 +34,9 @@ use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Collection;
|
||||
use JsonException;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class SubmitTelemetryData
|
||||
@@ -61,7 +64,7 @@ class SubmitTelemetryData implements ShouldQueue
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
@@ -76,10 +79,19 @@ class SubmitTelemetryData implements ShouldQueue
|
||||
return;
|
||||
}
|
||||
|
||||
$body = '[]';
|
||||
$json = $this->parseJson($telemetry);
|
||||
try {
|
||||
json_encode($json, JSON_THROW_ON_ERROR, 512);
|
||||
} catch (JsonException $e) {
|
||||
Log::error($e->getMessage());
|
||||
Log::error('Could not parse JSON.');
|
||||
throw new FireflyException(sprintf('Could not parse telemetry JSON: %s', $e->getMessage()));
|
||||
}
|
||||
|
||||
$client = new Client;
|
||||
$options = [
|
||||
'body' => json_encode($json, JSON_THROW_ON_ERROR, 512),
|
||||
'body' => $body,
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json',
|
||||
@@ -89,11 +101,11 @@ class SubmitTelemetryData implements ShouldQueue
|
||||
];
|
||||
try {
|
||||
$result = $client->post($url, $options);
|
||||
} catch (GuzzleException $e) {
|
||||
} catch (GuzzleException|Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
Log::error('Could not submit telemetry.');
|
||||
return;
|
||||
throw new FireflyException(sprintf('Could not submit telemetry: %s', $e->getMessage()));
|
||||
}
|
||||
$body = (string) $result->getBody();
|
||||
$statusCode = $result->getStatusCode();
|
||||
|
Reference in New Issue
Block a user