From a5c293bcc9cedf008438345bcfa7c3b67be6d2ca Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 11 Mar 2026 18:47:09 -0500 Subject: [PATCH] Add Plausible Analytics settings to System Settings page --- src/locales/en.json | 5 ++ src/pages/SystemSettings.tsx | 124 ++++++++++++++++++++++++++++++++++- 2 files changed, 128 insertions(+), 1 deletion(-) diff --git a/src/locales/en.json b/src/locales/en.json index ae0b8a9a..1d82021e 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -59,6 +59,11 @@ "temporaryDirectory": "Temporary", "sentryDsn": "Sentry DSN", "sentryDsnDescription": "Sentry Data Source Name (DSN) for error reporting. Leave empty to disable Sentry.", + "plausibleAnalytics": "Plausible Analytics", + "plausibleDomain": "Domain", + "plausibleDomainDescription": "The domain to track with Plausible Analytics. Leave empty to disable analytics.", + "plausibleEndpoint": "API Endpoint", + "plausibleEndpointDescription": "Custom Plausible API endpoint for self-hosted instances. Leave empty to use Plausible Cloud's default endpoint.", "shareErrorReports": "Share error reports", "shareErrorReportsDescription": "Help improve this app by automatically sending crash and error reports.", "systemPrompt": "System Prompt", diff --git a/src/pages/SystemSettings.tsx b/src/pages/SystemSettings.tsx index b4b06935..a132339a 100644 --- a/src/pages/SystemSettings.tsx +++ b/src/pages/SystemSettings.tsx @@ -1,4 +1,4 @@ -import { Settings, RefreshCw, Trash2, XCircle, Loader2, RotateCcw, Cog, Globe, Image, Code, Monitor, Award, Bug, FolderTree, Terminal as TerminalIcon, GitBranch } from "lucide-react"; +import { Settings, RefreshCw, Trash2, XCircle, Loader2, RotateCcw, Cog, Globe, Image, Code, Monitor, Award, Bug, BarChart3, FolderTree, Terminal as TerminalIcon, GitBranch } from "lucide-react"; import { useTranslation } from 'react-i18next'; import { useState, useEffect, useMemo } from "react"; import { Button } from "@/components/ui/button"; @@ -30,6 +30,8 @@ export function SystemSettings() { const [fsPathPluginsInput, setFsPathPluginsInput] = useState(config.fsPathPlugins); const [fsPathTemplatesInput, setFsPathTemplatesInput] = useState(config.fsPathTemplates); const [sentryDsnInput, setSentryDsnInput] = useState(config.sentryDsn); + const [plausibleDomainInput, setPlausibleDomainInput] = useState(config.plausibleDomain); + const [plausibleEndpointInput, setPlausibleEndpointInput] = useState(config.plausibleEndpoint); // Check which settings differ from defaults const isModified = useMemo(() => ({ @@ -46,6 +48,8 @@ export function SystemSettings() { fsPathPlugins: config.fsPathPlugins !== defaultConfig.fsPathPlugins, fsPathTemplates: config.fsPathTemplates !== defaultConfig.fsPathTemplates, sentryDsn: config.sentryDsn !== defaultConfig.sentryDsn, + plausibleDomain: config.plausibleDomain !== defaultConfig.plausibleDomain, + plausibleEndpoint: config.plausibleEndpoint !== defaultConfig.plausibleEndpoint, }), [config, defaultConfig]); // Restore functions - clear the value from config to use the default @@ -164,6 +168,24 @@ export function SystemSettings() { }); }; + const restorePlausibleDomain = () => { + const defaultValue = defaultConfig.plausibleDomain; + setPlausibleDomainInput(defaultValue); + updateConfig((current) => { + const { plausibleDomain, ...rest } = current; + return rest; + }); + }; + + const restorePlausibleEndpoint = () => { + const defaultValue = defaultConfig.plausibleEndpoint; + setPlausibleEndpointInput(defaultValue); + updateConfig((current) => { + const { plausibleEndpoint, ...rest } = current; + return rest; + }); + }; + // Service Worker state const [swState, setSwState] = useState(''); const [isUpdatingSW, setIsUpdatingSW] = useState(false); @@ -755,6 +777,106 @@ export function SystemSettings() { + {/* Plausible Analytics Configuration */} + + + +
+ +

{t('plausibleAnalytics')}

+ {(isModified.plausibleDomain || isModified.plausibleEndpoint) && ( +
+ )} +
+ + +
+
+
+ + {isModified.plausibleDomain && ( +
+ )} +
+
+ { + const value = e.target.value; + setPlausibleDomainInput(value); + updateConfig((current) => ({ + ...current, + plausibleDomain: value, + })); + }} + className="flex-1" + /> + {isModified.plausibleDomain && ( + + )} +
+

+ {t('plausibleDomainDescription')} +

+
+ +
+
+ + {isModified.plausibleEndpoint && ( +
+ )} +
+
+ { + const value = e.target.value; + setPlausibleEndpointInput(value); + updateConfig((current) => ({ + ...current, + plausibleEndpoint: value, + })); + }} + className="flex-1" + /> + {isModified.plausibleEndpoint && ( + + )} +
+

+ {t('plausibleEndpointDescription')} +

+
+
+ + + + {/* Filesystem Paths Configuration */}