Search code examples
next.jssentry

Sentry, Next.JS and digest


How can I add error.digest as a tag to all of reported errors?

scope.setTag('digest', error.digest)

In the sentry.server.config.ts and Sentry.init we can customize the beforeSend hook but I couldn't find the error.digest the hint.originalException.digest and hint.syntheticException.digest are undefined

Is there anyway to solve this problem?


Solution

  • In your sentry.client.config.ts file, you can add beforeSend logic to grab the digest off hint.originalException to Sentry.init() as you explained in your question.

    Unfortunately, on the backend, you or the SDK cannot access the digest, except through logs, since React itself (this is not something Next.js is responsible for) is not exposing the digest, or the digest generation logic in any way.