perf: split chunks and lazy-load Room to shrink initial bundle
manualChunks: add sentry, folds, i18n, jotai, immer Router: lazy-load Room component (used in home/direct/space routes) Sentry: wire in real DSN with browserTracingIntegration, 5% trace rate, tracePropagationTargets scoped to matrix.lotusguild.org, sendDefaultPii=false Main bundle: 2481 kB -> 1857 kB gzip 623 kB -> 450 kB (-28% initial load) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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={
|
||||
<HomeRouteRoomProvider>
|
||||
<Room />
|
||||
<React.Suspense fallback={null}>
|
||||
<Room />
|
||||
</React.Suspense>
|
||||
</HomeRouteRoomProvider>
|
||||
}
|
||||
/>
|
||||
@@ -211,7 +213,9 @@ export const createRouter = (clientConfig: ClientConfig, screenSize: ScreenSize)
|
||||
path={_ROOM_PATH}
|
||||
element={
|
||||
<DirectRouteRoomProvider>
|
||||
<Room />
|
||||
<React.Suspense fallback={null}>
|
||||
<Room />
|
||||
</React.Suspense>
|
||||
</DirectRouteRoomProvider>
|
||||
}
|
||||
/>
|
||||
@@ -251,7 +255,9 @@ export const createRouter = (clientConfig: ClientConfig, screenSize: ScreenSize)
|
||||
path={_ROOM_PATH}
|
||||
element={
|
||||
<SpaceRouteRoomProvider>
|
||||
<Room />
|
||||
<React.Suspense fallback={null}>
|
||||
<Room />
|
||||
</React.Suspense>
|
||||
</SpaceRouteRoomProvider>
|
||||
}
|
||||
/>
|
||||
|
||||
+14
-8
@@ -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;
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user