Skip to content

Commit c781f7a

Browse files
committed
chore: enable bundle analyzer and update Sentry configuration
1 parent 69f34df commit c781f7a

File tree

5 files changed

+23
-20
lines changed

5 files changed

+23
-20
lines changed

.env.example

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,7 @@ LIMIT_CPUS=
3737

3838
# Sentry auth token required for error tracking
3939
SENTRY_AUTH_TOKEN=
40-
NEXT_PUBLIC_SENTRY_DSN=
40+
NEXT_PUBLIC_SENTRY_DSN=
41+
42+
# Enables the bundle analyzer
43+
ANALYZE=false

next.config.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* eslint-disable @typescript-eslint/no-var-requires */
22
const { PHASE_DEVELOPMENT_SERVER } = require("next/constants")
33
const { withSentryConfig } = require("@sentry/nextjs")
4-
const { DefinePlugin } = require("webpack")
4+
const webpack = require("webpack")
55

66
const withBundleAnalyzer = require("@next/bundle-analyzer")({
7-
enabled: true,
7+
enabled: process.env.ANALYZE === "true",
88
})
99

1010
const { i18n } = require("./next-i18next.config")
@@ -38,15 +38,18 @@ module.exports = (phase, { defaultConfig }) => {
3838
use: "@svgr/webpack",
3939
})
4040

41-
config.plugins.push(
42-
new DefinePlugin({
43-
__SENTRY_DEBUG__: false,
44-
__SENTRY_TRACING__: false,
45-
})
46-
)
47-
4841
return config
4942
},
43+
plugins: [
44+
// Tree shake Sentry debug code
45+
// ref. https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/tree-shaking/#tree-shaking-with-nextjs
46+
new webpack.DefinePlugin({
47+
__SENTRY_DEBUG__: false,
48+
__RRWEB_EXCLUDE_IFRAME__: true,
49+
__RRWEB_EXCLUDE_SHADOW_DOM__: true,
50+
__SENTRY_EXCLUDE_REPLAY_WORKER__: true,
51+
}),
52+
],
5053
i18n,
5154
trailingSlash: true,
5255
images: {
@@ -82,10 +85,13 @@ module.exports = (phase, { defaultConfig }) => {
8285

8386
return withBundleAnalyzer(
8487
withSentryConfig(nextConfig, {
88+
// TODO: temp config, update this to the correct org & project
8589
org: "ethereumorg-ow",
8690
project: "javascript-nextjs",
8791
authToken: process.env.SENTRY_AUTH_TOKEN,
88-
silent: false,
92+
silent: true,
93+
disableLogger: true,
94+
release: `${process.env.BUILD_ID}_${process.env.REVIEW_ID}`,
8995
})
9096
)
9197
}

sentry.client.config.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@ import * as Sentry from "@sentry/nextjs"
22

33
Sentry.init({
44
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
5-
enabled: process.env.NODE_ENV === "production",
6-
// Replay may only be enabled for the client-side
7-
// integrations: [Sentry.replayIntegration()],
5+
enabled: process.env.CONTEXT === "production",
86
tracesSampleRate: 1.0,
9-
// Capture Replay for 10% of all sessions,
10-
// plus for 100% of sessions with an error
11-
replaysSessionSampleRate: 0.1,
12-
replaysOnErrorSampleRate: 1.0,
137
})

sentry.edge.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import * as Sentry from "@sentry/nextjs"
22

33
Sentry.init({
44
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
5-
enabled: process.env.NODE_ENV === "production",
5+
enabled: process.env.CONTEXT === "production",
66
tracesSampleRate: 1.0,
77
})

sentry.server.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import * as Sentry from "@sentry/nextjs"
22

33
Sentry.init({
44
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
5-
enabled: process.env.NODE_ENV === "production",
5+
enabled: process.env.CONTEXT === "production",
66
tracesSampleRate: 1.0,
77
})

0 commit comments

Comments
 (0)