Skip to content

Commit 2a67725

Browse files
Merge remote-tracking branch 'upstream/dev' into feat/learn-page-shadcn
2 parents 750849e + 62b5b3a commit 2a67725

33 files changed

+1930
-495
lines changed

.env.example

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,11 @@ BUILD_LOCALES=
3333

3434
# If resource constraints are being hit during builds, change LIMIT_CPUS to a
3535
# fixed number of CPUs (e.g. 2) to limit the demand during build time
36-
LIMIT_CPUS=
36+
LIMIT_CPUS=
37+
38+
# Sentry auth token required for error tracking
39+
SENTRY_AUTH_TOKEN=
40+
NEXT_PUBLIC_SENTRY_DSN=
41+
42+
# Enables the bundle analyzer
43+
ANALYZE=false

instrumentation.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import * as Sentry from "@sentry/nextjs"
2+
3+
export async function register() {
4+
const dsn = process.env.NEXT_PUBLIC_SENTRY_DSN
5+
6+
if (!dsn) {
7+
console.warn("Sentry DSN not found, skipping")
8+
return
9+
}
10+
11+
const commonSentryOptions = {
12+
dsn,
13+
enabled: process.env.NODE_ENV === "production",
14+
tracesSampleRate: 1.0,
15+
}
16+
17+
if (process.env.NEXT_RUNTIME === "nodejs") {
18+
Sentry.init({
19+
...commonSentryOptions,
20+
})
21+
}
22+
23+
if (process.env.NEXT_RUNTIME === "edge") {
24+
Sentry.init({
25+
...commonSentryOptions,
26+
})
27+
}
28+
}

next.config.js

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
/* eslint-disable @typescript-eslint/no-var-requires */
22
const { PHASE_DEVELOPMENT_SERVER } = require("next/constants")
3+
const { withSentryConfig } = require("@sentry/nextjs")
4+
5+
const withBundleAnalyzer = require("@next/bundle-analyzer")({
6+
enabled: process.env.ANALYZE === "true",
7+
})
38

49
const { i18n } = require("./next-i18next.config")
510

@@ -22,7 +27,7 @@ module.exports = (phase, { defaultConfig }) => {
2227
let nextConfig = {
2328
...defaultConfig,
2429
reactStrictMode: true,
25-
webpack: (config) => {
30+
webpack: (config, { webpack }) => {
2631
config.module.rules.push({
2732
test: /\.ya?ml$/,
2833
use: "yaml-loader",
@@ -53,13 +58,30 @@ module.exports = (phase, { defaultConfig }) => {
5358
// Modify the file loader rule to ignore *.svg, since we have it handled now.
5459
fileLoaderRule.exclude = /\.svg$/i
5560

61+
// Tree shake Sentry debug code
62+
// ref. https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/tree-shaking/#tree-shaking-with-nextjs
63+
config.plugins.push(
64+
new webpack.DefinePlugin({
65+
__SENTRY_DEBUG__: false,
66+
__RRWEB_EXCLUDE_IFRAME__: true,
67+
__RRWEB_EXCLUDE_SHADOW_DOM__: true,
68+
__SENTRY_EXCLUDE_REPLAY_WORKER__: true,
69+
})
70+
)
71+
5672
return config
5773
},
5874
i18n,
5975
trailingSlash: true,
6076
images: {
6177
deviceSizes: [640, 750, 828, 1080, 1200, 1504, 1920],
6278
},
79+
env: {
80+
NEXT_PUBLIC_CONTEXT: process.env.CONTEXT,
81+
},
82+
experimental: {
83+
instrumentationHook: true,
84+
},
6385
}
6486

6587
if (phase !== PHASE_DEVELOPMENT_SERVER) {
@@ -88,5 +110,15 @@ module.exports = (phase, { defaultConfig }) => {
88110
}
89111
}
90112

91-
return nextConfig
113+
return withBundleAnalyzer(
114+
withSentryConfig(nextConfig, {
115+
// TODO: temp config, update this to the correct org & project
116+
org: "ethereumorg-ow",
117+
project: "javascript-nextjs",
118+
authToken: process.env.SENTRY_AUTH_TOKEN,
119+
release: `${process.env.BUILD_ID}_${process.env.REVIEW_ID}`,
120+
disableLogger: true,
121+
silent: true,
122+
})
123+
)
92124
}

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ethereum-org-website",
3-
"version": "8.8.0",
3+
"version": "8.9.0",
44
"license": "MIT",
55
"private": true,
66
"scripts": {
@@ -34,13 +34,16 @@
3434
"@emotion/react": "^11.11.1",
3535
"@emotion/styled": "^11.11.0",
3636
"@hookform/resolvers": "^3.8.0",
37+
"@next/bundle-analyzer": "^14.2.5",
3738
"@radix-ui/react-accordion": "^1.2.0",
3839
"@radix-ui/react-checkbox": "^1.1.1",
40+
"@radix-ui/react-dialog": "^1.1.1",
3941
"@radix-ui/react-navigation-menu": "^1.2.0",
4042
"@radix-ui/react-popover": "^1.1.1",
4143
"@radix-ui/react-radio-group": "^1.2.0",
4244
"@radix-ui/react-slot": "^1.1.0",
4345
"@radix-ui/react-visually-hidden": "^1.1.0",
46+
"@sentry/nextjs": "^8.19.0",
4447
"@socialgouv/matomo-next": "^1.8.0",
4548
"chart.js": "^4.4.2",
4649
"chartjs-plugin-datalabels": "^2.2.0",
@@ -76,6 +79,7 @@
7679
"remark-gfm": "^3.0.1",
7780
"tailwind-merge": "^2.3.0",
7881
"tailwindcss-animate": "^1.0.7",
82+
"usehooks-ts": "^3.1.0",
7983
"yaml-loader": "^0.8.0"
8084
},
8185
"devDependencies": {
@@ -124,11 +128,10 @@
124128
"tsconfig-paths-webpack-plugin": "4.1.0",
125129
"typescript": "^5.5.2",
126130
"unified": "^10.0.0",
127-
"unist-util-visit": "^5.0.0",
128-
"usehooks-ts": "^3.1.0"
131+
"unist-util-visit": "^5.0.0"
129132
},
130133
"resolutions": {
131134
"jackspeak": "2.1.1",
132135
"sharp": "0.32.6"
133136
}
134-
}
137+
}

sentry.client.config.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+
const dsn = process.env.NEXT_PUBLIC_SENTRY_DSN
4+
5+
Sentry.init({
6+
dsn,
7+
enabled: process.env.NODE_ENV === "production",
8+
environment: process.env.NEXT_PUBLIC_CONTEXT,
9+
tracesSampleRate: 1.0,
10+
})

src/components/FeedbackWidget/useFeedbackWidget.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useRouter } from "next/router"
33

44
import { trackCustomEvent } from "@/lib/utils/matomo"
55

6-
import useDisclosure from "@/hooks/useDisclosure"
6+
import { useDisclosure } from "@/hooks/useDisclosure"
77
import { useSurvey } from "@/hooks/useSurvey"
88

99
export const useFeedbackWidget = () => {

src/components/Glossary/GlossaryTooltip/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useRouter } from "next/router"
33
import { Box, Text, VStack } from "@chakra-ui/react"
44

55
import Heading from "@/components/Heading"
6+
import InlineLink from "@/components/Link"
67
import Tooltip, { type TooltipProps } from "@/components/Tooltip"
78
import Translation from "@/components/Translation"
89

@@ -31,6 +32,9 @@ const GlossaryTooltip = ({
3132
<Translation
3233
id={termKey + "-term"}
3334
options={{ ns: "glossary-tooltip" }}
35+
// Override the default `a` tag transformation to avoid circular
36+
// dependency issues
37+
transform={{ a: InlineLink }}
3438
/>
3539
</Heading>
3640
{/**
@@ -43,6 +47,9 @@ const GlossaryTooltip = ({
4347
<Translation
4448
id={termKey + "-definition"}
4549
options={{ ns: "glossary-tooltip" }}
50+
// Override the default `a` tag transformation to avoid circular
51+
// dependency issues
52+
transform={{ a: InlineLink }}
4653
/>
4754
</Text>
4855
</VStack>

src/components/Nav/Mobile/ExpandIcon.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { motion } from "framer-motion"
2-
import { Icon } from "@chakra-ui/react"
32

43
const expandedPathVariants = {
54
closed: {
@@ -17,14 +16,9 @@ type ExpandIconProps = {
1716
}
1817

1918
const ExpandIcon = ({ isOpen }: ExpandIconProps) => (
20-
<Icon
19+
<svg
2120
viewBox="0 0 24 25"
22-
width={6}
23-
height={6}
24-
position="relative"
25-
strokeWidth="2px"
26-
display="inline-block"
27-
stroke="currentColor"
21+
className="relative inline-block h-6 w-6 stroke-current stroke-2 group-hover:text-primary-hover"
2822
>
2923
<motion.path
3024
variants={expandedPathVariants}
@@ -34,7 +28,7 @@ const ExpandIcon = ({ isOpen }: ExpandIconProps) => (
3428
stroke-width="2"
3529
/>
3630
<path d="M7.375 12.5L16.625 12.5" stroke-width="2" />
37-
</Icon>
31+
</svg>
3832
)
3933

4034
export default ExpandIcon
Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
1+
import { forwardRef } from "react"
12
import type { IconType } from "react-icons"
2-
import { type ButtonProps, Icon } from "@chakra-ui/react"
33

4-
import { Button } from "@/components/Buttons"
4+
import {
5+
Button,
6+
type ButtonProps,
7+
} from "../../../../tailwind/ui/buttons/Button"
58

69
type FooterButtonProps = ButtonProps & {
710
icon: IconType
811
}
912

10-
const FooterButton = ({ icon, ...props }: FooterButtonProps) => (
11-
<Button
12-
leftIcon={<Icon as={icon} />}
13-
sx={{ span: { m: 0 } }}
14-
variant="ghost"
15-
flexDir="column"
16-
alignItems="center"
17-
color="body.base"
18-
px="1"
19-
{...props}
20-
/>
13+
const FooterButton = forwardRef<HTMLButtonElement, FooterButtonProps>(
14+
({ icon: Icon, children, ...props }, ref) => (
15+
<Button
16+
ref={ref}
17+
className="flex h-fit flex-col items-center px-1 text-body"
18+
variant="ghost"
19+
{...props}
20+
>
21+
<Icon className="h-6 w-6" />
22+
{children}
23+
</Button>
24+
)
2125
)
26+
FooterButton.displayName = "FooterButton"
2227

2328
export default FooterButton

src/components/Nav/Mobile/FooterItemText.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
1-
import { Text } from "@chakra-ui/react"
2-
31
import { ChildOnlyProp } from "@/lib/types"
42

53
const FooterItemText = (props: ChildOnlyProp) => (
6-
<Text
7-
fontSize="sm"
8-
lineHeight="base"
9-
fontWeight="normal"
10-
letterSpacing="wider"
11-
mt="2"
12-
textTransform="uppercase"
13-
textAlign="center"
14-
opacity={0.7}
15-
_hover={{ opacity: 1 }}
4+
<p
5+
className="mt-2 text-center text-sm font-normal uppercase leading-base tracking-wider opacity-70 hover:opacity-100"
166
{...props}
177
/>
188
)

0 commit comments

Comments
 (0)