-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(viewer): ποΈ Add sentry to viewer
- Loading branch information
1 parent
ea80fd6
commit b339add
Showing
13 changed files
with
253 additions
and
5 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
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,27 @@ | ||
// This file sets a custom webpack configuration to use your Next.js app | ||
// with Sentry. | ||
// https://nextjs.org/docs/api-reference/next.config.js/introduction | ||
// https://docs.sentry.io/platforms/javascript/guides/nextjs/ | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const { withSentryConfig } = require('@sentry/nextjs') | ||
|
||
const moduleExports = { | ||
// Your existing module.exports | ||
} | ||
|
||
const sentryWebpackPluginOptions = { | ||
// Additional config options for the Sentry Webpack plugin. Keep in mind that | ||
// the following options are set automatically, and overriding them is not | ||
// recommended: | ||
// release, url, org, project, authToken, configFile, stripPrefix, | ||
// urlPrefix, include, ignore | ||
|
||
silent: true, // Suppresses all logs | ||
// For all available options, see: | ||
// https://github.com/getsentry/sentry-webpack-plugin#options. | ||
} | ||
|
||
// Make sure adding Sentry options is the last code to run before exporting, to | ||
// ensure that your source maps include changes from all other Webpack plugins | ||
module.exports = withSentryConfig(moduleExports, sentryWebpackPluginOptions) |
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,65 @@ | ||
import NextErrorComponent from 'next/error' | ||
|
||
import * as Sentry from '@sentry/nextjs' | ||
|
||
const MyError = ({ statusCode, hasGetInitialPropsRun, err }) => { | ||
if (!hasGetInitialPropsRun && err) { | ||
// getInitialProps is not called in case of | ||
// https://github.com/vercel/next.js/issues/8592. As a workaround, we pass | ||
// err via _app.js so it can be captured | ||
Sentry.captureException(err) | ||
// Flushing is not required in this case as it only happens on the client | ||
} | ||
|
||
return <NextErrorComponent statusCode={statusCode} /> | ||
} | ||
|
||
MyError.getInitialProps = async (context) => { | ||
const errorInitialProps = await NextErrorComponent.getInitialProps(context) | ||
|
||
const { res, err, asPath } = context | ||
|
||
// Workaround for https://github.com/vercel/next.js/issues/8592, mark when | ||
// getInitialProps has run | ||
errorInitialProps.hasGetInitialPropsRun = true | ||
|
||
// Returning early because we don't want to log 404 errors to Sentry. | ||
if (res?.statusCode === 404) { | ||
return errorInitialProps | ||
} | ||
|
||
// Running on the server, the response object (`res`) is available. | ||
// | ||
// Next.js will pass an err on the server if a page's data fetching methods | ||
// threw or returned a Promise that rejected | ||
// | ||
// Running on the client (browser), Next.js will provide an err if: | ||
// | ||
// - a page's `getInitialProps` threw or returned a Promise that rejected | ||
// - an exception was thrown somewhere in the React lifecycle (render, | ||
// componentDidMount, etc) that was caught by Next.js's React Error | ||
// Boundary. Read more about what types of exceptions are caught by Error | ||
// Boundaries: https://reactjs.org/docs/error-boundaries.html | ||
|
||
if (err) { | ||
Sentry.captureException(err) | ||
|
||
// Flushing before returning is necessary if deploying to Vercel, see | ||
// https://vercel.com/docs/platform/limits#streaming-responses | ||
await Sentry.flush(2000) | ||
|
||
return errorInitialProps | ||
} | ||
|
||
// If this point is reached, getInitialProps was called without any | ||
// information about what the error might be. This is unexpected and may | ||
// indicate a bug introduced in Next.js, so record it in Sentry | ||
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
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
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,15 @@ | ||
// This file configures the initialization of Sentry on the browser. | ||
// The config you add here will be used whenever a page is visited. | ||
// https://docs.sentry.io/platforms/javascript/guides/nextjs/ | ||
|
||
import * as Sentry from '@sentry/nextjs' | ||
|
||
Sentry.init({ | ||
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, | ||
// Adjust this value in production, or use tracesSampler for greater control | ||
tracesSampleRate: 1.0, | ||
// ... | ||
// Note: if you want to override the automatic release value, do not set a | ||
// `release` value here - use the environment variable `SENTRY_RELEASE`, so | ||
// that it will also get attached to your source maps | ||
}) |
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,4 @@ | ||
defaults.url=https://sentry.io/ | ||
defaults.org=typebot | ||
defaults.project=viewer | ||
cli.executable=../../../../.npm/_npx/14461/lib/node_modules/@sentry/wizard/node_modules/@sentry/cli/bin/sentry-cli |
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,15 @@ | ||
// This file configures the initialization of Sentry on the server. | ||
// The config you add here will be used whenever the server handles a request. | ||
// https://docs.sentry.io/platforms/javascript/guides/nextjs/ | ||
|
||
import * as Sentry from '@sentry/nextjs' | ||
|
||
Sentry.init({ | ||
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, | ||
// Adjust this value in production, or use tracesSampler for greater control | ||
tracesSampleRate: 1.0, | ||
// ... | ||
// Note: if you want to override the automatic release value, do not set a | ||
// `release` value here - use the environment variable `SENTRY_RELEASE`, so | ||
// that it will also get attached to your source maps | ||
}) |
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
b339add
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:
viewer-v2 β ./apps/viewer
typebot-viewer.vercel.app
viewer-v2-git-main-typebot-io.vercel.app
viewer-v2-typebot-io.vercel.app
b339add
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:
builder-v2 β ./apps/builder
builder-v2-typebot-io.vercel.app
builder-v2-git-main-typebot-io.vercel.app
app.typebot.io
b339add
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:
landing-page-v2 β ./apps/landing-page
landing-page-v2-typebot-io.vercel.app
www.get-typebot.com
get-typebot.com
landing-page-v2-git-main-typebot-io.vercel.app
typebot.io
www.typebot.io
b339add
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:
docs β ./apps/docs
docs-typebot-io.vercel.app
docs.typebot.io
docs-git-main-typebot-io.vercel.app