feat(shard): 🔊 Set up sentry (GlitchTip).

This commit is contained in:
2025-03-16 02:18:52 -03:00
parent 1d2b065111
commit ac53c42452
4 changed files with 90 additions and 9 deletions
+23
View File
@@ -2,6 +2,8 @@ from typing import Literal
from datetime import datetime, timezone
import sys
import discord
from discord.ext import commands
from discord.ext.commands import errors
@@ -10,6 +12,8 @@ from tortoise import expressions
import redis.asyncio as redis
import sentry_sdk
from payphone.db import setup, models
from payphone.core import constants, logging, exceptions, formatting, help_command
@@ -57,6 +61,8 @@ class Payphone(commands.AutoShardedBot):
self.log.info("Ready! Logged in as %s.", self.user.display_name)
raise Exception("HEYYY")
async def set_presence(self, shard_id: int) -> None:
"""Sets the presence of the bot back to online.
@@ -380,8 +386,12 @@ class Payphone(commands.AutoShardedBot):
return
else:
sentry_sdk.capture_exception(exception)
return await super().on_command_error(context, exception)
async def on_error(self, *args, **kwargs):
sentry_sdk.capture_exception(sys.exc_info())
@property
def embed_author(self) -> discord.EmbedAuthor:
"""The author of the embeds."""
@@ -440,6 +450,19 @@ class Payphone(commands.AutoShardedBot):
def run():
"""Runs the bot."""
sentry_sdk.init(
constants.SENTRY_DSN,
environment="development" if constants.IS_DEBUG else "production",
debug=constants.IS_DEBUG,
server_name=f"Shard #{constants.SHARD_ID + 1}",
attach_stacktrace=True,
send_default_pii=True,
enable_tracing=True,
traces_sample_rate=1.0,
profiles_sample_rate=1.0,
release=constants.VERSION,
)
bot = Payphone()
try:
+13 -1
View File
@@ -1,5 +1,7 @@
import os
import toml
try:
import dotenv
@@ -23,7 +25,7 @@ SHARD_COUNT = int(os.getenv("SHARD_COUNT", "1"))
REDIS_HOST = os.getenv("REDIS_HOST", "localhost")
REDIS_PORT = int(os.getenv("REDIS_PORT", "6379"))
INVISIBLE_CHARACTER = "\u200B"
INVISIBLE_CHARACTER = "\u200b"
BRAILE_CHARACTER = "\u2800"
PRIMARY_COLOR = 0xE2D9D0
@@ -32,3 +34,13 @@ MODERATOR_COLOR = 0xFF8787
MASK_COLOR = 0xFFC868
DISCORD_SERVER_INVITE = "https://discord.gg/fKuZty23pm"
SENTRY_DSN = os.getenv(
"SENTRY_DSN", "https://[email protected]/67"
)
VERSION = None
with open("pyproject.toml", "r", encoding="UTF-8") as f:
data = toml.load(f)
VERSION = "v" + data["project"]["version"].split(".")[1]