All files / src/lib report-ssr-fallback.ts

100% Statements 1/1
100% Branches 0/0
100% Functions 1/1
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23                                  2x          
import * as Sentry from "@sentry/cloudflare";
 
/**
 * Report a cold-path SSR data-fetch failure to Sentry.
 *
 * Marketplace pages catch their API-fetch errors and render a graceful fallback
 * (error box, empty state, etc.) instead of re-throwing — so the Sentry
 * `wrapRequestHandler` in middleware.ts never records them. Call this from those
 * catch blocks so the failure is still reported, tagged with the surface that
 * failed. The `ssr_fallback` tag is the single key the Sentry alert rule filters
 * on, so the alert matches exactly these failures and nothing else.
 *
 * Page frontmatter renders inside the per-request `wrapRequestHandler` scope, so
 * captureException attaches to the right request. No-ops when no DSN is
 * configured (local/dev).
 */
export function reportSsrFallback(surface: string, err: unknown): void {
	Sentry.captureException(err, {
		level: "error",
		tags: { ssr_fallback: surface },
	});
}