From 9e24f26389dbee942035c003b238a033a8fe7639 Mon Sep 17 00:00:00 2001 From: James Xylight Date: Wed, 30 Jul 2025 18:22:25 -0700 Subject: [PATCH] feat...?: add opt in send usage info button --- src/lib/i18n/en.json | 3 +- src/routes/api/diagnostic/+server.ts | 3 +- src/routes/settings/+page.svelte | 50 ++++++++++++++++++++-------- 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json index dcf56d2a..255c3f56 100644 --- a/src/lib/i18n/en.json +++ b/src/lib/i18n/en.json @@ -712,7 +712,8 @@ "settingsImport": "Successfully imported settings", "settingsImportWarning": "The imported settings don't seem valid. Are you sure you want to import this?", "userLoading": "Still loading your user data...", - "lemmyDonate": "Your account's instance runs Lemmy, and the developers are requesting donations. They are able to develop Lemmy as an open source platform, free of tracking and ads, thanks to the generosity of its users.\n\nAnnually, they ask you to consider donating to support their work, and allow them to continue maintaining and improving Lemmy.\n\n[Donate](https://join-lemmy.org/donate)\n\n*Note: this is a donation to Lemmy, not Photon.*" + "lemmyDonate": "Your account's instance runs Lemmy, and the developers are requesting donations. They are able to develop Lemmy as an open source platform, free of tracking and ads, thanks to the generosity of its users.\n\nAnnually, they ask you to consider donating to support their work, and allow them to continue maintaining and improving Lemmy.\n\n[Donate](https://join-lemmy.org/donate)\n\n*Note: this is a donation to Lemmy, not Photon.*", + "successDiagnostic": "Thank you for submitting this information!" }, "settings": { "title": "Settings", diff --git a/src/routes/api/diagnostic/+server.ts b/src/routes/api/diagnostic/+server.ts index 2b7dfa88..9bb994ef 100644 --- a/src/routes/api/diagnostic/+server.ts +++ b/src/routes/api/diagnostic/+server.ts @@ -6,13 +6,14 @@ export const POST: RequestHandler = async ({ request, getClientAddress }) => { const body = await request.json() const payload = { - theme: body.theme, profiles: body.profiles, settings: body.settings, + device: body.device, } await fetch(envPrivate.PRIVATE_DIAGNOSTICS_URL, { body: JSON.stringify(payload), + method: 'POST', headers: { Authorization: envPrivate.PRIVATE_DIAGNOSTIC_KEY, 'Content-Type': 'application/json', diff --git a/src/routes/settings/+page.svelte b/src/routes/settings/+page.svelte index f236192b..3f079aad 100644 --- a/src/routes/settings/+page.svelte +++ b/src/routes/settings/+page.svelte @@ -118,6 +118,15 @@ return payload } + async function submitDiagnostics() { + if (Object.keys(diagPayload).length == 0) return + + await fetch('/api/diagnostic', { + method: 'POST', + body: JSON.stringify(diagPayload), + }) + } + let localeMap: Map< string, { @@ -180,22 +189,35 @@ {#if diagnostic.open} - -
- - {$t('settings.usageInfo.profiles')} - - - {$t('settings.usageInfo.settings')} - - - {$t('settings.usageInfo.device')} - -
+    
{ + e.preventDefault() + submitDiagnostics() + diagnostic.open = false + toast({ content: $t('toast.successDiagnostic'), type: 'success' }) + }} + class="space-y-3" + > + +
+ + {$t('settings.usageInfo.profiles')} + + + {$t('settings.usageInfo.settings')} + + + {$t('settings.usageInfo.device')} + +
       {JSON.stringify(diagPayload, undefined, 2)}
     
+ + {/if}