Add Sentry error monitoring (edge-compatible)#719
Add Sentry error monitoring (edge-compatible)#719RisingOrange wants to merge 16 commits intoPauseAI:mainfrom
Conversation
Use @sentry/svelte (client) and @sentry/deno (server) instead of @sentry/sveltekit, which doesn't support Netlify's Deno edge runtime.
👷 Deploy request for pauseai pending review.Visit the deploys page to approve it
|
Fixes knip lint failure (unused devDependency).
|
Thanks, this doesn't capture logs yet right? That would be a neat addition but not super important. Could use the standardized waitUntil API for dispatching them (edit: and also for the errors maybe) |
Add proper types to avoid unsafe-assignment and unsafe-member-access warnings that pushed the warning count over the CI limit.
|
Enabled
|
|
Are you sure that it isn't available under |
|
@Wituareard Oh, you're right. Updated to use that |
|
npx didn't properly download the binary, so I had to add the CLI as a dependency |
|
Source map upload works, but it produces 600 lines of log entries so that should probably be reduced |
|
Nvm it was the Vite plugin that produced the logs |
This reverts commit bafb3b9.
|
Nothing shows up in Sentry, can't take a closer look atm unfortunately |
import.meta.env doesn't expose PUBLIC_ prefixed vars in SvelteKit. Must use $env/dynamic/public instead.
|
Found the issue: I tested with a custom Sentry project locally and confirmed client-side errors now show up. I couldn't test server errors locally, because the dev server runs Node.js and |
Adds Sentry error monitoring so we get notified when users hit errors, with stack traces and context to debug them. Resolves #707, alternative to #714.
@sentry/sveltekitdoesn't support non-Node.js edge runtimes, which includes Netlify edge functions (Deno). This PR uses the individual Sentry SDKs instead.Approach
@sentry/svelteinsrc/hooks.client.ts@sentry/deno(dynamically imported) insrc/hooks.server.ts@sentry/vite-plugin+ postbuild script for edge function mapsDetails
PUBLIC_SENTRY_DSNenv var (not hardcoded)tracesSampleRate: 0) — not useful for a content siteenableLogs: truein@sentry/deno)@sentry/denois dynamically imported to avoid conflicts with the Netlify Deno window stub fix, and skipped during Node.js prerenderinithook (since 2.10) to ensure Sentry is ready before the first requesthandleErrorusesevent.platform.context.waitUntilto flush events without blocking the error responseRequired env vars (Netlify)
PUBLIC_SENTRY_DSN— Sentry DSN (already configured)SENTRY_AUTH_TOKEN— for source map uploadsSENTRY_ORG— Sentry org slugSENTRY_PROJECT— Sentry project slugRisk
@sentry/denois in beta and may not work on Netlify's non-standard Deno edge runtime. If it fails at runtime, server-side error capture degrades silently (client-side still works). The dynamic import is wrapped in try/catch so a server SDK failure won't break the site.