Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions app/global-error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use client"

import { useEffect } from "react"
import NextError from "next/error"
import * as Sentry from "@sentry/nextjs"

export default function GlobalError({
error,
}: {
error: Error & { digest?: string }
}) {
useEffect(() => {
Sentry.captureException(error)
}, [error])

return (
<html>
<body>
<NextError statusCode={0} />
</body>
</html>
)
}
11 changes: 11 additions & 0 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { ReactNode } from "react"
import type { Metadata } from "next"
import * as Sentry from "@sentry/nextjs"

import "@/styles/global.css"

Expand All @@ -11,3 +13,12 @@ type Props = {
export default function RootLayout({ children }: Props) {
return children
}

// Sentry trace data
export function generateMetadata(): Metadata {
return {
other: {
...Sentry.getTraceData(),
},
}
}
12 changes: 12 additions & 0 deletions instrumentation-client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as Sentry from "@sentry/nextjs"

const environment = process.env.NEXT_PUBLIC_CONTEXT || "development"

Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
tracesSampleRate: 1,
debug: environment === "development",
environment,
})

export const onRouterTransitionStart = Sentry.captureRouterTransitionStart
13 changes: 13 additions & 0 deletions instrumentation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as Sentry from "@sentry/nextjs"

export async function register() {
if (process.env.NEXT_RUNTIME === "nodejs") {
await import("./sentry.server.config")
}

if (process.env.NEXT_RUNTIME === "edge") {
await import("./sentry.edge.config")
}
}

export const onRequestError = Sentry.captureRequestError
22 changes: 22 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const withBundleAnalyzer = require("@next/bundle-analyzer")({

const createNextIntlPlugin = require("next-intl/plugin")

const { withSentryConfig } = require("@sentry/nextjs")

const withNextIntl = createNextIntlPlugin()

const LIMIT_CPUS = Number(process.env.LIMIT_CPUS ?? 2)
Expand All @@ -28,6 +30,11 @@ module.exports = (phase, { defaultConfig }) => {
let nextConfig = {
...defaultConfig,
reactStrictMode: true,
env: {
// Context is used to determine the environment for Sentry
// ref. https://docs.netlify.com/configure-builds/environment-variables/#build-metadata
NEXT_PUBLIC_CONTEXT: process.env.CONTEXT,
},
webpack: (config) => {
config.module.rules.push({
test: /\.ya?ml$/,
Expand Down Expand Up @@ -139,6 +146,12 @@ module.exports = (phase, { defaultConfig }) => {
"node_modules/@swc/core-linux-x64-gnu",
"node_modules/@swc/core-linux-x64-musl",
"node_modules/@esbuild/linux-x64",
"node_modules/@sentry/cli/**/*",
"node_modules/sharp/**/*",
"node_modules/three/**/*",
"node_modules/canvas/**/*",
"node_modules/@playwright/**/*",
"node_modules/chromium-bidi/**/*",
"src/data",
"public/**/*.jpg",
"public/**/*.png",
Expand All @@ -160,3 +173,12 @@ module.exports = (phase, { defaultConfig }) => {

return withBundleAnalyzer(withNextIntl(nextConfig))
}

module.exports = withSentryConfig(module.exports, {
org: "ethereumorg-ow",
project: "ethorg",
silent: true,
widenClientFileUpload: true,
disableLogger: true,
automaticVercelMonitors: true,
})
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"@radix-ui/react-tooltip": "^1.1.2",
"@radix-ui/react-visually-hidden": "^1.1.0",
"@rainbow-me/rainbowkit": "^2.2.3",
"@sentry/nextjs": "^10.5.0",
"@socialgouv/matomo-next": "^1.8.0",
"@tanstack/react-query": "^5.66.7",
"@tanstack/react-table": "^8.19.3",
Expand Down
Loading