From 9ad66f9b27886582b2f785cab7fd48907b50802b Mon Sep 17 00:00:00 2001 From: Darius Cepulis Date: Tue, 21 Apr 2026 16:47:44 -0500 Subject: [PATCH] fix(site): only report Sentry errors from deployed function runtime (#1393) Co-authored-by: Claude --- site/sentry.server.config.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/site/sentry.server.config.ts b/site/sentry.server.config.ts index 8fdc2386..92f477b7 100644 --- a/site/sentry.server.config.ts +++ b/site/sentry.server.config.ts @@ -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