From be151fd6f7e7860cc60bee67bab815c155e86fcd Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.net>
Date: Fri, 29 May 2026 23:05:37 +0000
Subject: feat(analytics): track umami events across core actions

Add a guarded track() wrapper (src/lib/analytics.ts) so programmatic
events no-op instead of throwing when umami is absent (localhost),
lazily loaded, or ad-blocked. Instrument the core loop (progress
increment, roulette, list filter, force refresh), the auth funnel
(log in/out, command palette), settings toggles/selects at the wrapper
level, sync/debug/feed actions, and tool/sharing actions.
---
 src/lib/List/Manga/CleanMangaList.svelte | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

(limited to 'src/lib/List/Manga/CleanMangaList.svelte')

diff --git a/src/lib/List/Manga/CleanMangaList.svelte b/src/lib/List/Manga/CleanMangaList.svelte
index 25e6d48f..af52ca02 100644
--- a/src/lib/List/Manga/CleanMangaList.svelte
+++ b/src/lib/List/Manga/CleanMangaList.svelte
@@ -31,6 +31,7 @@ import CleanList from "../CleanList.svelte";
 import stateBin from "$stores/stateBin";
 import localforage from "localforage";
 import MediaRoulette from "../MediaRoulette.svelte";
+import { track } from "$lib/analytics";
 
 export let media: Media[];
 export let cleanCache: () => void;
@@ -105,6 +106,10 @@ $: filteredMedia =
 const updateSelectedList = (event: Event) => {
 	const nextSelectedList = (event.currentTarget as HTMLSelectElement).value;
 
+	track("Filter Manga List", {
+		scope: nextSelectedList === "All" ? "all" : "custom",
+	});
+
 	selectedList = nextSelectedList;
 
 	if (!disableFilter && $stateBin[filterKey] !== nextSelectedList)
@@ -125,8 +130,11 @@ $: if (rateLimited && !serviceStatusResponse)
 	serviceStatusResponse = getMangadexServiceStatus();
 
 const increment = (manga: Media) => {
-	if (!(pendingUpdate === manga.id || dummy))
+	if (!(pendingUpdate === manga.id || dummy)) {
+		track("Increment Manga Progress");
+
 		updateMedia(manga.id, manga.mediaListEntry?.progress, media);
+	}
 };
 </script>
 
@@ -154,6 +162,7 @@ const increment = (manga: Media) => {
           class="small-button"
           onclick={() => (showRoulette = true)}
           title={$locale().lists.actions?.pickRandomManga}
+          data-umami-event="Open Manga Roulette"
         >
           Roulette
         </button>
-- 
cgit v1.2.3

