Skip to content

Commit

Permalink
Add Sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
connorhsm committed Dec 8, 2024
1 parent 33f40a8 commit 9c133c0
Show file tree
Hide file tree
Showing 7 changed files with 807 additions and 699 deletions.
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ python-dateutil = "*"
requests = "*"
inflect = "*"
pandas = "*"
sentry-sdk = "*"

[dev-packages]
black = "*"
Expand Down
1,468 changes: 776 additions & 692 deletions Pipfile.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dictator/cogs/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

from discord.ext import commands, tasks

from get_version import get_dictator_version
from open_collective import ForecastOpenCollective
from constants import (
STATS_CHANNEL_ID,
OC_CHANNEL_ID,
OC_FORECAST_MONTH_DAY,
MOD_ROLE_ID,
PLAYER_LIST_PASSWORD,
DICTATOR_VERSION,
)

import socket
Expand Down Expand Up @@ -58,7 +58,7 @@ async def update_stats(self) -> None:
name=f"Families", value=f"{family_count} total\n{families}", inline=False
)
embed.set_footer(
text=f"Server v{server_info[1]} • Dictator v{get_dictator_version()}"
text=f"Server v{server_info[1]} • Dictator v{DICTATOR_VERSION}"
)
await self.stats_message.edit(embed=embed)

Expand Down
5 changes: 2 additions & 3 deletions dictator/cogs/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
from discord import app_commands
from discord.ext import commands

from constants import MOD_ROLE_ID, OC_CHANNEL_ID
from get_version import get_dictator_version
from constants import MOD_ROLE_ID, OC_CHANNEL_ID, DICTATOR_VERSION

import random

Expand Down Expand Up @@ -40,7 +39,7 @@ async def ping(self, interaction: discord.Interaction) -> None:
@app_commands.command()
async def version(self, interaction: discord.Interaction) -> None:
"""Check the current version of Dictator."""
await interaction.response.send_message(get_dictator_version(), ephemeral=True)
await interaction.response.send_message(DICTATOR_VERSION, ephemeral=True)

@commands.guild_only()
@commands.has_role(MOD_ROLE_ID)
Expand Down
5 changes: 5 additions & 0 deletions dictator/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
from dotenv import load_dotenv
from get_version import get_dictator_version

load_dotenv()

Expand All @@ -10,6 +11,7 @@
PLAYER_LIST_PASSWORD = os.environ["PLAYER_LIST_PASSWORD"]

# Optional environment variables, setting defaults
DICTATOR_VERSION = os.environ.get("DICTATOR_VERSION", get_dictator_version())
BOT_PREFIX = os.environ.get("BOT_PREFIX", "-")

MOD_ROLE_ID = int(os.environ.get("MOD_ROLE_ID", 578867113817800715))
Expand All @@ -36,3 +38,6 @@

# Day of the month to generate and send the forecast message
OC_FORECAST_MONTH_DAY = int(os.environ.get("OC_FORECAST_MONTH_DAY", 7))

SENTRY_DSN = os.environ.get("SENTRY_DSN", "https://d273912626b930e863089cd16baff50f@o4508150301065216.ingest.us.sentry.io/4508430421262336")
SENTRY_ENVIRONMENT = os.environ.get("SENTRY_ENVIRONMENT", "dev")
19 changes: 17 additions & 2 deletions dictator/dictator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
import os
from discord.ext import commands
import sentry_sdk
import discord
from constants import BOT_PREFIX, BOT_TOKEN
from discord.ext import commands

from constants import (
BOT_PREFIX,
BOT_TOKEN,
SENTRY_DSN,
SENTRY_ENVIRONMENT,
DICTATOR_VERSION,
)


sentry_sdk.init(
dsn=SENTRY_DSN,
environment=SENTRY_ENVIRONMENT,
release=DICTATOR_VERSION,
)


class Dictator(commands.Bot):
Expand Down
4 changes: 4 additions & 0 deletions example.env
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ PLAYER_LIST_PASSWORD=
# All optional variables have sufficient defaults set in dictator/constants.py
###

#DICTATOR_VERSION
#BOT_PREFIX=

#MOD_ROLE_ID=
Expand All @@ -31,3 +32,6 @@ PLAYER_LIST_PASSWORD=
#OC_GRAPHQL_ENDPOINT=
#OC_ANALYSIS_PERIOD_MONTHS=
#OC_FORECAST_MONTH_DAY=

#SENTRY_DSN=
#SENTRY_ENVIRONMENT=

0 comments on commit 9c133c0

Please sign in to comment.