Integrate Sentry With Strapi

Written by Sujay Prabhu on May 10, 2022; tagged under strapi, sentry

Sentry is a platform that notifies exceptions or errors that a user runs into while using the application. It can also be used for performance monitoring, setting alerts of errors and monitoring the health of each releases. Sentry can be integrated with Strapi in a couple of ways.

Using the official plugin: @strapi/plugin-sentry

yarn add @strapi/plugin-sentry // yarn
npm install @strapi/plugin-sentry // npm
  sentry: {
    enabled: true,
    config: {
      dsn: process.env.SENTRY_DSN,
      sendMetadata: true,

Here is the link of the pull request for integrating Sentry using officail plugin.

Note: strapi-plugin-sentry was the plugin to be used with Strapi v3 and it is deprecated with Strapi v4

Create custom middleware in Strapi

// src/middlewares/sentry.js

  dsn: process.env.SENTRY_DSN,
  environment: strapi.config.environment,
  integrations: [new Sentry.Integrations.Http({ tracing: true })],
  tracesSampleRate: 1.0,

module.exports = (config, { strapi }) => {
  return async (ctx, next) => {
    try {
      await next();
    } catch (error) {
      // Error object or string can be passed to captureException
      throw error;
// config/middleware.js

  // ... existing middlewares

Here is the link of the pull request for integrating Sentry by creating custom middleware.

Related Articles:

Sentry for Koa

Why Koa?

Middlewares in Strapi

If you have any questions or feedback, feel free to drop us a mail at