Skip to content

Sentry

The Sentry module (@zumito-team/sentry) integrates Sentry for centralized error monitoring. It automatically captures every error that passes through the framework’s ErrorHandler, enriching them with Discord context (guild, user, channel, command name).

Terminal window
npm install @zumito-team/sentry
zumito.config.ts
import { SentryModule } from '@zumito-team/sentry';
export const config = {
bundles: [
{
path: 'node_modules/@zumito-team/sentry',
options: {
dsn: 'https://<key>@sentry.io/<project>',
environment: 'production',
release: '1.0.0',
},
},
],
};
import { SentryModule, SentryService, ServiceContainer } from '@zumito-team/sentry';
new SentryModule({
dsn: 'https://<key>@sentry.io/<project>',
environment: 'production',
});
const sentry = ServiceContainer.getService(SentryService);

After initialization, you can use the standard Sentry API anywhere:

import * as Sentry from '@sentry/node';
Sentry.captureException(new Error('Custom error'));
Sentry.captureMessage('Something happened', 'warning');

Each error reported to Sentry is enriched with:

ContextTags
Error typeerrorType (CommandRun, Api, ModuleLoad, etc.)
Commandcommand, name, type, categories
Sourcesource (slash-command / prefix-command)
Guild & channelguildId, channelId
UserDiscord user ID and username (set as Sentry user)
API errorsendpoint, method
Module errorsmodule name
Route errorsroutePath
OptionTypeRequiredDefaultDescription
dsnstringyesSentry project DSN.
environmentstringnoNODE_ENV or developmentEnvironment name in Sentry.
releasestringnoRelease version identifier.
sampleRatenumberno1.0Error sample rate (0–1).
tracesSampleRatenumbernoPerformance trace sample rate (0–1).
debugbooleannofalseEnable Sentry debug mode.

The module listens to framework.eventEmitter.on('error', ...) — an event the framework emits every time ErrorHandler.handleError() processes an error. This means all error types are covered:

  • Slash and prefix command execution errors
  • API endpoint errors
  • Module / route load failures
  • Any custom error passed through ErrorHandler
  • @sentry/node — Sentry Node.js SDK.
  • zumito-framework (peer dependency — provided by the bot host).