-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* install and configure sentry. * fake errors. * move to environment variables. * enable debug. * make env variable public. * add log messages to api routes. * move logs inside handler. * cleanup. * remove error button. Co-authored-by: Brad Garropy <[email protected]>
- Loading branch information
1 parent
cfec2c3
commit 11bd772
Showing
9 changed files
with
1,815 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ coverage | |
|
||
# logs | ||
debug.log | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import * as Sentry from "@sentry/nextjs" | ||
|
||
Sentry.init({ | ||
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, | ||
tracesSampleRate: 1.0, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import * as Sentry from "@sentry/nextjs" | ||
|
||
Sentry.init({ | ||
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, | ||
tracesSampleRate: 1.0, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import * as Sentry from "@sentry/nextjs" | ||
import NextErrorComponent from "next/error" | ||
|
||
const MyError = ({statusCode, hasGetInitialPropsRun, err}) => { | ||
if (!hasGetInitialPropsRun && err) { | ||
Sentry.captureException(err) | ||
} | ||
|
||
return <NextErrorComponent statusCode={statusCode} /> | ||
} | ||
|
||
MyError.getInitialProps = async context => { | ||
const errorInitialProps = await NextErrorComponent.getInitialProps(context) | ||
const {res, err, asPath} = context | ||
|
||
errorInitialProps.hasGetInitialPropsRun = true | ||
|
||
if (res?.statusCode === 404) { | ||
return errorInitialProps | ||
} | ||
|
||
if (err) { | ||
Sentry.captureException(err) | ||
await Sentry.flush(2000) | ||
|
||
return errorInitialProps | ||
} | ||
|
||
Sentry.captureException( | ||
new Error(`_error.js getInitialProps missing data at path: ${asPath}`), | ||
) | ||
|
||
await Sentry.flush(2000) | ||
|
||
return errorInitialProps | ||
} | ||
|
||
export default MyError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11bd772
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: