import type { GlobalConfig } from "payload"; import { canViewAnalytics, isAdmin } from "@/access"; /** * Retention configuration for the analytics system, enforced by the nightly * cleanup cron (lib/analytics/cleanup.ts) and shown in the "Analytics & * Datenschutz" panel of the dashboard (components/admin/AdminAnalyticsView.tsx). */ export const AnalyticsSettings: GlobalConfig = { slug: "analytics-settings", label: "Auswertungs-Einstellungen", admin: { description: "Aufbewahrungsdauer für Rohdaten und zusammengefasste Tagesstatistiken.", group: "Datenschutz", }, access: { read: canViewAnalytics, update: isAdmin, }, fields: [ { name: "rawRetentionDays", type: "number", label: "Rohdaten-Aufbewahrung (Tage)", required: true, defaultValue: 90, min: 7, admin: { description: "Wie lange einzelne Messwerte gespeichert bleiben. Begrenzt auch den wählbaren Zeitraum in der Auswertung.", }, }, { name: "aggregateRetentionMonths", type: "number", label: "Aggregat-Aufbewahrung (Monate)", required: true, defaultValue: 12, min: 1, admin: { description: "Wie lange die täglichen Aggregat-Statistiken (ohne Einzel-Events) gespeichert bleiben.", }, }, ], };