Skip to content

Commit 7c90b1b

Browse files
Ajit Pratap Singhclaude
authored andcommitted
feat(website): add Sentry error boundary and withSentryConfig build wrapper
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 353cae1 commit 7c90b1b

2 files changed

Lines changed: 38 additions & 2 deletions

File tree

website/next.config.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
import type { NextConfig } from 'next';
22
import withBundleAnalyzer from '@next/bundle-analyzer';
3+
import { withSentryConfig } from '@sentry/nextjs';
34

45
const withAnalyzer = withBundleAnalyzer({
56
enabled: process.env.ANALYZE === 'true',
67
});
78

89
const nextConfig: NextConfig = {
10+
trailingSlash: true,
911
async headers() {
1012
return [
1113
{
1214
source: '/(.*)',
1315
headers: [
1416
{
1517
key: 'Content-Security-Policy',
16-
value: "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; font-src 'self'; img-src 'self' https://img.shields.io https://goreportcard.com https://*.shields.io data:; connect-src 'self'; worker-src 'self' blob:",
18+
value: "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; font-src 'self'; img-src 'self' https://img.shields.io https://goreportcard.com https://*.shields.io data:; connect-src 'self' https://*.sentry.io; worker-src 'self' blob:",
1719
},
1820
{
1921
key: 'X-Frame-Options',
@@ -48,4 +50,15 @@ const nextConfig: NextConfig = {
4850
},
4951
};
5052

51-
export default withAnalyzer(nextConfig);
53+
export default withSentryConfig(
54+
withAnalyzer(nextConfig),
55+
{
56+
org: process.env.SENTRY_ORG,
57+
project: process.env.SENTRY_PROJECT,
58+
authToken: process.env.SENTRY_AUTH_TOKEN,
59+
widenClientFileUpload: true,
60+
tunnelRoute: '/monitoring',
61+
silent: !process.env.CI,
62+
// Tree-shaking disabled — using Turbopack which doesn't support webpack tree-shaking
63+
}
64+
);

website/src/app/global-error.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"use client";
2+
3+
import * as Sentry from "@sentry/nextjs";
4+
import NextError from "next/error";
5+
import { useEffect } from "react";
6+
7+
export default function GlobalError({
8+
error,
9+
}: {
10+
error: Error & { digest?: string };
11+
}) {
12+
useEffect(() => {
13+
Sentry.captureException(error);
14+
}, [error]);
15+
16+
return (
17+
<html>
18+
<body>
19+
<NextError statusCode={0} />
20+
</body>
21+
</html>
22+
);
23+
}

0 commit comments

Comments
 (0)