您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

sentry.ts 1003B

123456789101112131415161718192021222324252627282930313233
  1. import * as Sentry from '@sentry/node'
  2. import { RewriteFrames } from '@sentry/integrations'
  3. export function init(): void {
  4. if (!process.env.NEXT_PUBLIC_SENTRY_DSN) return
  5. const integrations = []
  6. if (process.env.NEXT_IS_SERVER === 'true' && process.env.NEXT_PUBLIC_SENTRY_SERVER_ROOT_DIR) {
  7. // For Node.js, rewrite Error.stack to use relative paths, so that source
  8. // maps starting with ~/_next map to files in Error.stack with path
  9. // app:///_next
  10. integrations.push(
  11. new RewriteFrames({
  12. iteratee: (frame) => {
  13. frame.filename = frame.filename.replace(
  14. process.env.NEXT_PUBLIC_SENTRY_SERVER_ROOT_DIR,
  15. 'app:///'
  16. )
  17. frame.filename = frame.filename.replace('.next', '_next')
  18. return frame
  19. },
  20. })
  21. )
  22. }
  23. Sentry.init({
  24. enabled: process.env.NODE_ENV === 'production',
  25. integrations,
  26. dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
  27. release: process.env.NEXT_PUBLIC_COMMIT_SHA,
  28. })
  29. }