application->destination?->server; $this->serverUuid = $server?->uuid; $this->enabled = (bool) $server?->isTrafficAnalyticsEnabled(); $this->eligible = $server ? (! $server->isSwarm() && ! $server->isBuildServer()) : false; if ($this->enabled && $server) { try { $client = app(SentinelTrafficClient::class, ['server' => $server]); $this->overview = $client->appOverview($this->application->uuid, '24h')->toArray(); } catch (\Throwable $e) { $this->overview = null; } } } public function hasData(): bool { return $this->overview !== null && (int) ($this->overview['requests'] ?? 0) > 0; } public function errorRate(): float { if (! $this->overview || (int) ($this->overview['requests'] ?? 0) === 0) { return 0.0; } $errors = (int) ($this->overview['s4xx'] ?? 0) + (int) ($this->overview['s5xx'] ?? 0); return round(($errors / $this->overview['requests']) * 100, 2); } public function placeholder(): string { return <<<'HTML'
HTML; } public function render() { return view('livewire.project.application.traffic-overview'); } }