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/Settings/SettingCheckboxToggle.svelte | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

(limited to 'src/lib/Settings/SettingCheckboxToggle.svelte')

diff --git a/src/lib/Settings/SettingCheckboxToggle.svelte b/src/lib/Settings/SettingCheckboxToggle.svelte
index 1f58520d..e45077f7 100644
--- a/src/lib/Settings/SettingCheckboxToggle.svelte
+++ b/src/lib/Settings/SettingCheckboxToggle.svelte
@@ -2,6 +2,7 @@
 import Spacer from "$lib/Layout/Spacer.svelte";
 import tooltip from "$lib/Tooltip/tooltip";
 import settings, { type Settings } from "$stores/settings";
+import { track } from "$lib/analytics";
 
 type BooleanSettingsKeys<T> = {
 	[K in keyof T]: T[K] extends boolean ? K : never;
@@ -52,13 +53,21 @@ const check = (
 	const checked = (e.target as HTMLInputElement).checked;
 
 	if (setting) {
-		settings.setKey(setting, invert ? !checked : checked);
+		const value = invert ? !checked : checked;
+
+		settings.setKey(setting, value);
+		track("Toggle Setting", { key: setting, value });
 		onChange();
 	}
 };
 
 const flip = () => {
-	if (setting) $settings[setting] = !$settings[setting];
+	if (setting) {
+		const value = !$settings[setting];
+
+		$settings[setting] = value;
+		track("Toggle Setting", { key: setting, value });
+	}
 };
 </script>
 
-- 
cgit v1.2.3

