@sentry/wizard 1.2.12 → 1.2.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +99 -81
- package/README.md +29 -12
- package/dist/NextJs/configs/_error.js +65 -0
- package/dist/NextJs/configs/next.config.js +2 -2
- package/dist/lib/Helper/SentryCli.d.ts +4 -0
- package/dist/lib/Helper/SentryCli.js +14 -0
- package/dist/lib/Helper/SentryCli.js.map +1 -1
- package/dist/lib/Steps/Integrations/BaseIntegration.d.ts +1 -1
- package/dist/lib/Steps/Integrations/BaseIntegration.js +3 -2
- package/dist/lib/Steps/Integrations/BaseIntegration.js.map +1 -1
- package/dist/lib/Steps/Integrations/NextJs.d.ts +3 -2
- package/dist/lib/Steps/Integrations/NextJs.js +83 -53
- package/dist/lib/Steps/Integrations/NextJs.js.map +1 -1
- package/lib/Helper/SentryCli.ts +17 -0
- package/lib/Steps/Integrations/BaseIntegration.ts +5 -2
- package/lib/Steps/Integrations/NextJs.ts +105 -65
- package/package.json +1 -1
- package/scripts/NextJs/configs/_error.js +65 -0
- package/scripts/NextJs/configs/next.config.js +2 -2
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import NextErrorComponent from 'next/error';
|
|
2
|
+
|
|
3
|
+
import * as Sentry from '@sentry/nextjs';
|
|
4
|
+
|
|
5
|
+
const MyError = ({ statusCode, hasGetInitialPropsRun, err }) => {
|
|
6
|
+
if (!hasGetInitialPropsRun && err) {
|
|
7
|
+
// getInitialProps is not called in case of
|
|
8
|
+
// https://github.com/vercel/next.js/issues/8592. As a workaround, we pass
|
|
9
|
+
// err via _app.js so it can be captured
|
|
10
|
+
Sentry.captureException(err);
|
|
11
|
+
// Flushing is not required in this case as it only happens on the client
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return <NextErrorComponent statusCode={statusCode} />;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
MyError.getInitialProps = async (context) => {
|
|
18
|
+
const errorInitialProps = await NextErrorComponent.getInitialProps(context);
|
|
19
|
+
|
|
20
|
+
const { res, err, asPath } = context;
|
|
21
|
+
|
|
22
|
+
// Workaround for https://github.com/vercel/next.js/issues/8592, mark when
|
|
23
|
+
// getInitialProps has run
|
|
24
|
+
errorInitialProps.hasGetInitialPropsRun = true;
|
|
25
|
+
|
|
26
|
+
// Returning early because we don't want to log 404 errors to Sentry.
|
|
27
|
+
if (res?.statusCode === 404) {
|
|
28
|
+
return errorInitialProps;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Running on the server, the response object (`res`) is available.
|
|
32
|
+
//
|
|
33
|
+
// Next.js will pass an err on the server if a page's data fetching methods
|
|
34
|
+
// threw or returned a Promise that rejected
|
|
35
|
+
//
|
|
36
|
+
// Running on the client (browser), Next.js will provide an err if:
|
|
37
|
+
//
|
|
38
|
+
// - a page's `getInitialProps` threw or returned a Promise that rejected
|
|
39
|
+
// - an exception was thrown somewhere in the React lifecycle (render,
|
|
40
|
+
// componentDidMount, etc) that was caught by Next.js's React Error
|
|
41
|
+
// Boundary. Read more about what types of exceptions are caught by Error
|
|
42
|
+
// Boundaries: https://reactjs.org/docs/error-boundaries.html
|
|
43
|
+
|
|
44
|
+
if (err) {
|
|
45
|
+
Sentry.captureException(err);
|
|
46
|
+
|
|
47
|
+
// Flushing before returning is necessary if deploying to Vercel, see
|
|
48
|
+
// https://vercel.com/docs/platform/limits#streaming-responses
|
|
49
|
+
await Sentry.flush(2000);
|
|
50
|
+
|
|
51
|
+
return errorInitialProps;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// If this point is reached, getInitialProps was called without any
|
|
55
|
+
// information about what the error might be. This is unexpected and may
|
|
56
|
+
// indicate a bug introduced in Next.js, so record it in Sentry
|
|
57
|
+
Sentry.captureException(
|
|
58
|
+
new Error(`_error.js getInitialProps missing data at path: ${asPath}`),
|
|
59
|
+
);
|
|
60
|
+
await Sentry.flush(2000);
|
|
61
|
+
|
|
62
|
+
return errorInitialProps;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default MyError;
|
|
@@ -9,7 +9,7 @@ const moduleExports = {
|
|
|
9
9
|
// Your existing module.exports
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const sentryWebpackPluginOptions = {
|
|
13
13
|
// Additional config options for the Sentry Webpack plugin. Keep in mind that
|
|
14
14
|
// the following options are set automatically, and overriding them is not
|
|
15
15
|
// recommended:
|
|
@@ -23,4 +23,4 @@ const SentryWebpackPluginOptions = {
|
|
|
23
23
|
|
|
24
24
|
// Make sure adding Sentry options is the last code to run before exporting, to
|
|
25
25
|
// ensure that your source maps include changes from all other Webpack plugins
|
|
26
|
-
module.exports = withSentryConfig(moduleExports,
|
|
26
|
+
module.exports = withSentryConfig(moduleExports, sentryWebpackPluginOptions);
|