Skip to content

Commit 222968e

Browse files
committed
feat: implement Sentry
1 parent d34fb18 commit 222968e

File tree

11 files changed

+685
-63
lines changed

11 files changed

+685
-63
lines changed

.cursor/mcp.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"mcpServers": {
3+
"Sentry": {
4+
"url": "https://mcp.sentry.dev/mcp/avara-ex/aave-v3"
5+
}
6+
}
7+
}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,6 @@ package-lock.json
4848
.idea
4949
.vscode
5050
.env.development
51+
52+
# Sentry Config File
53+
.env.sentry-build-plugin

next.config.js

Lines changed: 83 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const { withSentryConfig } = require('@sentry/nextjs');
2+
13
// eslint-disable-next-line
24
const withBundleAnalyzer = require('@next/bundle-analyzer')({
35
enabled: process.env.ANALYZE === 'true',
@@ -8,53 +10,86 @@ if (process.env.NEXT_PUBLIC_ENABLE_GOVERNANCE === 'true') pageExtensions.push('g
810
if (process.env.NEXT_PUBLIC_ENABLE_STAKING === 'true') pageExtensions.push('staking.tsx');
911

1012
/** @type {import('next').NextConfig} */
11-
module.exports = withBundleAnalyzer({
12-
webpack(config) {
13-
config.module.rules.push({
14-
test: /\.svg$/i,
15-
issuer: /\.[jt]sx?$/,
16-
use: [
17-
{
18-
loader: '@svgr/webpack',
19-
options: {
20-
svgoConfig: {
21-
plugins: ['prefixIds'],
13+
module.exports = withSentryConfig(
14+
withBundleAnalyzer({
15+
webpack(config) {
16+
config.module.rules.push({
17+
test: /\.svg$/i,
18+
issuer: /\.[jt]sx?$/,
19+
use: [
20+
{
21+
loader: '@svgr/webpack',
22+
options: {
23+
svgoConfig: {
24+
plugins: ['prefixIds'],
25+
},
2226
},
2327
},
24-
},
25-
],
26-
});
27-
config.experiments = {
28-
topLevelAwait: true,
29-
layers: true, // added for next api routes rpc proxy
30-
};
31-
config.resolve.fallback = { fs: false, net: false, tls: false };
32-
return config;
33-
},
34-
reactStrictMode: true,
35-
// assetPrefix: "./",
36-
trailingSlash: true,
37-
pageExtensions,
38-
// NOTE: Needed for SAFE testing locally
39-
// async headers() {
40-
// return [
41-
// {
42-
// source: '/manifest.json',
43-
// headers: [
44-
// {
45-
// key: 'Access-Control-Allow-Origin',
46-
// value: '*',
47-
// },
48-
// {
49-
// key: 'Access-Control-Allow-Methods',
50-
// value: 'GET',
51-
// },
52-
// {
53-
// key: 'Access-Control-Allow-Headers',
54-
// value: 'X-Requested-With, content-type, Authorization',
55-
// },
56-
// ],
57-
// },
58-
// ];
59-
// },
60-
});
28+
],
29+
});
30+
config.experiments = {
31+
topLevelAwait: true,
32+
layers: true, // added for next api routes rpc proxy
33+
};
34+
config.resolve.fallback = { fs: false, net: false, tls: false };
35+
return config;
36+
},
37+
reactStrictMode: true,
38+
// assetPrefix: "./",
39+
trailingSlash: true,
40+
pageExtensions,
41+
// NOTE: Needed for SAFE testing locally
42+
// async headers() {
43+
// return [
44+
// {
45+
// source: '/manifest.json',
46+
// headers: [
47+
// {
48+
// key: 'Access-Control-Allow-Origin',
49+
// value: '*',
50+
// },
51+
// {
52+
// key: 'Access-Control-Allow-Methods',
53+
// value: 'GET',
54+
// },
55+
// {
56+
// key: 'Access-Control-Allow-Headers',
57+
// value: 'X-Requested-With, content-type, Authorization',
58+
// },
59+
// ],
60+
// },
61+
// ];
62+
// },
63+
}),
64+
{
65+
// For all available options, see:
66+
// https://www.npmjs.com/package/@sentry/webpack-plugin#options
67+
68+
org: 'avara-ex',
69+
project: 'aave-v3',
70+
71+
// Only print logs for uploading source maps in CI
72+
silent: !process.env.CI,
73+
74+
// For all available options, see:
75+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
76+
77+
// Upload a larger set of source maps for prettier stack traces (increases build time)
78+
widenClientFileUpload: true,
79+
80+
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
81+
// This can increase your server load as well as your hosting bill.
82+
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
83+
// side errors will fail.
84+
tunnelRoute: '/monitoring',
85+
86+
// Automatically tree-shake Sentry logger statements to reduce bundle size
87+
disableLogger: true,
88+
89+
// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
90+
// See the following for more information:
91+
// https://docs.sentry.io/product/crons/
92+
// https://vercel.com/docs/cron-jobs
93+
automaticVercelMonitors: true,
94+
}
95+
);

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"@paraswap/sdk": "6.10.0",
5656
"@safe-global/safe-apps-provider": "^0.18.4",
5757
"@safe-global/safe-apps-sdk": "^9.1.0",
58+
"@sentry/nextjs": "7.120.4",
5859
"@tanstack/react-query": "^5.62.8",
5960
"@visx/annotation": "^3.3.0",
6061
"@visx/axis": "^2.14.0",
@@ -159,4 +160,4 @@
159160
"budgetPercentIncreaseRed": 20,
160161
"showDetails": true
161162
}
162-
}
163+
}

pages/_error.page.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as Sentry from '@sentry/nextjs';
12
import type { NextPageContext } from 'next';
23
import Error from 'next/error';
34

@@ -9,8 +10,11 @@ function ErrorPage({ statusCode }: ErrorPageProps) {
910
return <Error statusCode={statusCode} />;
1011
}
1112

12-
ErrorPage.getInitialProps = (ctx: NextPageContext) => {
13+
ErrorPage.getInitialProps = async (ctx: NextPageContext) => {
1314
const { res, err } = ctx;
15+
16+
await Sentry.captureUnderscoreErrorException(ctx);
17+
1418
// Inspect the status code and show the given template based off of it
1519
// Default to 404 page
1620
const statusCode = res ? res.statusCode : err ? err.statusCode : 404;

pages/api/sentry-example-api.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { NextApiRequest, NextApiResponse } from 'next';
2+
3+
// Custom error class for Sentry testing
4+
class SentryExampleAPIError extends Error {
5+
constructor(message: string | undefined) {
6+
super(message);
7+
this.name = 'SentryExampleAPIError';
8+
}
9+
}
10+
// A faulty API route to test Sentry's error monitoring
11+
export default function handler(_req: NextApiRequest, res: NextApiResponse) {
12+
throw new SentryExampleAPIError(
13+
'This error is raised on the backend called by the example page.'
14+
);
15+
res.status(200).json({ name: 'John Doe' });
16+
}

0 commit comments

Comments
 (0)