diff --git a/src/discord/events/error.ts b/src/discord/events/error.ts index beac8f367..3ce2f3d83 100644 --- a/src/discord/events/error.ts +++ b/src/discord/events/error.ts @@ -7,7 +7,7 @@ import { MessageContextMenuCommandInteraction, UserContextMenuCommandInteraction, } from 'discord.js'; -import * as Sentry from '@sentry/node'; +// import * as Sentry from '@sentry/node'; import { ErrorEvent } from '../@types/eventDef'; const F = f(__filename); @@ -51,41 +51,41 @@ export default async function handleError( const embed = new EmbedBuilder() .setColor(Colors.Red); - if (interaction) { - // log.debug(F, 'Interaction found, sending error to GlitchTip'); - Sentry.captureException(errorData, { - tags: { - command: commandName, - context: await commandContext(interaction), - }, - user: { - id: interaction.user.id, - username: interaction.user.username, - }, - }); - } else { - // log.debug(F, 'No interaction, sending error to GlitchTip'); - Sentry.captureException(errorData); - } + // if (interaction) { + // // log.debug(F, 'Interaction found, sending error to GlitchTip'); + // Sentry.captureException(errorData, { + // tags: { + // command: commandName, + // context: await commandContext(interaction), + // }, + // user: { + // id: interaction.user.id, + // username: interaction.user.username, + // }, + // }); + // } else { + // // log.debug(F, 'No interaction, sending error to GlitchTip'); + // Sentry.captureException(errorData); + // } // If this is production, send a message to the channel and alert the developers if (env.NODE_ENV === 'production') { - if (interaction) { - // log.debug(F, 'Interaction found, sending error to rollbar'); - global.rollbar.error(errorStack, { - tags: { - command: commandName, - context: await commandContext(interaction), - }, - user: { - id: interaction.user.id, - username: interaction.user.username, - }, - }); - } else { - // log.debug(F, 'No interaction, sending error to rollbar'); - global.rollbar.error(errorStack); - } + // if (interaction) { + // // log.debug(F, 'Interaction found, sending error to rollbar'); + // global.rollbar.error(errorStack, { + // tags: { + // command: commandName, + // context: await commandContext(interaction), + // }, + // user: { + // id: interaction.user.id, + // username: interaction.user.username, + // }, + // }); + // } else { + // // log.debug(F, 'No interaction, sending error to rollbar'); + // global.rollbar.error(errorStack); + // } // Get channel we send errors to const channel = await discordClient.channels.fetch(env.CHANNEL_BOTERRORS) as TextChannel; diff --git a/src/global/utils/log.ts b/src/global/utils/log.ts index a3d379d14..a10b4eea3 100644 --- a/src/global/utils/log.ts +++ b/src/global/utils/log.ts @@ -9,12 +9,22 @@ import { // import { Logtail } from '@logtail/node'; // eslint-disable-line // import { LogtailTransport } from '@logtail/winston'; // eslint-disable-line import Rollbar, { Level } from 'rollbar'; -// import * as Sentry from '@sentry/node'; // eslint-disable-line // import SentryTransport from 'winston-transport-sentry-node'; // eslint-disable-line +import * as Sentry from '@sentry/node'; import { env } from './env.config'; const RollbarTransport = require('winston-transport-rollbar-3'); +// Setup Rollbar +const rollbarConfig = { + accessToken: env.ROLLBAR_TOKEN, + captureUncaught: true, + captureUnhandledRejections: true, + logLevel: 'error' as Level, +}; + +global.rollbar = new Rollbar(rollbarConfig); + const { combine, splat, @@ -61,15 +71,7 @@ const myFormat = printf(({ return msg; }); -const rollbarConfig = { - accessToken: env.ROLLBAR_TOKEN, - captureUncaught: true, - captureUnhandledRejections: true, - logLevel: 'error' as Level, -}; - -global.rollbar = new Rollbar(rollbarConfig); - +// Old sentry stuff // const sentryConfig = { // dsn: env.SENTRY_TOKEN, // debug: true, // Enable debug mode to log internal transactions @@ -119,10 +121,16 @@ const transportOptions = [ new transports.Console(), ]; -// We only want logtail logs in production +// We only want rollbar logs in production // let transportOptions = []; if (env.NODE_ENV === 'production') { transportOptions.push(new RollbarTransport({ rollbarConfig })); + // Setup glitchTip + Sentry.init({ + dsn: env.GLITCHTIP_DSN, + // debug: true, + environment: env.NODE_ENV, + }); } const logger = createLogger({ diff --git a/src/start.ts b/src/start.ts index 0133ce7e9..7efe7c257 100755 --- a/src/start.ts +++ b/src/start.ts @@ -13,7 +13,6 @@ import { import * as path from 'path'; import Canvas from '@napi-rs/canvas'; import { PrismaClient } from '@prisma/client'; -import * as Sentry from '@sentry/node'; import { env } from './global/utils/env.config'; import { log } from './global/utils/log'; import validateEnv from './global/utils/env.validate'; // eslint-disable-line @@ -46,12 +45,6 @@ async function start() { log.info(F, 'Initializing service!'); if (validateEnv('SERVICES')) { api(); - Sentry.init({ - dsn: env.GLITCHTIP_DSN, - // debug: true, - environment: env.NODE_ENV, - }); - global.db = new PrismaClient({ log: ['error'] }); await updateDb(); if (env.DISCORD_CLIENT_TOKEN && validateEnv('DISCORD')) await discordConnect();