Skip to content

Commit b9d13d0

Browse files
committed
fix: improve UX and tracking
- Change landing page progress to positive wording ('X lessons to explore') - Add scroll to top when navigating between pages - Fix section pill highlighting for welcome/playground modules - Add Umami tracking for language URL switch and landing page clicks
1 parent 5b6b283 commit b9d13d0

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

src/app.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,6 +1939,7 @@ function handleRoute(shouldUpdateUrl = true) {
19391939
break;
19401940
case RouteType.LANGUAGE:
19411941
// Switch language and redirect to home
1942+
track("language_url", { language: route.lang });
19421943
setLanguage(route.lang);
19431944
applyTranslations();
19441945
// Sync language dropdown
@@ -1977,6 +1978,7 @@ function hideAllPages() {
19771978
function showLandingPage() {
19781979
hideAllPages();
19791980
elements.landingPage?.classList.remove("hidden");
1981+
window.scrollTo(0, 0);
19801982

19811983
// Update section progress on landing page
19821984
updateLandingProgress();
@@ -2000,7 +2002,7 @@ function updateLandingProgress() {
20002002
}
20012003
});
20022004
if (total > 0) {
2003-
progressEl.textContent = `${completed}/${total} lessons`;
2005+
progressEl.textContent = `${total} lessons to explore`;
20042006
} else {
20052007
progressEl.textContent = "";
20062008
}
@@ -2014,6 +2016,7 @@ function updateLandingProgress() {
20142016
function showSectionPage(sectionId) {
20152017
hideAllPages();
20162018
elements.sectionPage?.classList.remove("hidden");
2019+
window.scrollTo(0, 0);
20172020

20182021
// Track section page view
20192022
track("section_view", { section: sectionId });
@@ -2061,6 +2064,7 @@ function showSectionPage(sectionId) {
20612064
function showReferencePage(refId) {
20622065
hideAllPages();
20632066
elements.referencePage?.classList.remove("hidden");
2067+
window.scrollTo(0, 0);
20642068

20652069
// Default to CSS if no refId
20662070
const activeRef = refId || "css";
@@ -2181,8 +2185,9 @@ function updateNavHighlight(route) {
21812185
link.classList.add("active");
21822186
} else if (route?.type === RouteType.LESSON) {
21832187
// Highlight section based on module's inferred section
2188+
// Skip highlighting for modules excluded from progress (welcome, playground, goodbye)
21842189
const module = lessonEngine.modules.find((m) => m.id === route.moduleId);
2185-
if (module) {
2190+
if (module && !module.excludeFromProgress) {
21862191
const moduleSection = getModuleSection(module);
21872192
if (link.dataset.section === moduleSection) {
21882193
link.classList.add("active");
@@ -2363,6 +2368,18 @@ function init() {
23632368
closeSidebar();
23642369
}
23652370
});
2371+
2372+
// Landing page tracking (event delegation)
2373+
elements.landingPage?.addEventListener("click", (e) => {
2374+
const target = e.target.closest("a");
2375+
if (!target) return;
2376+
2377+
if (target.classList.contains("cta-button")) {
2378+
track("landing_cta", { href: target.getAttribute("href") });
2379+
} else if (target.classList.contains("section-card")) {
2380+
track("landing_section", { section: target.dataset.section });
2381+
}
2382+
});
23662383
}
23672384

23682385
// Start the application

0 commit comments

Comments
 (0)