Make onboarding tour install-wide instead of per-browser

Persist onboardingCompleted flag server-side via /api/v1/config so the
tour only auto-starts once per DashCaddy installation, not on every
new browser that connects.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-11 21:58:10 -07:00
parent 2d1944fd55
commit 063bf948b1
5 changed files with 56 additions and 8 deletions

View File

@@ -58,7 +58,12 @@
if (d.success) window._updateAuthCard(d.config.enabled && d.config.isSetUp, d.config.sessionDuration);
} catch (e) { /* ignore */ }
}
// Lazy-load onboarding for first-time users, otherwise just add the tour button
if (window.__dashcaddySiteConfigLoaded) {
try {
await window.__dashcaddySiteConfigLoaded;
} catch (_) { /* ignore */ }
}
// Lazy-load onboarding only once per install, otherwise just add the tour button
addTourButton();
if (shouldLoadOnboarding()) {
loadOnboarding();
@@ -89,6 +94,9 @@
// Check if onboarding should auto-start (first-time user)
function shouldLoadOnboarding() {
if (typeof SITE !== 'undefined' && SITE.onboardingCompleted) {
return false;
}
try {
const data = JSON.parse(localStorage.getItem('dashcaddy_onboarding'));
return !data || (!data.tourCompleted && data.currentStep === 0);
@@ -140,11 +148,10 @@
function addTourButton() {
if (document.getElementById('restart-tour-btn')) return;
// Check if tour has been completed before
let tourDone = false;
let tourDone = typeof SITE !== 'undefined' && SITE.onboardingCompleted;
try {
const data = JSON.parse(localStorage.getItem('dashcaddy_onboarding'));
tourDone = data && data.tourCompleted;
tourDone = tourDone || !!(data && data.tourCompleted);
} catch (_) {}
// Before first completion: show in primary toolbar. After: tuck into Admin section.