Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix(dashboard): remove traffic analytics enablement nudge

Aditya Tripathid887d1cbdce9
diff --git a/app/Livewire/Dashboard/TrafficAnalytics.php b/app/Livewire/Dashboard/TrafficAnalytics.php
index 9b1b761ed3..9de3f7fd16 100644
--- a/app/Livewire/Dashboard/TrafficAnalytics.php
+++ b/app/Livewire/Dashboard/TrafficAnalytics.php
@@ -32,36 +32,12 @@ class TrafficAnalytics extends Component
*/
public array $series = [];
- /**
- * Servers that could run traffic analytics but have it off — drives the dashboard nudge.
- *
- * @var array<int, array{uuid: string, name: string}>
- */
- public array $eligibleDisabledServers = [];
-
- // Stable key over the eligible-disabled set so a localStorage dismissal sticks until
- // a new eligible server appears (which changes the key and re-shows the nudge).
- public string $nudgeKey = '';
-
public function mount(): void
{
- $allServers = Server::ownedByCurrentTeamCached();
-
- $this->servers = $allServers
+ $this->servers = Server::ownedByCurrentTeamCached()
->filter(fn (Server $server) => $server->isTrafficAnalyticsEnabled())
->values();
- $eligibleDisabled = $allServers
- ->filter(fn (Server $server) => ! $server->isTrafficAnalyticsEnabled()
- && ! $server->isSwarm()
- && ! $server->isBuildServer())
- ->values();
-
- $this->eligibleDisabledServers = $eligibleDisabled
- ->map(fn (Server $server) => ['uuid' => $server->uuid, 'name' => $server->name])
- ->all();
- $this->nudgeKey = substr(md5($eligibleDisabled->pluck('uuid')->sort()->implode(',')), 0, 12);
-
if ($this->servers->isNotEmpty()) {
$this->loadData();
}
diff --git a/resources/views/livewire/dashboard/traffic-analytics.blade.php b/resources/views/livewire/dashboard/traffic-analytics.blade.php
index dcffccb020..62c49b67df 100644
--- a/resources/views/livewire/dashboard/traffic-analytics.blade.php
+++ b/resources/views/livewire/dashboard/traffic-analytics.blade.php
@@ -36,48 +36,13 @@ $spark = 'refreshChartData-'.$chartId.'-status';
</div>
@endif
<a href="{{ route('analytics') }}" {{ wireNavigate() }}
- class="inline-flex h-7 items-center gap-1 rounded-md px-2.5 text-[12px] font-medium text-neutral-500 ring-1 ring-neutral-200 transition-colors hover:text-black dark:text-fg-faint dark:ring-white/[0.08] dark:hover:text-fg">
+ class="inline-flex shrink-0 items-center gap-1 text-[12px] font-medium text-neutral-500 transition-colors hover:text-black dark:text-fg-dim dark:hover:text-fg">
Open analytics
- <svg class="size-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
- <path stroke-linecap="round" stroke-linejoin="round" d="M9 5l7 7-7 7" />
- </svg>
+ <x-reicon name="arrow-right" class="size-3" />
</a>
</div>
</div>
- @if (! empty($eligibleDisabledServers))
- <div x-data="{ dismissed: localStorage.getItem('traffic-nudge-{{ $nudgeKey }}') === '1' }" x-show="!dismissed" x-cloak
- class="mb-3 flex items-start gap-3 rounded-xl border border-neutral-200 bg-white px-4 py-3 shadow-sm dark:border-white/[0.08] dark:bg-white/[0.025]">
- <div class="min-w-0 flex-1">
- <p class="text-[12px] font-semibold text-black dark:text-fg">
- {{ count($eligibleDisabledServers) === 1 ? '1 server can start collecting traffic analytics' : count($eligibleDisabledServers).' servers can start collecting traffic analytics' }}
- </p>
- <p class="mt-0.5 text-[11px] text-neutral-500 dark:text-fg-dim">
- Enabling regenerates the proxy config and restarts the proxy + Sentinel (a brief blip).
- Works with Traefik &amp; Caddy.
- </p>
- </div>
- <div class="flex shrink-0 items-center gap-2">
- @if (count($eligibleDisabledServers) === 1)
- <a class="button" href="{{ route('server.sentinel', ['server_uuid' => $eligibleDisabledServers[0]['uuid']]) }}" {{ wireNavigate() }}>
- Enable on {{ \Illuminate\Support\Str::limit($eligibleDisabledServers[0]['name'], 16) }}
- </a>
- @else
- <a class="button" href="{{ route('server.index') }}" {{ wireNavigate() }}>
- View servers
- </a>
- @endif
- <button type="button" title="Dismiss"
- @click="dismissed = true; localStorage.setItem('traffic-nudge-{{ $nudgeKey }}', '1')"
- class="flex h-6 w-6 items-center justify-center rounded-md text-neutral-400 transition-colors hover:text-black dark:text-fg-faint dark:hover:text-fg">
- <svg class="h-3.5 w-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
- <path stroke-linecap="round" stroke-linejoin="round" d="M6 6l12 12M6 18L18 6" />
- </svg>
- </button>
- </div>
- </div>
- @endif
-
@if ($servers->isEmpty())
<x-empty size="sm" title="Traffic analytics is not enabled"
description="Enable Sentinel traffic analytics on a server to see a team-wide summary here."
diff --git a/tests/Feature/TrafficAnalytics/TrafficNudgeTest.php b/tests/Feature/TrafficAnalytics/TrafficNudgeTest.php
index c82a93578e..bffc8f2e5f 100644
--- a/tests/Feature/TrafficAnalytics/TrafficNudgeTest.php
+++ b/tests/Feature/TrafficAnalytics/TrafficNudgeTest.php
@@ -1,5 +1,6 @@
<?php
+use App\Livewire\Analytics;
use App\Livewire\Dashboard\TrafficAnalytics as DashboardTrafficAnalytics;
use App\Models\PrivateKey;
use App\Models\Server;
@@ -32,15 +33,23 @@ function disabledServer(): Server
return $server;
}
-it('shows the dashboard nudge when an eligible server has analytics disabled', function () {
+it('does not show a traffic nudge on the dashboard', function () {
disabledServer();
Livewire::test(DashboardTrafficAnalytics::class)
+ ->assertOk()
+ ->assertDontSee('can start collecting traffic analytics');
+});
+
+it('shows the analytics-page nudge when an eligible server has analytics disabled', function () {
+ disabledServer();
+
+ Livewire::test(Analytics::class)
->assertOk()
->assertSee('can start collecting traffic analytics');
});
-it('does not count swarm or build servers in the dashboard nudge', function () {
+it('does not count swarm or build servers in the analytics-page nudge', function () {
$swarm = disabledServer();
$swarm->settings->is_swarm_manager = true;
$swarm->settings->save();
@@ -49,7 +58,7 @@ it('does not count swarm or build servers in the dashboard nudge', function () {
$build->settings->is_build_server = true;
$build->settings->save();
- Livewire::test(DashboardTrafficAnalytics::class)
+ Livewire::test(Analytics::class)
->assertOk()
->assertDontSee('can start collecting traffic analytics');
});