Skip to content

Commit 111c8be

Browse files
committed
feat: add sentry integration
1 parent 6cc7941 commit 111c8be

File tree

8 files changed

+12397
-9822
lines changed

8 files changed

+12397
-9822
lines changed

instrumentation.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as Sentry from '@sentry/nextjs';
2+
3+
export async function register() {
4+
if (process.env.NEXT_RUNTIME === 'nodejs') {
5+
await import('./sentry.server.config');
6+
}
7+
8+
if (process.env.NEXT_RUNTIME === 'edge') {
9+
await import('./sentry.edge.config');
10+
}
11+
}
12+
13+
export const onRequestError = Sentry.captureRequestError;

next.config.js

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ const withBundleAnalyzer = require("@next/bundle-analyzer")({
55
/**
66
* @type {import('next').NextConfig}
77
*/
8-
const config = {
8+
let config = {
99
productionBrowserSourceMaps: true,
1010
env: {
1111
// make the backend URL available to the frontend
1212
NEXT_PUBLIC_BACKEND_URL: process.env.BACKEND_URL,
13-
NEXT_PUBLIC_ACCOUNTS_URL: "https://accounts.flanksource.com"
13+
NEXT_PUBLIC_ACCOUNTS_URL: "https://accounts.flanksource.com",
14+
NEXT_PUBLIC_SENTRY_HOST: "https://1db3b3bbf111cafee19c4e7827a4b601@o4508810638589952.ingest.de.sentry.io",
15+
NEXT_PUBLIC_SENTRY_PROJECT_ID: "4508810640162896",
16+
NEXT_PUBLIC_SENTRY_DSN: process.env.SENTRY_DSN || "https://1db3b3bbf111cafee19c4e7827a4b601@o4508810638589952.ingest.de.sentry.io/4508810640162896",
1417
},
1518
redirects: async () => {
1619
if (process.env.NEXT_PUBLIC_APP_DEPLOYMENT === "CANARY_CHECKER") {
@@ -83,8 +86,8 @@ const config = {
8386
// https://github.com/vercel/next.js/tree/canary/examples/with-docker#in-existing-projects
8487
...(process.env.NEXT_STANDALONE_DEPLOYMENT === "true"
8588
? {
86-
output: "standalone"
87-
}
89+
output: "standalone"
90+
}
8891
: {}),
8992
experimental: {
9093
// increase the default timeout for the proxy from 30s to 10m to allow for
@@ -96,4 +99,50 @@ const config = {
9699
transpilePackages: ["monaco-editor"]
97100
};
98101

99-
module.exports = withBundleAnalyzer(config);
102+
config = withBundleAnalyzer(config);
103+
104+
105+
106+
// Injected content via Sentry wizard below
107+
108+
const { withSentryConfig } = require("@sentry/nextjs");
109+
110+
module.exports = withSentryConfig(
111+
config,
112+
{
113+
// For all available options, see:
114+
// https://github.com/getsentry/sentry-webpack-plugin#options
115+
116+
org: "flanksource",
117+
project: "flanksource-ui",
118+
119+
// Only print logs for uploading source maps in CI
120+
silent: !process.env.CI,
121+
122+
// For all available options, see:
123+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
124+
125+
// Upload a larger set of source maps for prettier stack traces (increases build time)
126+
widenClientFileUpload: true,
127+
128+
// Automatically annotate React components to show their full name in breadcrumbs and session replay
129+
reactComponentAnnotation: {
130+
enabled: true,
131+
},
132+
133+
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
134+
// This can increase your server load as well as your hosting bill.
135+
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
136+
// side errors will fail.
137+
tunnelRoute: "/monitoring",
138+
139+
// Hides source maps from generated client bundles
140+
hideSourceMaps: false,
141+
142+
// Automatically tree-shake Sentry logger statements to reduce bundle size
143+
disableLogger: true,
144+
145+
automaticVercelMonitors: false,
146+
}
147+
);
148+

0 commit comments

Comments
 (0)