Skip to content

Commit aab5d32

Browse files
authored
feat: sentry integration (#1020) (#1029)
* feat: add Sentry error tracking integration Configure via NEXT_PUBLIC_SENTRY_DSN environment variable. * chore: clean up Sentry wizard output - Remove unneeded server/edge configs (static export) - Remove App Router files (using Pages Router) - Remove example pages - Use env var for DSN instead of hardcoding - Add typed _error.tsx for Pages Router error capture * chore: suppress Sentry global-error.js warning Not needed for Pages Router projects. * feat: add environment tag to Sentry errors Uses NEXT_PUBLIC_SITE_CONFIG to segment errors by environment. * feat: enable Sentry for dev and prod environments Add DSN to site-config env files.
1 parent 9564475 commit aab5d32

File tree

9 files changed

+1980
-317
lines changed

9 files changed

+1980
-317
lines changed

.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
NEXT_PUBLIC_SITEMAP_DOMAIN='https://brc-analytics.dev.clevercanary.com'
22
NEXT_PUBLIC_BASE_PATH=''
33
SITEMAP_EXCLUDE='/export*,/login'
4+
# Sentry configuration (optional - leave empty to disable)
5+
NEXT_PUBLIC_SENTRY_DSN=''
6+
# Suppress warning about App Router global-error.js (we use Pages Router)
7+
SENTRY_SUPPRESS_GLOBAL_ERROR_HANDLER_FILE_WARNING=1

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ backend/**/.env
4242
venv
4343
__pycache__
4444

45+
playwright-report/
4546

4647
## public api
4748
/public/api
49+
50+
# Sentry Config File
51+
.env.sentry-build-plugin

instrumentation-client.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import * as Sentry from "@sentry/nextjs";
2+
3+
Sentry.init({
4+
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
5+
enabled: !!process.env.NEXT_PUBLIC_SENTRY_DSN,
6+
environment: process.env.NEXT_PUBLIC_SITE_CONFIG || "unknown",
7+
tracesSampleRate: 1,
8+
});
9+
10+
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;

next.config.mjs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { withSentryConfig } from "@sentry/nextjs";
12
import nextMDX from "@next/mdx";
23
import withPlugins from "next-compose-plugins";
34
import path from "path";
@@ -13,7 +14,8 @@ const ESM_PACKAGES = [
1314
const withMDX = nextMDX({
1415
extension: /\.mdx?$/,
1516
});
16-
export default withPlugins(
17+
18+
const nextConfig = withPlugins(
1719
[[withMDX, { pageExtensions: ["md", "mdx", "ts", "tsx"] }]],
1820
{
1921
basePath: "",
@@ -86,3 +88,15 @@ export default withPlugins(
8688
},
8789
}
8890
);
91+
92+
export default withSentryConfig(nextConfig, {
93+
disableLogger: true,
94+
org: "galaxy",
95+
project: "brc-analytics-dev",
96+
sentryUrl: "https://sentry.galaxyproject.org/",
97+
silent: true,
98+
sourcemaps: {
99+
disable: true,
100+
},
101+
suppressGlobalErrorHandlerFileWarning: true,
102+
});

0 commit comments

Comments
 (0)