Refactor Next.js configuration and remove Sentry integration
- Updated `serverExternalPackages` in the Next.js configuration to exclude `@sentry/node`, improving compatibility with React's RSC/client boundary. - Removed the `instrumentation.ts` file and refactored Sentry-related code to a no-op, ensuring it does not interfere with the Next.js build process. - Simplified the dashboard page by integrating `DashboardGuildGrid`, enhancing the user interface and reducing complexity in the component structure.
This commit is contained in:
@@ -1,43 +1,20 @@
|
||||
let initialized = false;
|
||||
|
||||
/**
|
||||
* WebUI error reporting stub.
|
||||
*
|
||||
* `@sentry/node` is intentionally not used in the Next.js app: importing it
|
||||
* (even lazily via `instrumentation.ts`) pulled OpenTelemetry into the build
|
||||
* graph and broke page-data collection with
|
||||
* `TypeError: createContext is not a function`. Bot-side Sentry remains in
|
||||
* `apps/bot`. Capture here stays a structured console fallback so call sites
|
||||
* can keep using one API.
|
||||
*/
|
||||
export async function initWebuiSentry(): Promise<void> {
|
||||
if (initialized) {
|
||||
return;
|
||||
}
|
||||
const dsn = process.env.SENTRY_DSN?.trim();
|
||||
if (!dsn) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Import only when a DSN is configured. Loading `@sentry/node` at module
|
||||
// scope patches Node builtins and can break Next.js page-data collection
|
||||
// (`createContext is not a function`) during `next build`.
|
||||
const Sentry = await import('@sentry/node');
|
||||
Sentry.init({
|
||||
dsn,
|
||||
environment: process.env.NODE_ENV ?? 'production',
|
||||
release: 'nexumi-webui@0.1.0',
|
||||
tracesSampleRate: process.env.NODE_ENV === 'production' ? 0.1 : 1.0,
|
||||
initialScope: {
|
||||
tags: { service: 'webui' }
|
||||
}
|
||||
});
|
||||
initialized = true;
|
||||
// no-op in WebUI
|
||||
}
|
||||
|
||||
export async function captureWebuiException(
|
||||
error: unknown,
|
||||
context?: Record<string, unknown>
|
||||
): Promise<void> {
|
||||
const dsn = process.env.SENTRY_DSN?.trim();
|
||||
if (!dsn) {
|
||||
return;
|
||||
}
|
||||
const Sentry = await import('@sentry/node');
|
||||
Sentry.withScope((scope) => {
|
||||
if (context) {
|
||||
scope.setExtras(context);
|
||||
}
|
||||
Sentry.captureException(error);
|
||||
});
|
||||
console.error('[webui]', error, context ?? {});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user