fix(observability): tag Sentry environment by host (dev → staging)
dev.sase.tr and sase.tr both run NODE_ENV=production (and ship the same production Vite build), so every Sentry event — api, worker, and browser — was tagged environment=production, making dev errors indistinguishable from prod. Resolve the environment from the canonical prod host instead: COOLIFY_FQDN / BETTER_AUTH_URL on the server (the same signal isCatalogBackfillEnabled uses), window.location.hostname on the web. So dev now tags as "staging" and stays filterable. Explicit SENTRY_ENVIRONMENT / VITE_SENTRY_ENVIRONMENT still win. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -21,8 +21,20 @@ export async function initSentry() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Both dev.sase.tr (staging) and sase.tr (prod) ship a production Vite build
|
||||
// (MODE === "production"), so MODE can't separate them. Derive from the host at
|
||||
// runtime instead, so dev errors stay filterable from prod in Sentry. An
|
||||
// explicit VITE_SENTRY_ENVIRONMENT still wins.
|
||||
const host = typeof window !== "undefined" ? window.location.hostname : "";
|
||||
const environment =
|
||||
import.meta.env.VITE_SENTRY_ENVIRONMENT ?? import.meta.env.MODE ?? "production";
|
||||
(import.meta.env.VITE_SENTRY_ENVIRONMENT as string | undefined) ??
|
||||
(host === "sase.tr" || host === "www.sase.tr"
|
||||
? "production"
|
||||
: host.endsWith("dev.sase.tr")
|
||||
? "staging"
|
||||
: import.meta.env.DEV
|
||||
? "development"
|
||||
: "staging");
|
||||
const release = import.meta.env.VITE_SENTRY_RELEASE;
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user