/**
 * Next.js instrumentation 钩子 —— 按 runtime 加载对应 Sentry 服务端配置,
 * 并导出 onRequestError 捕获 SSR / RSC / Route Handler 里的服务端错误。
 */
import * as Sentry from '@sentry/nextjs';

export async function register() {
  if (process.env.NEXT_RUNTIME === 'nodejs') {
    await import('./sentry.server.config');
  }
  if (process.env.NEXT_RUNTIME === 'edge') {
    await import('./sentry.edge.config');
  }
}

export const onRequestError = Sentry.captureRequestError;
