fix(analytics): keep setup prompt dismissed after refresh

Give the traffic analytics prompt a stable Livewire key and label the server link “Set up on”. Add a browser test for the link and persistent dismissal.
This commit is contained in:
Andras Bacsai
2026-09-24 15:26:08 +02:00
parent 33eb1dab79
commit 2fb8c411e9
2 changed files with 21 additions and 2 deletions
+2 -2
View File
@@ -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() }}>
+19
View File
@@ -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();