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/SettingToggle.svelte | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

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

diff --git a/src/lib/Settings/SettingToggle.svelte b/src/lib/Settings/SettingToggle.svelte
index 0e77c9b0..a84a7a72 100644
--- a/src/lib/Settings/SettingToggle.svelte
+++ b/src/lib/Settings/SettingToggle.svelte
@@ -1,23 +1,25 @@
 <script lang="ts">
 import Spacer from "$lib/Layout/Spacer.svelte";
 import settings, { type Settings } from "$stores/settings";
+import { track } from "$lib/analytics";
 
 export let setting: keyof Settings;
 export let on = "";
 export let off = "";
 export let sectionBreak = false;
 export let disabled = false;
+
+const toggle = () => {
+	if (disabled) return;
+
+	const value = !$settings[setting];
+
+	settings.setKey(setting, value);
+	track("Toggle Setting", { key: setting, value });
+};
 </script>
 
-<a
-  href={'#'}
-  onclick={() =>
-    disabled
-      ? {}
-      : $settings[setting]
-        ? settings.setKey(setting, false)
-        : settings.setKey(setting, true)}
->
+<a href={'#'} onclick={toggle}>
   {#if disabled}
     <strike>
       {$settings[setting] ? on : off}
-- 
cgit v1.2.3

