1234567891011121314151617181920212223242526272829303132 |
- import * as Sentry from '@sentry/node'
- import { RewriteFrames } from '@sentry/integrations'
-
- export const init = () => {
- if (process.env.NEXT_PUBLIC_SENTRY_DSN) {
- const integrations = []
- if (
- process.env.NEXT_IS_SERVER === 'true' &&
- process.env.NEXT_PUBLIC_SENTRY_SERVER_ROOT_DIR
- ) {
- 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
- },
- })
- )
- }
-
- Sentry.init({
- enabled: process.env.NODE_ENV === 'production',
- integrations,
- dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
- release: process.env.NEXT_PUBLIC_COMMIT_SHA,
- })
- }
- }
|