diff options
Diffstat (limited to 'src/lib/CommandPalette')
| -rw-r--r-- | src/lib/CommandPalette/CommandPalette.svelte | 11 | ||||
| -rw-r--r-- | src/lib/CommandPalette/authActions.ts | 5 |
2 files changed, 15 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(); diff --git a/src/lib/CommandPalette/authActions.ts b/src/lib/CommandPalette/authActions.ts index 9dbc9565..3dd51bf7 100644 --- a/src/lib/CommandPalette/authActions.ts +++ b/src/lib/CommandPalette/authActions.ts @@ -1,5 +1,6 @@ import { env } from "$env/dynamic/public"; import root from "$lib/Utility/root"; +import { track } from "$lib/analytics"; import localforage from "localforage"; import locale from "$stores/locale"; import { get } from "svelte/store"; @@ -18,6 +19,8 @@ export const authActions = ( preventDefault: true, tags: ["auth", "sign", "out", "user"], onClick: async () => { + track("Log Out", { source: "command-palette" }); + await localforage.removeItem("identity"); await localforage.removeItem("commit"); @@ -38,6 +41,8 @@ export const authActions = ( preventDefault: true, tags: ["auth", "sign", "in", "anilist"], onClick: async () => { + track("Log In", { source: "command-palette" }); + await localforage.setItem( "redirect", window.location.origin + |