Sentry plugin
Page summary:
The Sentry plugin connects Strapi to Sentry to report errors and attach debugging metadata. This documentation details installation, environment-based configuration, and ways to disable or skip sending events outside production.
This plugin enables you to track errors in your Strapi application using Sentry.
IDENTITY CARD
Location
Only usable and configurable via server code
Package name
@strapi/plugin-sentryAdditional resources
By using the Sentry plugin you can:
- Initialize a Sentry instance upon startup of a Strapi application
- Send Strapi application errors as events to Sentry
- Include additional metadata in Sentry events to assist in debugging
- Expose a global Sentry service usable by the Strapi server
Installation
Install the Sentry plugin by adding the dependency to your Strapi application as follows:
- yarn
- npm
yarn add @strapi/plugin-sentry
npm install @strapi/plugin-sentry
Configuration
Create or edit your /config/plugins file to configure the Sentry plugin. The following properties are available:
| Property | Type | Default Value | Description |
|---|---|---|---|
dsn | string | null | Your Sentry data source name. |
sendMetadata | boolean | true | Whether the plugin should attach additional information (e.g., OS, browser, etc.) to the events sent to Sentry. |
init | object | {} | A config object that is passed directly to Sentry during initialization (see official Sentry documentation for available options). |
The following is an example basic configuration:
- JavaScript
- TypeScript
/config/plugins.js
module.exports = ({ env }) => ({
// ...
sentry: {
enabled: true,
config: {
dsn: env('SENTRY_DSN'),
sendMetadata: true,
},
},
// ...
});
/config/plugins.ts
export default ({ env }) => ({
// ...
sentry: {
enabled: true,
config: {
dsn: env('SENTRY_DSN'),
sendMetadata: true,
},
},
// ...
});