Skip to content

Commit 20ed477

Browse files
committed
Sentry on upgrade #3475
1 parent afa7000 commit 20ed477

10 files changed

Lines changed: 1595 additions & 14 deletions

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,7 @@ tsconfig.tsbuildinfo
5858

5959
# gitignore pnpm-lock file in search as it should use package.lock
6060
#search/pnpm-lock.yaml
61-
search/AzuriteConfig
61+
search/AzuriteConfig
62+
63+
# Sentry Config File
64+
.env.sentry-build-plugin

web/app/global-error.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
'use client'
22

3-
/* import { captureException } from '@sentry/nextjs' */
3+
import { captureException } from '@sentry/nextjs'
44
import NextError from 'next/error'
5-
/* import { useEffect } from 'react' */
5+
import { useEffect } from 'react'
66

77
export default function GlobalError({
88
error,
99
}: {
1010
error: Error & { digest?: string }
1111
}) {
1212
console.warn('global error', error)
13-
/* useEffect(() => {
13+
useEffect(() => {
1414
captureException(error)
15-
}, [error]) */
15+
}, [error])
1616

1717
return (
1818
<html lang='en'>

web/app/instrumentation.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+
export async function register() {
3+
if (process.env.NEXT_RUNTIME === "nodejs") {
4+
await import("./sentry.server.config");
5+
}
6+
if (process.env.NEXT_RUNTIME === "edge") {
7+
await import("./sentry.edge.config");
8+
}
9+
}
10+
export const onRequestError = Sentry.captureRequestError;

web/app/sentry.client.config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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://8c4f308da7deed9aea83c76daa1938c0@o4509004923797504.ingest.de.sentry.io/4509010392121425',
9+
environment: process.env.NEXT_PUBLIC_SANITY_DATASET || 'global-development',
10+
11+
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
12+
tracesSampleRate: 1,
13+
14+
// Setting this option to true will print useful information to the console while you're setting up Sentry.
15+
debug: false,
16+
})

web/app/sentry.edge.config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on).
2+
// The config you add here will be used whenever one of the edge features is loaded.
3+
// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.
4+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
5+
6+
import * as Sentry from '@sentry/nextjs'
7+
8+
Sentry.init({
9+
dsn: 'https://8c4f308da7deed9aea83c76daa1938c0@o4509004923797504.ingest.de.sentry.io/4509010392121425',
10+
environment: process.env.NEXT_PUBLIC_SANITY_DATASET || 'global-development',
11+
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
12+
tracesSampleRate: 1,
13+
14+
// Setting this option to true will print useful information to the console while you're setting up Sentry.
15+
debug: false,
16+
})

web/app/sentry.sever.config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// This file configures the initialization of Sentry on the server.
2+
// The config you add here will be used whenever the server handles a request.
3+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
4+
5+
import * as Sentry from '@sentry/nextjs'
6+
7+
Sentry.init({
8+
dsn: 'https://8c4f308da7deed9aea83c76daa1938c0@o4509004923797504.ingest.de.sentry.io/4509010392121425',
9+
environment: process.env.NEXT_PUBLIC_SANITY_DATASET || 'global-development',
10+
11+
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
12+
tracesSampleRate: 1,
13+
14+
// Setting this option to true will print useful information to the console while you're setting up Sentry.
15+
debug: false,
16+
})

web/next.config.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import type { NextConfig } from 'next'
66
import createNextIntlPlugin from 'next-intl/plugin'
77
//import { getAllRedirects } from './sanity/interface/redirects'
88
import securityHeaders from './securityHeaders'
9+
import { withSentryConfig } from "@sentry/nextjs";
10+
911

1012
const withNextIntl = createNextIntlPlugin()
1113

@@ -39,7 +41,7 @@ export type ConfigRedirect = {
3941
}
4042
)
4143

42-
const nextConfig: NextConfig = {
44+
const nextConfig: NextConfig = withNextIntl({
4345
output: 'standalone',
4446
transpilePackages: ['friendly-challenge', '@energyvision/shared'],
4547
logging: {
@@ -112,6 +114,11 @@ const nextConfig: NextConfig = {
112114
],
113115
browserDebugInfoInTerminal: true,
114116
},
115-
}
117+
})
116118

117-
export default withNextIntl(nextConfig)
119+
export default withSentryConfig(nextConfig,{
120+
org: 'equinor',
121+
project: 'equinor-com',
122+
silent: !process.env.CI,
123+
disableLogger: true,
124+
})

web/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@
7474
"@tanstack/react-table": "^8.21.3",
7575
"uuid": "^9.0.0",
7676
"video.js": "^8.23.3",
77-
"xml2js": "^0.6.2"
77+
"xml2js": "^0.6.2",
78+
"@sentry/nextjs": "10.37.0"
7879
},
7980
"devDependencies": {
8081
"@algolia/client-search": "^4.16.0",

0 commit comments

Comments
 (0)