teableio_teable/apps/nextjs-app/instrumentation.ts
Bieber 4f4c0f2824
[sync] Fix Sentry Release (T1750) (#1094) (#2471)
Synced from teableio/teable-ee@d43bb45

Co-authored-by: teable-bot <bot@teable.io>
2026-01-22 18:13:14 +08:00

39 lines
927 B
TypeScript

// This file is required by Next.js 15+ for Sentry integration
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
export async function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
await import('./sentry.server.config');
}
// Edge Runtime config - create sentry.edge.config.ts if using Middleware or Edge API Routes
// if (process.env.NEXT_RUNTIME === 'edge') {
// await import('./sentry.edge.config');
// }
}
export const onRequestError = async (
err: Error,
request: {
path: string;
method: string;
headers: Record<string, string>;
},
context: {
routerKind: string;
routePath: string;
routeType: string;
renderSource?: string;
revalidateReason?: string;
serverComponentType?: string;
}
) => {
const Sentry = await import('@sentry/nextjs');
Sentry.captureException(err, {
extra: {
request,
context,
},
});
};