diff --git a/.env.production b/.env.production index cb4433f4e..76085ce15 100644 --- a/.env.production +++ b/.env.production @@ -1,4 +1,2 @@ -# Sentry DSN — get from sentry.io → Project Settings → Client Keys -# VITE_SENTRY_DSN=https://xxx@oXXX.ingest.sentry.io/YYYY -VITE_SENTRY_DSN= +VITE_SENTRY_DSN=https://264a5e95c5d31fe080a2e92fb008294d@o4511430568378368.ingest.us.sentry.io/4511430571982849 VITE_APP_VERSION=lotus diff --git a/src/app/pages/Router.tsx b/src/app/pages/Router.tsx index 562ecd0c8..23c062424 100644 --- a/src/app/pages/Router.tsx +++ b/src/app/pages/Router.tsx @@ -49,7 +49,7 @@ import { RouteSpaceProvider, Space, SpaceRouteRoomProvider, SpaceSearch } from ' import { setAfterLoginRedirectPath } from './afterLoginRedirectPath'; -import { Room } from '../features/room'; +const Room = React.lazy(() => import('../features/room').then(m => ({ default: m.Room }))); import { WelcomePage } from './client/WelcomePage'; import { SidebarNav } from './client/SidebarNav'; @@ -186,7 +186,9 @@ export const createRouter = (clientConfig: ClientConfig, screenSize: ScreenSize) path={_ROOM_PATH} element={ - + + + } /> @@ -211,7 +213,9 @@ export const createRouter = (clientConfig: ClientConfig, screenSize: ScreenSize) path={_ROOM_PATH} element={ - + + + } /> @@ -251,7 +255,9 @@ export const createRouter = (clientConfig: ClientConfig, screenSize: ScreenSize) path={_ROOM_PATH} element={ - + + + } /> diff --git a/src/index.tsx b/src/index.tsx index b7cb403d9..31f392a1d 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -7,20 +7,26 @@ import '@fontsource/inter/variable.css'; import 'folds/dist/style.css'; import { configClass, varsClass } from 'folds'; -if (import.meta.env.VITE_SENTRY_DSN) { +const sentryDsn = import.meta.env.VITE_SENTRY_DSN; +if (sentryDsn) { Sentry.init({ - dsn: import.meta.env.VITE_SENTRY_DSN, + dsn: sentryDsn, environment: import.meta.env.MODE, release: import.meta.env.VITE_APP_VERSION, + integrations: [ + Sentry.browserTracingIntegration(), + ], + // Only trace requests to our own Matrix homeserver + tracePropagationTargets: ['localhost', /^https:\/\/matrix\.lotusguild\.org/], + // 5% of transactions — enough signal without burning quota tracesSampleRate: 0.05, - // Don't send PII — strip user IPs and don't attach user info automatically + // Don't send PII (IPs, usernames) — this is a private chat app sendDefaultPii: false, + // Forward Sentry logs to the dashboard + enableLogs: true, beforeSend(event) { - // Scrub any accessToken that may have leaked into breadcrumbs/data - const str = JSON.stringify(event); - if (str.includes('access_token') || str.includes('accessToken')) { - return null; - } + // Drop any event that may have leaked an access token into breadcrumbs/data + if (JSON.stringify(event).includes('access_token')) return null; return event; }, }); diff --git a/vite.config.js b/vite.config.js index 58ca5e4f4..a11ff3e12 100644 --- a/vite.config.js +++ b/vite.config.js @@ -137,6 +137,11 @@ export default defineConfig({ if (id.includes('node_modules/@tanstack')) return 'react-query'; if (id.includes('node_modules/linkify')) return 'linkify'; if (id.includes('node_modules/dompurify')) return 'dompurify'; + if (id.includes('node_modules/@sentry')) return 'sentry'; + if (id.includes('node_modules/i18next') || id.includes('node_modules/react-i18next')) return 'i18n'; + if (id.includes('node_modules/jotai')) return 'jotai'; + if (id.includes('node_modules/immer')) return 'immer'; + if (id.includes('node_modules/folds')) return 'folds'; }, }, },