add umami analytics integration

This commit is contained in:
jeffvli
2025-11-26 01:16:17 -08:00
parent c77d38fca0
commit 778d878349
13 changed files with 594 additions and 19 deletions
@@ -1,5 +1,6 @@
import { Fragment } from 'react/jsx-runtime';
import { AnalyticsSettings } from '/@/renderer/features/settings/components/advanced/analytics-settings';
import { ExportImportSettings } from '/@/renderer/features/settings/components/advanced/export-import-settings';
import { CacheSettings } from '/@/renderer/features/settings/components/window/cache-settngs';
import { UpdateSettings } from '/@/renderer/features/settings/components/window/update-settings';
@@ -8,6 +9,7 @@ import { Stack } from '/@/shared/components/stack/stack';
const sections = [
{ component: UpdateSettings, key: 'update' },
{ component: AnalyticsSettings, key: 'analytics' },
{ component: ExportImportSettings, key: 'export-import' },
{ component: CacheSettings, key: 'cache' },
];
@@ -0,0 +1,39 @@
import { useTranslation } from 'react-i18next';
import {
SettingOption,
SettingsSection,
} from '/@/renderer/features/settings/components/settings-section';
import { Switch } from '/@/shared/components/switch/switch';
export const AnalyticsSettings = () => {
const { t } = useTranslation();
const handleToggleAnalytics = (disable: boolean) => {
if (disable) {
localStorage.setItem('umami.disabled', '1');
} else {
localStorage.removeItem('umami.disabled');
}
};
const analyticsOptions: SettingOption[] = [
{
control: (
<Switch
defaultChecked={localStorage.getItem('umami.disabled') === '1'}
onChange={(e) => handleToggleAnalytics(e.currentTarget.checked)}
/>
),
description: t('setting.analyticsDisable_description', { postProcess: 'sentenceCase' }),
title: t('setting.analyticsDisable', { postProcess: 'sentenceCase' }),
},
];
return (
<SettingsSection
options={analyticsOptions}
title={t('page.setting.analytics', { postProcess: 'sentenceCase' })}
/>
);
};