generated from 8iq/nodejs-hackathon-boilerplate-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SBERDOMA-104 add sentry to client/server
- Loading branch information
Showing
6 changed files
with
139 additions
and
41 deletions.
There are no files selected for viewing
32 changes: 0 additions & 32 deletions
32
apps/condo/domains/common/components/containers/GlobalErrorBoundery.tsx
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import * as Sentry from '@sentry/node' | ||
import { RewriteFrames } from '@sentry/integrations' | ||
import getConfig from 'next/config' | ||
|
||
// refs. to: https://github.com/vercel/next.js/blob/canary/examples/with-sentry/utils/sentry.js | ||
export const initSentry = () => { | ||
const { publicRuntimeConfig } = getConfig() | ||
const { sentryDsn, isProduction } = publicRuntimeConfig | ||
|
||
if (sentryDsn) { | ||
const integrations = [] | ||
if (typeof window === 'undefined') { | ||
// For Node.js, rewrite Error.stack to use relative paths, so that source | ||
// maps starting with ~/_next map to files in Error.stack with path | ||
// app:///_next | ||
integrations.push( | ||
new RewriteFrames({ | ||
iteratee: (frame) => { | ||
frame.filename = frame.filename.replace( | ||
process.env.NEXT_PUBLIC_SENTRY_SERVER_ROOT_DIR, | ||
'app:///' | ||
) | ||
frame.filename = frame.filename.replace('.next', '_next') | ||
return frame | ||
}, | ||
}) | ||
) | ||
} | ||
|
||
console.log(isProduction) | ||
Sentry.init({ | ||
integrations, | ||
dsn: sentryDsn, | ||
enabled: isProduction, | ||
}) | ||
} | ||
} |
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