runtipi/sentry.client.config.ts
Nicolas Meienberger 84ea5dcb7f
Sync 3.5.2 in develop (#1589)
* chore: bump version to 3.5.2

* fix(container): use env variables instead of parsing before ready

* chore: run biome safe autofix

* fix(db): use env for username and db instead of hardcoded value
2024-08-10 15:14:08 +02:00

30 lines
861 B
TypeScript

import { cleanseErrorData, settingsSchema } from '@runtipi/shared';
import * as Sentry from '@sentry/nextjs';
const getClientConfig = () => {
if (typeof window === 'undefined') {
return {};
}
const inputElement = document.getElementById('client-settings') as HTMLInputElement | null;
if (!inputElement) {
return {};
}
const parsedSettings = settingsSchema.parse(JSON.parse(inputElement.value));
return parsedSettings;
};
const { allowErrorMonitoring } = getClientConfig();
if (allowErrorMonitoring && process.env.NODE_ENV === 'production' && process.env.LOCAL !== 'true') {
Sentry.init({
environment: process.env.NODE_ENV,
dsn: 'https://7a73d72f886948478b55621e7b92c3c7@o4504242900238336.ingest.sentry.io/4504826587971584',
beforeSend: cleanseErrorData,
integrations: [Sentry.extraErrorDataIntegration()],
});
}