-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add gatsby example #2054
add gatsby example #2054
Conversation
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ | ||
"skipLibCheck": true /* Skip type checking all .d.ts files. */ | ||
}, | ||
"include": ["./src/**/*", "./gatsby-node.ts", "./gatsby-config.ts", "./plugins/**/*", "gatsby-browser.js", "gatsby-node.js", "gatsby-ssr.js"] |
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.
What are gatsby-node.js
and gatsby-ssr.js
?
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.
See https://www.gatsbyjs.com/docs/reference/config-files/gatsby-node/ and https://www.gatsbyjs.com/docs/reference/config-files/gatsby-ssr/ respectively
This is just the standard tsconfig that comes when starting a new Gatsby project. gatsby-node.js
and gatsby-ssr.js
and gatsby-browser.js
are optional files
examples/js/gatsby/gatsby-browser.js
Outdated
/** | ||
* With `gatsby develop` wrapRootElement is called before onClientEntry and then again afterwards. | ||
* However, `gatsby serve` onClientEntry is called, followed by wrapRootElement. So we need this | ||
* extra state to deal with the difference in behavior. | ||
*/ | ||
let bugsnagStarted = false | ||
|
||
export const onClientEntry = () => { | ||
if (bugsnagStarted) { | ||
return | ||
} | ||
Bugsnag.start(bugsnagConfig) | ||
bugsnagStarted = true | ||
} |
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.
This can use Bugsnag.isStarted
instead of keeping track manually
/** | |
* With `gatsby develop` wrapRootElement is called before onClientEntry and then again afterwards. | |
* However, `gatsby serve` onClientEntry is called, followed by wrapRootElement. So we need this | |
* extra state to deal with the difference in behavior. | |
*/ | |
let bugsnagStarted = false | |
export const onClientEntry = () => { | |
if (bugsnagStarted) { | |
return | |
} | |
Bugsnag.start(bugsnagConfig) | |
bugsnagStarted = true | |
} | |
export const onClientEntry = () => { | |
if (Bugsnag.isStarted) { | |
return | |
} | |
Bugsnag.start(bugsnagConfig) | |
} |
examples/js/gatsby/gatsby-browser.js
Outdated
if (!bugsnagStarted) { | ||
Bugsnag.start(bugsnagConfig) | ||
bugsnagStarted = true | ||
} |
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.
if (!bugsnagStarted) { | |
Bugsnag.start(bugsnagConfig) | |
bugsnagStarted = true | |
} | |
if (!Bugsnag.isStarted) { | |
Bugsnag.start(bugsnagConfig) | |
} |
Goal
To demonstrate how to integrate BugSnag with Gatsby projects
Design
Focus on browser error tracking as most of the Gatsby usage is expected to be SSG pages
Testing
gatsby develop
:useEffect
Bad button handler
useCallback
bad button
error thrown during rendergatsby build && gatsby serve
:useEffect
Bad button handler
useCallback
bad button
error thrown during render