Skip to content

Commit

Permalink
refactor: use Laravel Str facade to create UUID
Browse files Browse the repository at this point in the history
as per @eugenebednik, use Laravel Str facade to compute a valid instance ID
  • Loading branch information
warlof committed Aug 19, 2021
1 parent dc2481a commit 971b7af
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/Traits/Telemeter.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
namespace Seat\Services\Traits;

use Exception;
use Illuminate\Support\Str;
use InfluxDB2\Client;
use InfluxDB2\Model\WritePrecision;

Expand Down Expand Up @@ -171,14 +172,7 @@ private function getTelemetryInstanceID()
if (! $id) {

// Generate a V4 random UUID
// https://gist.github.com/dahnielson/508447#file-uuid-php-L74
$id = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0x0fff) | 0x4000,
mt_rand(0, 0x3fff) | 0x8000,
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
);
$id = Str::uuid();

// Set the generated UUID in the applications config
setting(['analytics_id', $id], true);
Expand Down

0 comments on commit 971b7af

Please sign in to comment.