DEV Community

Željko Šević
Željko Šević

Posted on • Originally published at sevic.dev on

Error tracking with Sentry

Error tracking and alerting are crucial in the production environment, proactively fixing the errors leads to a better user experience. Sentry is one of the error tracking services, and it provides alerting for unhandled exceptions. You should receive an email when something wrong happens.

Sentry issues show the error stack trace, device, operating system, and browser information. The project dashboard shows an unhandled exception once it's thrown. This post covers the integration of several technologies with Sentry.

Node.js

  • Create a Node.js project on Sentry

  • Install the package

npm i @sentry/node
Enter fullscreen mode Exit fullscreen mode
  • Run the following script
const Sentry = require('@sentry/node');

Sentry.init({
  dsn: SENTRY_DSN
});

test();
Enter fullscreen mode Exit fullscreen mode

Next.js

  • Create a Next.js project on Sentry (version 13 is not yet supported)

  • Run the following commands for the setup

npm i @sentry/nextjs
npx @sentry/wizard -i nextjs
Enter fullscreen mode Exit fullscreen mode

Gatsby

  • Create a Gatsby project on Sentry

  • Install the package

npm i @sentry/gatsby
Enter fullscreen mode Exit fullscreen mode
  • Add plugin in Gatsby config
module.exports = {
  plugins: [
    // ...
    {
      resolve: '@sentry/gatsby',
      options: {
        dsn: SENTRY_DSN
      }
    }
  ]
};
Enter fullscreen mode Exit fullscreen mode

React Native

  • Create a React Native project on Sentry

  • Run the following commands for the setup

npm i @sentry/react-native
npx @sentry/wizard -i reactNative -p android
Enter fullscreen mode Exit fullscreen mode

Course

Build your SaaS in 2 weeks - Start Now

Top comments (0)