export async function register() {
if (process.env.NODE_ENV !== 'production' && process.env.NEXT_RUNTIME === 'nodejs') {
await import('./libs/debug-file-logger');
}
const isDev = process.env.NODE_ENV !== 'production';
if (
process.env.NEXT_RUNTIME === 'nodejs' &&
process.env.DATABASE_URL &&
!process.env.VERCEL_ENV &&
(!isDev || process.env.ENABLE_BOT_IN_DEV === '1')
) {
const { GatewayService } = await import('./server/services/gateway');
const service = new GatewayService();
service.ensureRunning().catch((err) => {
console.error('[Instrumentation] Failed to auto-start GatewayManager:', err);
});
}
if (process.env.NODE_ENV !== 'production' && !process.env.ENABLE_TELEMETRY_IN_DEV) {
return;
}
const shouldEnable = process.env.ENABLE_TELEMETRY && process.env.NEXT_RUNTIME === 'nodejs';
if (!shouldEnable) {
return;
}
await import('./instrumentation.node');
}