Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 860af35

Browse files
committed
Revert to e950c57, ci build ok one
1 parent 79a6d43 commit 860af35

File tree

6 files changed

+58
-11
lines changed

6 files changed

+58
-11
lines changed

next.config.docker.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ const nextConfig = {
2424
'process.env.SENTRY_RELEASE': JSON.stringify(buildId),
2525
}),
2626
)
27+
if (!isServer) {
28+
config.resolve.alias['@sentry/node'] = '@sentry/browser'
29+
}
2730

2831
return config
2932
},

next.config.js

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ const withBundleAnalyzer = require('@next/bundle-analyzer')({
1010
const offlineConfig = require('./config/next_offline')
1111

1212
// Use the SentryWebpack plugin to upload the source maps during build step
13-
// const SentryWebpackPlugin = require('@sentry/webpack-plugin')
13+
const SentryWebpackPlugin = require('@sentry/webpack-plugin')
1414

15-
// const {
16-
// NEXT_PUBLIC_SENTRY_DSN: SENTRY_DSN,
17-
// SENTRY_ORG,
18-
// SENTRY_PROJECT,
19-
// SENTRY_AUTH_TOKEN,
20-
// NODE_ENV,
21-
// } = process.env
15+
const {
16+
NEXT_PUBLIC_SENTRY_DSN: SENTRY_DSN,
17+
SENTRY_ORG,
18+
SENTRY_PROJECT,
19+
SENTRY_AUTH_TOKEN,
20+
NODE_ENV,
21+
} = process.env
2222

23-
// process.env.SENTRY_DSN = SENTRY_DSN
23+
process.env.SENTRY_DSN = SENTRY_DSN
2424

2525
// next-plugins end
2626

@@ -34,6 +34,38 @@ const nextConfig = {
3434
new webpack.ContextReplacementPlugin(/moment[/\\]locale$/, /(en)/),
3535
)
3636

37+
// for sentry
38+
config.plugins.push(
39+
new webpack.DefinePlugin({
40+
'process.env.SENTRY_RELEASE': JSON.stringify(buildId),
41+
}),
42+
)
43+
if (!isServer) {
44+
config.resolve.alias['@sentry/node'] = '@sentry/browser'
45+
}
46+
47+
// When all the Sentry configuration env variables are available/configured
48+
// The Sentry webpack plugin gets pushed to the webpack plugins to build
49+
// and upload the source maps to sentry.
50+
// This is an alternative to manually uploading the source maps
51+
// Note: This is disabled in development mode.
52+
if (
53+
SENTRY_DSN &&
54+
SENTRY_ORG &&
55+
SENTRY_PROJECT &&
56+
SENTRY_AUTH_TOKEN &&
57+
NODE_ENV === 'production'
58+
) {
59+
config.plugins.push(
60+
new SentryWebpackPlugin({
61+
include: '.next',
62+
ignore: ['node_modules'],
63+
urlPrefix: '~/_next',
64+
release: buildId,
65+
}),
66+
)
67+
}
68+
3769
return config
3870
},
3971
}

src/containers/content/CommunityContent/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* CommunityContent.
2+
* CommunityContent
33
*/
44

55
import { FC, Fragment } from 'react'

src/pages/_app.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Head from 'next/head'
2+
import * as Sentry from '@sentry/node'
23

34
/**
45
* import default seo configuration
@@ -10,6 +11,11 @@ import Head from 'next/head'
1011

1112
import CrashErrorHint from '@/components/CrashErrorHint'
1213

14+
Sentry.init({
15+
enabled: process.env.NODE_ENV === 'production',
16+
dsn: process.env.NEXT_PUBLIC_SENTRY_TOKEN,
17+
})
18+
1319
const App = ({ Component, pageProps, err }) => {
1420
return (
1521
<>

src/pages/_error.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react'
22
import NextErrorComponent from 'next/error'
33
import { Provider } from 'mobx-react'
4+
import * as Sentry from '@sentry/node'
45

56
import AnalysisService from '@/services/Analysis'
67
import ThemePalette from '@/containers/layout/ThemePalette'
@@ -19,6 +20,7 @@ const Error = (props) => {
1920
// getInitialProps is not called in case of
2021
// https://github.com/vercel/next.js/issues/8592. As a workaround, we pass
2122
// err via _app.js so it can be captured
23+
Sentry.captureException(err)
2224
}
2325

2426
return (
@@ -67,12 +69,16 @@ Error.getInitialProps = async ({ res, err, asPath }) => {
6769
return { statusCode: 404, ...i18nConfig }
6870
}
6971
if (err) {
72+
Sentry.captureException(err)
7073
return { ...errorInitialProps, ...i18nConfig }
7174
}
7275

7376
// If this point is reached, getInitialProps was called without any
7477
// information about what the error might be. This is unexpected and may
7578
// indicate a bug introduced in Next.js, so record it in Sentry
79+
Sentry.captureException(
80+
new Error(`_error.js getInitialProps missing data at path: ${asPath}`),
81+
)
7682

7783
return { ...errorInitialProps, ...i18nConfig }
7884
}

src/pages/community.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export const getServerSideProps: GetServerSideProps = async (props) => {
147147
return { props: { errorCode: null, ...initProps } }
148148
}
149149

150-
const CommunityPage = (props = {}) => {
150+
const CommunityPage = (props) => {
151151
const store = useStore(props)
152152

153153
const { errorCode, viewing } = store

0 commit comments

Comments
 (0)