Add guest analytics consent nudge
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled

This commit is contained in:
Codex Agent
2026-01-23 16:20:14 +01:00
parent 4bf0d5052c
commit bdb1789a10
7 changed files with 388 additions and 9 deletions

View File

@@ -24,6 +24,7 @@ import type { LocaleCode } from '../i18n/messages';
import { useHapticsPreference } from '../hooks/useHapticsPreference';
import { triggerHaptic } from '../lib/haptics';
import { getHelpSlugForPathname } from '../lib/helpRouting';
import { useConsent } from '@/contexts/consent';
const legalPages = [
{ slug: 'impressum', translationKey: 'settings.legal.section.impressum' },
@@ -270,6 +271,8 @@ function HomeView({
}: HomeViewProps) {
const { t } = useTranslation();
const { enabled: hapticsEnabled, setEnabled: setHapticsEnabled, supported: hapticsSupported } = useHapticsPreference();
const { preferences, savePreferences } = useConsent();
const matomoEnabled = typeof window !== 'undefined' && Boolean((window as any).__MATOMO_GUEST__?.enabled);
const legalLinks = React.useMemo(
() =>
legalPages.map((page) => ({
@@ -389,6 +392,26 @@ function HomeView({
</CardContent>
</Card>
{matomoEnabled ? (
<Card>
<CardHeader className="pb-3">
<CardTitle>{t('settings.analytics.title')}</CardTitle>
<CardDescription>{t('settings.analytics.description')}</CardDescription>
</CardHeader>
<CardContent className="space-y-2">
<div className="flex items-center justify-between gap-4">
<span className="text-sm font-medium">{t('settings.analytics.label')}</span>
<Switch
checked={Boolean(preferences?.analytics)}
onCheckedChange={(checked) => savePreferences({ analytics: checked })}
aria-label={t('settings.analytics.label')}
/>
</div>
<div className="text-xs text-muted-foreground">{t('settings.analytics.note')}</div>
</CardContent>
</Card>
) : null}
<Card>
<CardHeader className="pb-3">
<CardTitle>