aboutsummaryrefslogtreecommitdiff
path: root/src/lib/CommandPalette/CommandPalette.svelte
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-05-29 23:05:37 +0000
committerFuwn <[email protected]>2026-05-29 23:05:37 +0000
commitbe151fd6f7e7860cc60bee67bab815c155e86fcd (patch)
tree47dcfe80450479efe722f4b59c58f934d07f3618 /src/lib/CommandPalette/CommandPalette.svelte
parentfeat(lists): animate list-title count with NumberTicker (diff)
downloaddue.moe-be151fd6f7e7860cc60bee67bab815c155e86fcd.tar.xz
due.moe-be151fd6f7e7860cc60bee67bab815c155e86fcd.zip
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.
Diffstat (limited to 'src/lib/CommandPalette/CommandPalette.svelte')
-rw-r--r--src/lib/CommandPalette/CommandPalette.svelte11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/lib/CommandPalette/CommandPalette.svelte b/src/lib/CommandPalette/CommandPalette.svelte
index 04eabff9..bf568200 100644
--- a/src/lib/CommandPalette/CommandPalette.svelte
+++ b/src/lib/CommandPalette/CommandPalette.svelte
@@ -4,6 +4,7 @@ import { fly, fade } from "svelte/transition";
import { flip } from "svelte/animate";
import type { CommandPaletteAction } from "./actions";
import locale from "$stores/locale";
+import { track } from "$lib/analytics";
export let items: CommandPaletteAction[] = [];
export let open = false;
@@ -103,6 +104,8 @@ $: if (open && !isVisible) {
}
const executeItem = (item: CommandPaletteAction) => {
+ track("Run Command", { command: item.name });
+
if (item.onClick) item.onClick();
if (!item.preventDefault) window.location.href = item.url;
@@ -158,7 +161,11 @@ const handleGlobalKey = (e: KeyboardEvent) => {
open = !open;
- if (open) requestAnimationFrame(() => inputRef?.focus());
+ if (open) {
+ track("Open Command Palette");
+
+ requestAnimationFrame(() => inputRef?.focus());
+ }
}
};
</script>
@@ -214,6 +221,8 @@ const handleGlobalKey = (e: KeyboardEvent) => {
out:fly={{ y: -20, duration: 150 }}
animate:flip={{ duration: 200 }}
onclick={(e) => {
+ track('Run Command', { command: item.name });
+
if (item.preventDefault) e.preventDefault();
if (item.onClick) item.onClick();