fix(site): only report Sentry errors from deployed function runtime (#1393)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Darius Cepulis
2026-04-21 16:47:44 -05:00
committed by GitHub
co-authored by Claude
parent 37da3bf817
commit 9ad66f9b27
+14 -2
View File
@@ -1,9 +1,21 @@
import process from 'node:process';
import * as Sentry from '@sentry/astro';
// Only the deployed Netlify Function runtime sets AWS_LAMBDA_FUNCTION_NAME;
// it's absent during `astro build`. Gating on it keeps errors from pre-render
// (e.g. a broken PR) out of Sentry — we only want live request failures.
const isLambdaRuntime = Boolean(process.env.AWS_LAMBDA_FUNCTION_NAME);
// Alert for production (videojs.org) and branch-deploy (next.videojs.org) only.
// Deploy-preview errors are the PR author's to triage before merge.
const context = import.meta.env.CONTEXT;
const isAlertingContext = context === 'production' || context === 'branch-deploy';
Sentry.init({
dsn: 'https://6bcdfa6b82da6dd4d7753618a9a69c7c@o43841.ingest.us.sentry.io/4510671167160320',
environment: import.meta.env.CONTEXT || 'development',
enabled: import.meta.env.PROD,
environment: context || 'development',
enabled: import.meta.env.PROD && isLambdaRuntime && isAlertingContext,
release: import.meta.env.COMMIT_REF || import.meta.env.DEPLOY_ID || undefined,
// Adds request headers and IP for users, for more info visit:
// https://docs.sentry.io/platforms/javascript/guides/astro/configuration/options/#sendDefaultPii