Skip to content

Commit 67d9ae8

Browse files
authored
Merge pull request #98 from chrisweb/preview
#98 (comment)
2 parents ca9710c + 27da328 commit 67d9ae8

File tree

9 files changed

+882
-876
lines changed

9 files changed

+882
-876
lines changed

app/error.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default function Error({
1919

2020
return (
2121
<section className="core">
22-
<h1 className="h1">
22+
<h1 className="h3">
2323
Sorry, something went wrong
2424
&nbsp;
2525
<span className="emoji">😞</span>

app/global-error.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default function GlobalError({
2222
<body>
2323
<main>
2424
<section className="core">
25-
<h1 className="h1">
25+
<h1 className="h3">
2626
Sorry, something went wrong
2727
&nbsp;
2828
<span className="emoji">😞</span>

app/global.css

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,27 +328,27 @@ p {
328328
margin-block: 1.8em;
329329
}
330330

331-
h1 {
331+
h1, .h1 {
332332
font-size: var(--main-fontSize-big1);
333333
}
334334

335-
h2 {
335+
h2, .h2 {
336336
font-size: var(--main-fontSize-big2);
337337
}
338338

339-
h3 {
339+
h3, .h3 {
340340
font-size: var(--main-fontSize-big3);
341341
}
342342

343-
h4 {
343+
h4, .h4 {
344344
font-size: var(--main-fontSize-big4);
345345
}
346346

347-
h5 {
347+
h5, .h5 {
348348
font-size: var(--main-fontSize-big5);
349349
}
350350

351-
h6 {
351+
h6, .h6 {
352352
font-size: var(--main-fontSize-big6);
353353
}
354354

app/web_development/posts/sentry-io/page.mdx

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Sentry.io
33
keywords: ['Sentry.io', 'logging', 'debugging', 'SaaS', 'wizard']
44
published: 2024-08-07T11:22:33.444Z
5-
modified: 2024-09-02T16:16:16.444Z
5+
modified: 2025-02-19T16:16:16.444Z
66
permalink: https://chris.lu/web_development/posts/sentry-io
77
section: Web development
88
---
@@ -206,28 +206,42 @@ To enable Sentry **reactComponentAnnotation** configuration option is usually a
206206
207207
### Issues with Sentry Component Annotations
208208

209-
To make this feature happen Sentry needs to add a data attributes to components, this does usually not pose a problem except sometimes the Sentry Annotations on third party components will cause an error in those third party tools, like [react-three-fiber](https://github.com/pmndrs/react-three-fiber) which do NOT like those extra attributes at all
209+
For the **Sentry Component Annotation** feature to work, Sentry adds a `data-sentry` data attribute to the DOM of React components.
210210

211-
This means that **React component annotations** are great unless you use a package like **React Three Fiber** or setup your project using **Vite**, then you need to disable the feature
211+
This does usually not pose a problem except with some packages that are incompatible. For example if you enable **Component Annotations** and use [@react-three/fiber](https://github.com/pmndrs/react-three-fiber) then you might see the following error ([Sentry Issue #530](https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/530)) popping up in your terminal:
212212

213-
#### React three fiber (R3F) issue
213+
> TypeError: Cannot read properties of undefined (reading 'sentry')
214214
215-
For now if you use **React three fiber (R3F)** the only workaround is to turn the Sentry **React component annotations** option off, by setting the `reactComponentAnnotation` variable to false
215+
A similar [Issue #492](https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/492) has impacted vite users
216216

217-
It is only after I had opened an [Issue #13413](https://github.com/getsentry/sentry-javascript/issues/13413) in the **sentry-javascript** repository that I found the [Issue #530 (Cannot read properties of undefined (reading 'sentry') when using reactComponentAnnotation)](https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/530) in the **sentry-javascript-bundler-plugins** repository, which has a comment by one of the Sentry SDK maintainers, they mentioned that they consider adding more options in the future to let you exclude components
217+
<span className="neonBlueHighlightedText">Option 1</span> (just a workaround): Is to disable the feature by setting the **reactComponentAnnotation** configuration option to **false**:
218218

219-
However as of now those options are not available yet (we can NOT enable React component annotations and exclude React three fiber), meaning the only option left is to disable the reactComponentAnnotation feature (if you chose to continue using R3F)
219+
```js
220+
reactComponentAnnotation: {
221+
enabled: false,
222+
},
223+
```
220224

221-
> [!MORE]
222-
> [Sentry "Issue #530" (open as of dec. 2024)](https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/530)
225+
<span className="neonBlueHighlightedText">Option 2</span> (only available in Sentry > 9):
223226

224-
#### Vite issue
227+
The sentry-javascript-bundler-plugins [PR #617](https://github.com/getsentry/sentry-javascript-bundler-plugins/pull/617) has added a new **ignoredComponents** configuration option, that lets you tell Sentry which components should get ignored, meaning for those components Sentry will not try to add extra attributes to their DOM
225228

226-
There is a similar issue when using Vite and the @sentry/vite-plugin as described in the [Issue #492](https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/492) which (as of dec. 2024) is also still open
229+
```js
230+
reactComponentAnnotation: {
231+
enabled: true,
232+
ignoredComponents: ['MY_COMPONENT_WHICH_BREAKS'],
233+
},
234+
```
227235

228-
Same as R3F, the only solution here is to NOT enable the annotations feature until the problem is fixed
236+
> [!WARN]
237+
> The first **sentry-javascript-bundler-plugins** version with support for the Sentry **ignoredComponents** is [version 2.23.0](https://github.com/getsentry/sentry-javascript-bundler-plugins/releases/tag/2.23.0).
238+
>
239+
> @Sentry/Next.js v8.45.0 still uses @sentry/bundler-plugin-core / @sentry/webpack-plugin v2.22.7
240+
>
241+
> @Sentry/Next.js v9.0.1 has (@sentry/webpack-plugin) v3.1.2 as dependency, so this is the first version that has the new **ignoredComponents** feature merged
229242
230243
> [!MORE]
231-
> [Sentry "Issue #492" (open as of dec. 2024)](https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/530)
244+
> [Sentry bundler "Issue #530"](https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/530)
245+
> [Sentry bundler "PR #617"](https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/530)
232246
233247
</article>

app/web_development/tutorials/next-js-static-first-mdx-starterkit/error-handling-and-logging/page.mdx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Error handling and logging - Next.js 15 Tutorial
33
description: Error handling and logging - Next.js 15 static first MDX starterkit | Web development tutorials | www.chris.lu
44
keywords: ['error', 'handling', 'logging', 'Boundary', 'react', 'sentry.io', 'nextjs']
55
published: 2024-12-31T23:00:00.000Z
6-
modified: 2024-12-31T23:00:00.000Z
6+
modified: 2025-02-19T23:00:00.000Z
77
permalink: https://chris.lu/web_development/tutorials/next-js-static-first-mdx-starterkit/error-handling-and-logging
88
section: Web development
99
---
@@ -202,11 +202,7 @@ Now, Sentry will install the latest Sentry SDK for Next.js.
202202
**Do you want to enable React component annotations to make breadcrumbs and session replays more readable?** Next Sentry is asking if we want to use the feature called [React component annotations](https://docs.sentry.io/platforms/javascript/guides/react/features/component-names/) which attempts to use component names in reports instead of more cryptic selectors, I think this is a nice feature, so I selected **Yes**, if you already use Sentry.io and don't want to change how bug reports work, then leave it on **No**, you can always turn it on/off via the configuration later if you want
203203

204204
> [!WARN]
205-
> I turned **React component annotations** on and then noticed that my [react-three-fiber](https://github.com/pmndrs/react-three-fiber) animation had stopped working, this is because **React component annotations** adds data attributes to components which React Three Fiber does not like, and which then creates bugs which print the following in your console:
206-
>
207-
> > TypeError: Cannot read properties of undefined (reading 'sentry')
208-
>
209-
> So if you plan on using **React Three Fiber** then you should answer to this question with **NO**, to learn more about this problem and how to disable **React component annotations** manually in the configuration have a look at the [Sentry React Component Annotation(s) can be problematic](#sentry-react-component-annotations-can-be-problematic) chapter
205+
> be aware that some packages might have a problem with the extra attributes that Sentry adds to the DOM of a component, to make the Annotations feature work. If you want to learn more about this problem, then I recommend reading the ["Issues with Sentry Component Annotations" chapter of the "Sentry" post](/web_development/posts/sentry-io#issues-with-sentry-component-annotations)
210206
211207
**Do you want to create an example page** chose **YES** (we will later use it to test the Sentry setup, and then we will delete it)
212208

@@ -328,13 +324,11 @@ Now is a good time to commit the updated `next.config.ts` (and other changes the
328324
329325
### Sentry React Component Annotation(s) can be problematic
330326

331-
To enable Sentry **reactComponentAnnotation** configuration option is usually a good idea as it makes reports more readable by using component names instead of long selectors
332-
333-
To make this feature happen Sentry needs to add a data attributes to components, this does usually not pose a problem except sometimes the Sentry Annotations on third party components will cause an error in those third party tools
327+
It is usually a good idea enable Sentry **reactComponentAnnotation** configuration option, as it makes reports more readable by using component names instead of long selectors
334328

335-
I have a more detailed explanation about annotations and the problems that can occur in my [Sentry Post](/web_development/posts/sentry-io)
329+
To make the Annotation(s) feature work, Sentry needs to add a data attributes to components, this does usually not pose a problem except in some situations where the Sentry Annotations on a third party components will cause an error in those third party package.
336330

337-
The solution to these problems is to disable the feature and wait for the Sentry team to fine tune the feature (which is quite young) and fix annotations bugs (I have linked to some tickets in my Sentry post, you may want to subscribe to them if you want to keep track of fixes)
331+
For those that run into problems after enabling the React Component Annotations feature, I have added a more detailed explanation as well as a workaround in the ["Issues with Sentry Component Annotations" chapter of the "Sentry" post](/web_development/posts/sentry-io#issues-with-sentry-component-annotations)
338332

339333
> [!MORE]
340334
> [chris.lu "Sentry.io" post](/web_development/posts/sentry-io)

components/neonRoad/Canvas.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ const NeonRoadCanvas: React.FC<IProps> = (props) => {
8080
aria-label={props.altText}
8181
role="img"
8282
gl={rendererProps}
83-
//frameloop="never"
84-
//onCreated={onCanvasCreatedHandler}
83+
//frameloop="never"
84+
//onCreated={onCanvasCreatedHandler}
8585
>
8686
<Suspense fallback={<Fallback />}>
8787
<AdaptiveDpr pixelated />
@@ -134,4 +134,6 @@ const NeonRoadCanvas: React.FC<IProps> = (props) => {
134134
)
135135
}
136136

137+
NeonRoadCanvas.displayName = 'NeonRoadCanvas'
138+
137139
export default NeonRoadCanvas

next.config.ts

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ const nextConfig = (phase: string) => {
218218
formats: ['image/avif', 'image/webp'],
219219
deviceSizes: [240, 336, 480, 704, 1080, 1408, 1920, 2112, 3840],
220220
},
221-
// TODO: is this needed for app directory
222221
// Configure pageExtensions to include md and mdx
223222
pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'mdx'],
224223
// disable linting during builds using "next lint"
@@ -314,6 +313,21 @@ const securityHeadersConfig = (phase: string) => {
314313
${upgradeInsecure}
315314
`
316315

316+
// for production environment white-list vitals.vercel-insights
317+
// based on: https://vercel.com/docs/speed-insights#content-security-policy
318+
if (process.env.VERCEL_ENV === 'production') {
319+
return `
320+
${defaultCSPDirectives}
321+
font-src 'self';
322+
style-src 'self' 'unsafe-inline';
323+
script-src 'self' 'unsafe-inline' 'wasm-unsafe-eval';
324+
connect-src 'self' https://vitals.vercel-insights.com ${reportingDomainWildcard};
325+
img-src 'self' data:;
326+
frame-src 'none';
327+
${reportCSPViolations}
328+
`
329+
}
330+
317331
// when environment is preview enable unsafe-inline scripts for vercel preview feedback/comments feature
318332
// and whitelist vercel's domains based on:
319333
// https://vercel.com/docs/workflow-collaboration/comments/specialized-usage#using-a-content-security-policy
@@ -332,26 +346,11 @@ const securityHeadersConfig = (phase: string) => {
332346
`
333347
}
334348

335-
// for production environment white-list vitals.vercel-insights
336-
// based on: https://vercel.com/docs/speed-insights#content-security-policy
337-
if (process.env.VERCEL_ENV === 'production') {
338-
return `
339-
${defaultCSPDirectives}
340-
font-src 'self';
341-
style-src 'self' 'unsafe-inline';
342-
script-src 'self' 'unsafe-inline' 'wasm-unsafe-eval';
343-
connect-src 'self' https://vitals.vercel-insights.com ${reportingDomainWildcard};
344-
img-src 'self' data:;
345-
frame-src 'none';
346-
${reportCSPViolations}
347-
`
348-
}
349-
350349
// for dev environment enable unsafe-eval for hot-reload
351350
return `
352351
${defaultCSPDirectives}
353-
font-src 'self';
354-
style-src 'self' 'unsafe-inline';
352+
font-src 'self' https://fonts.gstatic.com;
353+
style-src 'self' 'unsafe-inline' https://fonts.googleapis.com;
355354
script-src 'self' 'unsafe-inline' 'unsafe-eval' https://va.vercel-scripts.com;
356355
connect-src 'self';
357356
img-src 'self' data:;
@@ -430,6 +429,10 @@ export default withSentryConfig(
430429
// Automatically annotate React components to show their full name in breadcrumbs and session replay
431430
reactComponentAnnotation: {
432431
enabled: false,
432+
// not sure what to do with this yet
433+
// none of my attempts seem to work
434+
// https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/530
435+
ignoredComponents: ['@react-three/fiber', '__r3f', 'r3f', 'PlaneGeometry', 'BufferGeometry', 'Canvas', 'ambientLight', 'DirectionalLight', 'AdaptiveDpr', 'EffectComposer', 'Bloom', 'OrthographicCamera', 'PerspectiveCamera', 'SoftShadows', 'mesh'],
433436
},
434437

435438
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
@@ -439,7 +442,12 @@ export default withSentryConfig(
439442
tunnelRoute: '/monitoring',
440443

441444
// Hides source maps from generated client bundles
442-
hideSourceMaps: true,
445+
sourcemaps: {
446+
//disable: false;
447+
//assets: string | string[];
448+
//ignore?: string | string[];
449+
//deleteSourcemapsAfterUpload: boolean;
450+
},
443451

444452
// Automatically tree-shake Sentry logger statements to reduce bundle size
445453
disableLogger: true,
@@ -448,6 +456,6 @@ export default withSentryConfig(
448456
// See the following for more information:
449457
// https://docs.sentry.io/product/crons/
450458
// https://vercel.com/docs/cron-jobs
451-
automaticVercelMonitors: true,
459+
//automaticVercelMonitors: true,
452460
}
453461
)

0 commit comments

Comments
 (0)