diff --git a/divent/bot.py b/divent/bot.py index 5805f78..5ae5fc7 100644 --- a/divent/bot.py +++ b/divent/bot.py @@ -4,12 +4,14 @@ from datetime import datetime, timedelta from os import environ, path from typing import List, Optional +import sentry_sdk from disnake import Client, Guild from dotenv import load_dotenv from ics import Calendar, Event # type: ignore from ics.alarm.display import DisplayAlarm # type: ignore from quart import Quart, redirect, render_template, request, session, url_for from requests_oauthlib import OAuth2Session # type: ignore +from sentry_sdk.integrations.quart import QuartIntegration load_dotenv() @@ -31,6 +33,10 @@ TOKEN_URL = API_BASE_URL + "/oauth2/token" if QUART_DEBUG: logging.basicConfig(level=logging.DEBUG) +SENTRY_DSN = environ.get("SENTRY_DSN") +if SENTRY_DSN: + sentry_sdk.init(SENTRY_DSN, integrations=[QuartIntegration()]) + class Discord(Client): async def on_ready(self): diff --git a/poetry.lock b/poetry.lock index 7339864..b26dca3 100644 --- a/poetry.lock +++ b/poetry.lock @@ -293,7 +293,7 @@ python-versions = ">=3.7,<4.0" [[package]] name = "hypercorn" -version = "0.13.2" +version = "0.14.1" description = "A ASGI Server based on Hyper libraries and inspired by Gunicorn" category = "main" optional = false @@ -307,6 +307,7 @@ toml = "*" wsproto = ">=0.14.0" [package.extras] +docs = ["pydata-sphinx-theme"] h3 = ["aioquic (>=0.9.0,<1.0)"] trio = ["trio (>=0.11.0)"] uvloop = ["uvloop"] @@ -607,6 +608,41 @@ requests = ">=2.0.0" [package.extras] rsa = ["oauthlib[signedtoken] (>=3.0.0)"] +[[package]] +name = "sentry-sdk" +version = "1.9.5" +description = "Python client for Sentry (https://sentry.io)" +category = "main" +optional = false +python-versions = "*" + +[package.dependencies] +certifi = "*" +urllib3 = [ + {version = ">=1.26.9", markers = "python_version >= \"3.5\""}, + {version = ">=1.26.11", markers = "python_version >= \"3.6\""}, +] + +[package.extras] +aiohttp = ["aiohttp (>=3.5)"] +beam = ["apache-beam (>=2.12)"] +bottle = ["bottle (>=0.12.13)"] +celery = ["celery (>=3)"] +chalice = ["chalice (>=1.16.0)"] +django = ["django (>=1.8)"] +falcon = ["falcon (>=1.4)"] +fastapi = ["fastapi (>=0.79.0)"] +flask = ["blinker (>=1.1)", "flask (>=0.11)"] +httpx = ["httpx (>=0.16.0)"] +pure_eval = ["asttokens", "executing", "pure-eval"] +pyspark = ["pyspark (>=2.4.4)"] +quart = ["blinker (>=1.1)", "quart (>=0.16.1)"] +rq = ["rq (>=0.6)"] +sanic = ["sanic (>=0.8)"] +sqlalchemy = ["sqlalchemy (>=1.2)"] +starlette = ["starlette (>=0.19.1)"] +tornado = ["tornado (>=5)"] + [[package]] name = "six" version = "1.16.0" @@ -696,7 +732,7 @@ watchdog = ["watchdog"] [[package]] name = "wsproto" -version = "1.1.0" +version = "1.2.0" description = "WebSockets state-machine based protocol implementation" category = "main" optional = false @@ -732,7 +768,7 @@ testing = ["func-timeout", "jaraco.itertools", "pytest (>=6)", "pytest-black (>= [metadata] lock-version = "1.1" python-versions = "^3.8" -content-hash = "aa6a725f039c589728fbc1b98da39e96a2ea91b94be489141b4368d16dd300ac" +content-hash = "0cea4fed56a5ddc26f0330cbd3dc2b3098770c8e0b65559289cd4d24863ab616" [metadata.files] aiofiles = [ @@ -983,8 +1019,8 @@ html-void-elements = [ {file = "html_void_elements-0.1.0-py3-none-any.whl", hash = "sha256:784cf39db03cdeb017320d9301009f8f3480f9d7b254d0974272e80e0cb5e0d2"}, ] hypercorn = [ - {file = "Hypercorn-0.13.2-py3-none-any.whl", hash = "sha256:ca18f91ab3fa823cbe9e949738f9f2cc07027cd647c80d8f93e4b1a2a175f112"}, - {file = "Hypercorn-0.13.2.tar.gz", hash = "sha256:6307be5cbdf6ba411967d4661202dc4f79bd511b5d318bc4eed88b09418427f8"}, + {file = "Hypercorn-0.14.1-py3-none-any.whl", hash = "sha256:b71b61698a9fb498564762cef0d18e52e416ab7301e2e55744c92ccaded11b2c"}, + {file = "Hypercorn-0.14.1.tar.gz", hash = "sha256:1132a64316c8c6db79b5b4f2f6be77d4d99854a6add7fcdcfc9612e728e5cf10"}, ] hyperframe = [ {file = "hyperframe-6.0.1-py3-none-any.whl", hash = "sha256:0ec6bafd80d8ad2195c4f03aacba3a8265e57bc4cff261e802bf39970ed02a15"}, @@ -1309,6 +1345,10 @@ requests-oauthlib = [ {file = "requests-oauthlib-1.3.1.tar.gz", hash = "sha256:75beac4a47881eeb94d5ea5d6ad31ef88856affe2332b9aafb52c6452ccf0d7a"}, {file = "requests_oauthlib-1.3.1-py2.py3-none-any.whl", hash = "sha256:2577c501a2fb8d05a304c09d090d6e47c306fef15809d102b327cf8364bddab5"}, ] +sentry-sdk = [ + {file = "sentry-sdk-1.9.5.tar.gz", hash = "sha256:2d7ec7bc88ebbdf2c4b6b2650b3257893d386325a96c9b723adcd31033469b63"}, + {file = "sentry_sdk-1.9.5-py2.py3-none-any.whl", hash = "sha256:b4b41f90951ed83e7b4c176eef021b19ecba39da5b73aca106c97a9b7e279a90"}, +] six = [ {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, @@ -1342,8 +1382,8 @@ werkzeug = [ {file = "Werkzeug-2.2.2.tar.gz", hash = "sha256:7ea2d48322cc7c0f8b3a215ed73eabd7b5d75d0b50e31ab006286ccff9e00b8f"}, ] wsproto = [ - {file = "wsproto-1.1.0-py3-none-any.whl", hash = "sha256:2218cb57952d90b9fca325c0dcfb08c3bda93e8fd8070b0a17f048e2e47a521b"}, - {file = "wsproto-1.1.0.tar.gz", hash = "sha256:a2e56bfd5c7cd83c1369d83b5feccd6d37798b74872866e62616e0ecf111bda8"}, + {file = "wsproto-1.2.0-py3-none-any.whl", hash = "sha256:b9acddd652b585d75b20477888c56642fdade28bdfd3579aa24a4d2c037dd736"}, + {file = "wsproto-1.2.0.tar.gz", hash = "sha256:ad565f26ecb92588a3e43bc3d96164de84cd9902482b130d0ddbaa9664a85065"}, ] yarl = [ {file = "yarl-1.8.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:abc06b97407868ef38f3d172762f4069323de52f2b70d133d096a48d72215d28"}, diff --git a/pyproject.toml b/pyproject.toml index 9bff971..536e26b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,7 @@ python-dotenv = "0.20.0" quart = "0.18.0" requests = "2.28.1" requests-oauthlib = "1.3.1" +sentry-sdk = "1.9.5" [tool.poetry.dev-dependencies] flake8 = "5.0.4"