|
4 | 4 | import { locale } from 'svelte-i18n' |
5 | 5 | import SvgIcon from './SvgIcon.svelte' |
6 | 6 | import { language, theme } from '../stores' |
| 7 | + import { trackEvent } from '../helper/analytics' |
7 | 8 | import { saveUserSettings } from './../helper/settings' |
8 | 9 | import { TITLE, DEFAULT_THEME, LANG_ARR } from './../helper/constant' |
9 | 10 |
|
|
96 | 97 | const onToggleTheme = async () => { |
97 | 98 | const newTheme = $theme === DEFAULT_THEME ? 'dark' : DEFAULT_THEME |
98 | 99 | theme.set(newTheme) |
| 100 | + trackEvent('theme-toggle', { theme: newTheme }) |
99 | 101 | // 保存到服务器(响应式更新会自动触发,但这里显式调用以确保立即保存) |
100 | 102 | await saveUserSettings({ theme: newTheme }).catch((err) => { |
101 | 103 | console.error('Failed to save theme:', err) |
|
106 | 108 | lang = item.value |
107 | 109 | language.set(item.value) |
108 | 110 | updateUrlLang(item.value) |
| 111 | + trackEvent('language-change', { language: item.value }) |
109 | 112 |
|
110 | 113 | await saveUserSettings({ language: item.value }).catch((err) => { |
111 | 114 | console.error('Failed to save language:', err) |
|
115 | 118 |
|
116 | 119 | <header class="flex h-20 items-center justify-between" style="z-index: 1000;"> |
117 | 120 | <h1 class="h-full leading-none"> |
118 | | - <a href="/" title={TITLE} class="flex h-full items-center space-x-2 focus-visible:outline-none"> |
| 121 | + <a |
| 122 | + href="/" |
| 123 | + title={TITLE} |
| 124 | + class="flex h-full items-center space-x-2 focus-visible:outline-none" |
| 125 | + on:click={() => trackEvent('logo-click')}> |
119 | 126 | <img src="/logo.png" alt="Sink" class="h-5 w-5" /> |
120 | 127 | <span class="title font-[cursive] text-xl font-semibold">{TITLE}</span> |
121 | 128 | </a> |
|
126 | 133 | rel="noopener" |
127 | 134 | class="focus-visible-ring inline-flex rounded-md p-2 leading-5 outline-none hover:bg-gray-100" |
128 | 135 | href="https://x.com/intent/user?screen_name=MarshalXuan" |
129 | | - title="X | Twitter Follow MarshalXuan"> |
| 136 | + title="X | Twitter Follow MarshalXuan" |
| 137 | + on:click={() => trackEvent('social-link-click', { platform: 'x' })}> |
130 | 138 | <SvgIcon name="x" width={20} height={20} color="#212121" /> |
131 | 139 | </a> |
132 | 140 | <button |
|
169 | 177 | title="Github" |
170 | 178 | class="inline-flex w-full items-center rounded-full bg-gray-900 px-6 py-3 text-sm |
171 | 179 | leading-4 text-white hover:bg-gray-800 hover:text-white focus:outline-none focus:ring-0 |
172 | | - focus:ring-offset-2 md:hidden md:w-auto md:rounded-full md:px-3 md:focus:ring-2"> |
| 180 | + focus:ring-offset-2 md:hidden md:w-auto md:rounded-full md:px-3 md:focus:ring-2" |
| 181 | + on:click={() => trackEvent('social-link-click', { platform: 'github' })}> |
173 | 182 | <SvgIcon name="githubx" width={20} height={20} color="#ffffff" /> |
174 | 183 | <strong class="ml-2 font-semibold">GitHub</strong> |
175 | 184 | </a> |
|
0 commit comments