- Updated package dependencies to include `@sentry/node` for error tracking. - Refactored command routing to incorporate user and guild blacklisting checks, improving command execution safety. - Enhanced health server metrics to include queue waiting times, providing better insights into system performance. - Introduced confirmation handling for guild backup commands, streamlining user interactions. - Improved moderation commands with better error handling and case management, ensuring robust moderation capabilities. - Added new duration parsing functions to handle timeout durations effectively, enhancing moderation features. - Updated localization files to reflect new command structures and user guidance improvements.
37 lines
931 B
TypeScript
37 lines
931 B
TypeScript
import * as Sentry from '@sentry/node';
|
|
import { env } from './env.js';
|
|
import { logger } from './logger.js';
|
|
|
|
let initialized = false;
|
|
|
|
export function initSentry(service: 'bot-manager' | 'bot-shard' | 'webui'): void {
|
|
if (initialized || !env.SENTRY_DSN) {
|
|
return;
|
|
}
|
|
Sentry.init({
|
|
dsn: env.SENTRY_DSN,
|
|
environment: env.NODE_ENV,
|
|
release: process.env.npm_package_version
|
|
? `nexumi@${process.env.npm_package_version}`
|
|
: 'nexumi@0.1.0',
|
|
tracesSampleRate: env.NODE_ENV === 'production' ? 0.1 : 1.0,
|
|
initialScope: {
|
|
tags: { service }
|
|
}
|
|
});
|
|
initialized = true;
|
|
logger.info({ service }, 'Sentry initialized');
|
|
}
|
|
|
|
export function captureException(error: unknown, context?: Record<string, unknown>): void {
|
|
if (!env.SENTRY_DSN) {
|
|
return;
|
|
}
|
|
Sentry.withScope((scope) => {
|
|
if (context) {
|
|
scope.setExtras(context);
|
|
}
|
|
Sentry.captureException(error);
|
|
});
|
|
}
|