feat...?: add opt in send usage info button
This commit is contained in:
3 files changed
+27
-3
No files matched your search
@@ -712,7 +712,8 @@
|
|||||||
"settingsImport": "Successfully imported settings",
|
"settingsImport": "Successfully imported settings",
|
||||||
"settingsImportWarning": "The imported settings don't seem valid. Are you sure you want to import this?",
|
"settingsImportWarning": "The imported settings don't seem valid. Are you sure you want to import this?",
|
||||||
"userLoading": "Still loading your user data...",
|
"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": {
|
"settings": {
|
||||||
"title": "Settings",
|
"title": "Settings",
|
||||||
|
|||||||
@@ -6,13 +6,14 @@ export const POST: RequestHandler = async ({ request, getClientAddress }) => {
|
|||||||
const body = await request.json()
|
const body = await request.json()
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
theme: body.theme,
|
|
||||||
profiles: body.profiles,
|
profiles: body.profiles,
|
||||||
settings: body.settings,
|
settings: body.settings,
|
||||||
|
device: body.device,
|
||||||
}
|
}
|
||||||
|
|
||||||
await fetch(envPrivate.PRIVATE_DIAGNOSTICS_URL, {
|
await fetch(envPrivate.PRIVATE_DIAGNOSTICS_URL, {
|
||||||
body: JSON.stringify(payload),
|
body: JSON.stringify(payload),
|
||||||
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: envPrivate.PRIVATE_DIAGNOSTIC_KEY,
|
Authorization: envPrivate.PRIVATE_DIAGNOSTIC_KEY,
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|||||||
@@ -118,6 +118,15 @@
|
|||||||
return payload
|
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<
|
let localeMap: Map<
|
||||||
string,
|
string,
|
||||||
{
|
{
|
||||||
@@ -180,10 +189,19 @@
|
|||||||
|
|
||||||
{#if diagnostic.open}
|
{#if diagnostic.open}
|
||||||
<Modal title={$t('settings.usageInfo.title')} bind:open={diagnostic.open}>
|
<Modal title={$t('settings.usageInfo.title')} bind:open={diagnostic.open}>
|
||||||
|
<form
|
||||||
|
onsubmit={e => {
|
||||||
|
e.preventDefault()
|
||||||
|
submitDiagnostics()
|
||||||
|
diagnostic.open = false
|
||||||
|
toast({ content: $t('toast.successDiagnostic'), type: 'success' })
|
||||||
|
}}
|
||||||
|
class="space-y-3"
|
||||||
|
>
|
||||||
<Markdown
|
<Markdown
|
||||||
source={$t('settings.usageInfo.body', { hostname: page.url.hostname })}
|
source={$t('settings.usageInfo.body', { hostname: page.url.hostname })}
|
||||||
/>
|
/>
|
||||||
<hr class="my-1 border-slate-200 dark:border-zinc-800" />
|
<hr class="mb-4 border-slate-200 dark:border-zinc-800" />
|
||||||
<Switch bind:checked={diagnostic.profile}>
|
<Switch bind:checked={diagnostic.profile}>
|
||||||
{$t('settings.usageInfo.profiles')}
|
{$t('settings.usageInfo.profiles')}
|
||||||
</Switch>
|
</Switch>
|
||||||
@@ -196,6 +214,10 @@
|
|||||||
<pre class="max-w-full">
|
<pre class="max-w-full">
|
||||||
{JSON.stringify(diagPayload, undefined, 2)}
|
{JSON.stringify(diagPayload, undefined, 2)}
|
||||||
</pre>
|
</pre>
|
||||||
|
<Button color="primary" size="lg" class="w-full" submit>
|
||||||
|
{$t('form.submit')}
|
||||||
|
</Button>
|
||||||
|
</form>
|
||||||
</Modal>
|
</Modal>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user