diff --git a/api/_sentry-edge.js b/api/_sentry-edge.js index 320e0c792..2a5bdb549 100644 --- a/api/_sentry-edge.js +++ b/api/_sentry-edge.js @@ -28,8 +28,9 @@ export async function captureEdgeException(err, context = {}) { const errMsg = err instanceof Error ? err.message : String(err); const errType = err instanceof Error ? err.constructor.name : 'Error'; try { - await fetch(_storeUrl, { + const res = await fetch(_storeUrl, { method: 'POST', + signal: AbortSignal.timeout(2000), headers: { 'Content-Type': 'application/json', 'X-Sentry-Auth': `Sentry sentry_version=7, sentry_key=${_key}`, @@ -45,5 +46,15 @@ export async function captureEdgeException(err, context = {}) { tags: { runtime: 'edge' }, }), }); - } catch {} + if (!res.ok) { + const hint = res.status === 401 || res.status === 403 + ? ' — check VITE_SENTRY_DSN and auth key' + : res.status === 429 + ? ' — rate limited by Sentry' + : ' — Sentry outage or transient error'; + console.warn(`[sentry-edge] non-2xx response ${res.status}${hint}`); + } + } catch (fetchErr) { + console.warn('[sentry-edge] failed to deliver event:', fetchErr instanceof Error ? fetchErr.message : fetchErr); + } } diff --git a/api/notification-channels.ts b/api/notification-channels.ts index 58b89c85a..51270df9e 100644 --- a/api/notification-channels.ts +++ b/api/notification-channels.ts @@ -110,7 +110,7 @@ export default async function handler(req: Request): Promise { return json(data, 200, corsHeaders); } catch (err) { console.error('[notification-channels] GET error:', err); - await captureEdgeException(err, { handler: 'notification-channels', method: 'GET' }); + void captureEdgeException(err, { handler: 'notification-channels', method: 'GET' }); return json({ error: 'Failed to fetch' }, 500, corsHeaders); } } @@ -187,7 +187,7 @@ export default async function handler(req: Request): Promise { return json({ error: 'Unknown action' }, 400, corsHeaders); } catch (err) { console.error('[notification-channels] POST error:', err); - await captureEdgeException(err, { handler: 'notification-channels', method: 'POST' }); + void captureEdgeException(err, { handler: 'notification-channels', method: 'POST' }); return json({ error: 'Operation failed' }, 500, corsHeaders); } } diff --git a/src/main.ts b/src/main.ts index 6658ba723..95a36376d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -16,6 +16,10 @@ Sentry.init({ : location.hostname.includes('vercel.app') ? 'preview' : 'development', enabled: Boolean(sentryDsn) && !location.hostname.startsWith('localhost') && !('__TAURI_INTERNALS__' in window), + allowUrls: [ + /https?:\/\/(www\.|tech\.|finance\.|commodity\.|happy\.)?worldmonitor\.app/, + /https?:\/\/.*\.vercel\.app/, + ], sendDefaultPii: true, tracesSampleRate: 0.1, ignoreErrors: [