Merge pull request #631 from Xyphyn/revert-630-opt-in-diagnostic

Revert "misc: opt in diagnostic"
This commit is contained in:
Xylight authored and GitHub committed 2025-08-06 20:19:11 +00:00
commit 8ab3c09eec
3 files changed
+1 -138

No files matched your search

+1 -10
View File
@@ -716,8 +716,7 @@
"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.*",
"successDiagnostic": "Thank you for submitting this information!"
"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.*"
},
"settings": {
"title": "Settings",
@@ -728,14 +727,6 @@
"export": "Export",
"import": "Import",
"reset": "Reset",
"usageInfo": {
"title": "Send usage info",
"body": "You can help the development of Photon by sending information about how you use the app. This is entirely opt-in, and nothing is shared when you don't explicitly ask to.\n\nThe data under 'payload' will be sent to `https://{{hostname}}/api/diagnostic` via `POST`, and such data will be handled by the owner(s) of **{{hostname}}**.",
"profiles": "Profile count and instances (no usernames)",
"settings": "Your chosen photon settings",
"device": "Info about your device",
"payload": "Payload"
},
"navigation": {
"title": "Navigation",
"autoHide": {
-26
View File
@@ -1,26 +0,0 @@
import type { RequestHandler } from '@sveltejs/kit'
import { env as envPrivate } from '$env/dynamic/private'
// this is a very rudimentary 'security' system.
export const POST: RequestHandler = async ({ request, getClientAddress }) => {
const body = await request.json()
const payload = {
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',
// so that any upstream diagnostic server can handle abuse
'x-forwarded-for': getClientAddress(),
},
})
return new Response(JSON.stringify({ success: true, storedData: payload }))
}
-102
View File
@@ -36,7 +36,6 @@
Bars2,
Bars3,
BarsArrowDown,
Beaker,
BookOpen,
BugAnt,
Calendar,
@@ -71,63 +70,9 @@
import Section from './Section.svelte'
import Setting from './Setting.svelte'
import ToggleSetting from './ToggleSetting.svelte'
import { page } from '$app/state'
import Markdown from '$lib/components/markdown/Markdown.svelte'
let importing = $state(false)
let importText = $state('')
let diagnostic = $state({
open: false,
profile: false,
settings: false,
device: false,
})
let diagPayload = $derived(calculatePayload(diagnostic))
function calculatePayload(args: {
profile: boolean
settings: boolean
device: boolean
}) {
// eslint-disable-next-line
let payload: Record<string, any> = {}
if (args.profile) {
payload.profiles = {
count: profile.meta.profiles.length,
instances: [profile.meta.profiles.map(i => i.instance)],
}
}
if (args.settings) {
payload.settings = $state.snapshot(settings)
}
if (args.device) {
payload.device = {
userAgent: navigator.userAgent,
windowSize: {
width: window.innerWidth,
height: window.innerHeight,
ratio: window.devicePixelRatio,
},
language: navigator.language,
platform: navigator.platform,
}
}
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,
{
@@ -188,40 +133,6 @@
</Modal>
{/if}
{#if 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
source={$t('settings.usageInfo.body', { hostname: page.url.hostname })}
/>
<hr class="mb-4 border-slate-200 dark:border-zinc-800" />
<Switch bind:checked={diagnostic.profile}>
{$t('settings.usageInfo.profiles')}
</Switch>
<Switch bind:checked={diagnostic.settings}>
{$t('settings.usageInfo.settings')}
</Switch>
<Switch bind:checked={diagnostic.device}>
{$t('settings.usageInfo.device')}
</Switch>
<pre class="max-w-full">
{JSON.stringify(diagPayload, undefined, 2)}
</pre>
<Button color="primary" size="lg" class="w-full" submit>
{$t('form.submit')}
</Button>
</form>
</Modal>
{/if}
<Header pageHeader class="text-3xl font-bold flex justify-between">
{$t('settings.title')}
{#snippet extended()}
@@ -294,19 +205,6 @@
</Button>
</div>
{#if env.PUBLIC_DIAGNOSTICS.toLowerCase() == 'true'}
<Button
onclick={() => (diagnostic.open = !diagnostic.open)}
rounding="pill"
class="w-max"
>
{#snippet prefix()}
<Icon src={Beaker} mini size="18" />
{/snippet}
{$t('settings.usageInfo.title')}
</Button>
{/if}
<div
class="flex flex-col *:py-2 divide-y divide-slate-200 dark:divide-zinc-800"
style="scroll-behavior: smooth;"