Files
SlpSoftware/src/main.tsx
T
2026-07-25 15:46:58 +02:00

42 lines
1.8 KiB
TypeScript

import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import { RouterProvider } from '@tanstack/react-router';
import * as Sentry from '@sentry/react';
import './fonts';
import './index.css';
import { router } from './router';
const sentryDsn = import.meta.env.VITE_SENTRY_DSN;
if (sentryDsn) {
Sentry.init({
dsn: sentryDsn,
// VITE_APP_ENV ('test' | 'production') distinguishes test vs. production builds — both use
// `vite build` without an explicit mode, so MODE alone would tag both as 'production'.
// Falls back to MODE for local development (`pnpm dev` -> 'development').
environment: import.meta.env.VITE_APP_ENV ?? import.meta.env.MODE,
release: __APP_VERSION__,
integrations: [Sentry.tanstackRouterBrowserTracingIntegration(router)],
// Low-traffic marketing site: capture all traces (lower this if traffic grows significantly).
tracesSampleRate: 1.0,
// Required for Sentry.logger.* calls (e.g. the temporary SentryTestButton) to actually be sent.
enableLogs: true,
// Ad-blockers/privacy extensions commonly block requests straight to *.ingest.sentry.io
// (ERR_BLOCKED_BY_CLIENT), because it looks like third-party tracking. Routing through our
// own domain via a "tunnel" avoids that: in built (test/production) environments this is
// handled by the reverse-proxy Pi (see nginx/reverse-proxy-nginx.conf.example); locally
// (`pnpm dev`) the equivalent proxy route is set up in vite.config.ts's `server.proxy`.
tunnel: '/sentry-tunnel',
});
}
const rootElement = document.getElementById('root');
if (!rootElement) {
throw new Error('Root element "#root" not found in index.html');
}
createRoot(rootElement).render(
<StrictMode>
<RouterProvider router={router} />
</StrictMode>,
);