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(analytics): keep setup prompt dismissed after refresh

Andras Bacsai2fb8c411e9f5
diff --git a/resources/views/livewire/analytics.blade.php b/resources/views/livewire/analytics.blade.php
index 9b6fd3643b..3ae6f2f137 100644
--- a/resources/views/livewire/analytics.blade.php
+++ b/resources/views/livewire/analytics.blade.php
@@ -90,7 +90,7 @@ $appListboxOptions = array_merge(
{{-- Nudge: enabled-eligible servers that haven't turned traffic analytics on yet. --}}
@if ($scopedServerUuid === null && ! empty($eligibleDisabledServers))
- <div x-data="{ dismissed: localStorage.getItem('traffic-nudge-{{ $nudgeKey }}') === '1' }" x-show="!dismissed" x-cloak
+ <div wire:key="analytics-traffic-nudge" x-data="{ dismissed: localStorage.getItem('traffic-nudge-{{ $nudgeKey }}') === '1' }" x-show="!dismissed" x-cloak
class="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">
@@ -104,7 +104,7 @@ $appListboxOptions = array_merge(
<div class="flex shrink-0 items-center gap-2">
@if (count($eligibleDisabledServers) === 1)
<a class="button" href="{{ route('server.analytics', ['server_uuid' => $eligibleDisabledServers[0]['uuid']]) }}" {{ wireNavigate() }}>
- Enable on {{ \Illuminate\Support\Str::limit($eligibleDisabledServers[0]['name'], 16) }}
+ Set up on {{ \Illuminate\Support\Str::limit($eligibleDisabledServers[0]['name'], 16) }}
</a>
@else
<a class="button" href="{{ route('server.index') }}" {{ wireNavigate() }}>
diff --git a/tests/v4/Browser/TrafficAnalyticsTest.php b/tests/v4/Browser/TrafficAnalyticsTest.php
index ad4ba0a194..b7658b6779 100644
--- a/tests/v4/Browser/TrafficAnalyticsTest.php
+++ b/tests/v4/Browser/TrafficAnalyticsTest.php
@@ -44,6 +44,25 @@ it('shows the disabled empty state on the global analytics page', function () {
->screenshot(filename: 'global-analytics-disabled-empty-state');
});
+it('dismisses the global analytics enable prompt', function () {
+ loginAndSkipBoarding();
+
+ $page = visit('/analytics');
+
+ $page->assertVisible('[title="Dismiss"]')
+ ->assertSee('Set up on localhost');
+
+ expect($page->attribute('Set up on localhost', 'href'))
+ ->toContain('/server/'.$this->stack['server']->uuid.'/analytics');
+
+ $page->click('[title="Dismiss"]')
+ ->assertMissing('[title="Dismiss"]')
+ ->refresh()
+ ->assertSee('Traffic analytics is not enabled')
+ ->assertMissing('[title="Dismiss"]')
+ ->screenshot(filename: 'global-analytics-prompt-dismissed');
+});
+
it('shows the disabled empty state on the dashboard traffic widget', function () {
$page = loginAndSkipBoarding();