freetravel/src/instrument.ts
2026-11-14 22:52:54 +05:00

28 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import * as Sentry from "@sentry/node";
/** Окружение: SENTRY_ENVIRONMENT, иначе по адресу стенда Пеппы (PEPPA_HOST), иначе dev. */
export function sentryEnvironment(env: NodeJS.ProcessEnv): string {
if (env.SENTRY_ENVIRONMENT) return env.SENTRY_ENVIRONMENT;
const host = env.PEPPA_HOST ?? "";
if (/-prod\./.test(host)) return "prod";
if (/-staging\./.test(host)) return "staging";
if (/-pr\d+\./.test(host)) return "preview";
return "dev";
}
// Без SENTRY_DSN SDK ничего не отправляет.
// В Sentry SDK v11 `sendDefaultPii` заменён на `dataCollection`: персональные данные не собираем.
Sentry.init({
dsn: process.env.SENTRY_DSN || undefined,
release: process.env.SENTRY_RELEASE || undefined,
environment: sentryEnvironment(process.env),
dataCollection: {
userInfo: false,
cookies: false,
httpHeaders: false,
httpBodies: [],
urlQueryParams: false,
genAI: { inputs: false, outputs: false },
},
});