This commit is contained in:
Kalle 2026-07-15 22:07:23 +03:00
parent 738788afbf
commit d552f5f4f2
2 changed files with 24 additions and 3 deletions

View File

@ -100,12 +100,22 @@ if ("serviceWorker" in navigator) {
});
}
/**
* Max time hydration waits for Sentry to initialize. If Sentry loads within
* this window its instrumentation is passed to the router (enabling the
* pageload trace); if not, hydration proceeds without it and errors are still
* captured once Sentry finishes loading.
*/
const SENTRY_INIT_TIMEOUT_MS = 1000;
const sentryPromise = initSentry();
// the server rendered with the page language's date-fns locale, so it must be
// cached before hydration to avoid a markup mismatch
Promise.all([
i18nLoader(),
loadDateFnsLocale(document.documentElement.lang as LanguageCode),
initSentry(),
Promise.race([sentryPromise, wait(SENTRY_INIT_TIMEOUT_MS)]),
])
.then(([, , sentry]) =>
hydrateRoot(
@ -116,8 +126,10 @@ Promise.all([
sentry ? [sentry.tracing.clientInstrumentation] : []
}
onError={(error) => {
if (sentry && error instanceof Error) {
sentry.captureException(error);
if (error instanceof Error) {
void sentryPromise.then((sentry) =>
sentry?.captureException(error),
);
}
}}
/>

View File

@ -48,6 +48,15 @@ export default defineConfig((config) => {
telemetry: false,
unstable_sentryVitePluginOptions: {
applicationKey: "sendou-ink",
// tree-shakes SDK features we don't use (Replay, debug logging)
// out of the dynamically imported client bundle
bundleSizeOptimizations: {
excludeDebugStatements: true,
excludeReplayCanvas: true,
excludeReplayShadowDom: true,
excludeReplayIframe: true,
excludeReplayWorker: true,
},
},
},
config,