Skip to content

Commit 3798eeb

Browse files
committed
feat: Added sentry
1 parent 1e733d4 commit 3798eeb

6 files changed

Lines changed: 87 additions & 1 deletion

File tree

web/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,6 @@ yarn-error.log*
3636
next-env.d.ts
3737
.idea
3838
.env.sentry-build.plugin
39+
40+
# Sentry Config File
41+
.env.sentry-build-plugin

web/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({ error }: { error: Error & { digest?: string } }) {
8+
useEffect(() => {
9+
Sentry.captureException(error);
10+
}, [error]);
11+
12+
return (
13+
<html>
14+
<body>
15+
{/* `NextError` is the default Next.js error page component. Its type
16+
definition requires a `statusCode` prop. However, since the App Router
17+
does not expose status codes for errors, we simply pass 0 to render a
18+
generic error message. */}
19+
<NextError statusCode={0} />
20+
</body>
21+
</html>
22+
);
23+
}

web/bun.lockb

88 KB
Binary file not shown.

web/next.config.mjs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,37 @@
1+
import {withSentryConfig} from "@sentry/nextjs";
12
/** @type {import('next').NextConfig} */
23
const nextConfig = {
34
output: "standalone",
45
};
56

6-
export default nextConfig;
7+
export default withSentryConfig(nextConfig, {
8+
// For all available options, see:
9+
// https://www.npmjs.com/package/@sentry/webpack-plugin#options
10+
11+
org: "private-dec",
12+
project: "codecanvas",
13+
14+
// Only print logs for uploading source maps in CI
15+
silent: !process.env.CI,
16+
17+
// For all available options, see:
18+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
19+
20+
// Upload a larger set of source maps for prettier stack traces (increases build time)
21+
widenClientFileUpload: true,
22+
23+
// Uncomment to route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
24+
// This can increase your server load as well as your hosting bill.
25+
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
26+
// side errors will fail.
27+
// tunnelRoute: "/monitoring",
28+
29+
// Automatically tree-shake Sentry logger statements to reduce bundle size
30+
disableLogger: true,
31+
32+
// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
33+
// See the following for more information:
34+
// https://docs.sentry.io/product/crons/
35+
// https://vercel.com/docs/cron-jobs
36+
automaticVercelMonitors: true,
37+
});

web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"@mantine/spotlight": "^7",
2424
"@mantine/tiptap": "^7",
2525
"@mantinex/dev-icons": "^1.0.2",
26+
"@sentry/nextjs": "^9",
2627
"@tabler/icons-react": "^3.16.0",
2728
"@tiptap/extension-code-block-lowlight": "^2.8.0",
2829
"@tiptap/extension-color": "^2.8.0",

web/sentry.client.config.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// This file configures the initialization of Sentry on the client.
2+
// The config you add here will be used whenever a users loads a page in their browser.
3+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
4+
5+
import * as Sentry from "@sentry/nextjs";
6+
7+
Sentry.init({
8+
dsn: "https://68b3b0610345b912b555e01f90dc4834@o4509031950778368.ingest.de.sentry.io/4509031955431504",
9+
10+
// Add optional integrations for additional features
11+
integrations: [
12+
Sentry.replayIntegration(),
13+
],
14+
15+
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
16+
tracesSampleRate: 1,
17+
18+
// Define how likely Replay events are sampled.
19+
// This sets the sample rate to be 10%. You may want this to be 100% while
20+
// in development and sample at a lower rate in production
21+
replaysSessionSampleRate: 0.1,
22+
23+
// Define how likely Replay events are sampled when an error occurs.
24+
replaysOnErrorSampleRate: 1.0,
25+
26+
// Setting this option to true will print useful information to the console while you're setting up Sentry.
27+
debug: false,
28+
});

0 commit comments

Comments
 (0)