debug(push): add native push-setup telemetry to trace iOS registration

device_tokens stays empty after reinstall+Allow, so the APNs token is never
obtained or never reaches the server, and there's no device console on Windows.
Add a /api/push-debug collector and breadcrumbs through setupNativePush (plugin
presence, permission state, register call, registration event/error, token POST
result) so the failing step is visible in server logs. Temporary — remove once
push is confirmed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-27 21:20:03 +05:30
parent 83b445e32d
commit c6523a8461
2 changed files with 28 additions and 10 deletions
+12
View File
@@ -424,6 +424,18 @@ route('POST', '/api/devices/remove', async (req, res) => {
json(res, 200, { ok: true });
});
// --- Push diagnostics (temporary): the native app reports each step of push setup here so we can see
// WHERE iOS registration fails without a Mac/device console. Best-effort; logs and returns 200. ---
route('POST', '/api/push-debug', async (req, res) => {
try {
const b = await readBody(req);
let uid = 'anon'; try { const u = await currentUser(req); if (u) uid = u.id; } catch (_) {}
const line = (typeof b === 'object' ? JSON.stringify(b) : String(b)).slice(0, 800);
console.log('[push-debug] user=' + uid + ' ' + line);
} catch (_) {}
json(res, 200, { ok: true });
});
// --- App install telemetry: records each install and, once the user signs in, who's using it. ---
route('POST', '/api/telemetry/install', async (req, res) => {
const { installId, platform, appVersion, os } = await readBody(req);