diff --git a/example.env b/example.env index f38633e..0494691 100644 --- a/example.env +++ b/example.env @@ -4,3 +4,4 @@ DEBUG=1 SECRET_KEY=q!=ahgtraat*k4ytuniq)0892h7j5^2koqp55mh6p18$4344ks TIME_ZONE=America/Los_Angeles DEPLOY_ENV=development +SENTRY_DSN= diff --git a/poetry.lock b/poetry.lock index 174d185..0727ffc 100644 --- a/poetry.lock +++ b/poetry.lock @@ -81,7 +81,7 @@ version = "2024.8.30" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.6" -groups = ["dev"] +groups = ["main", "dev"] files = [ {file = "certifi-2024.8.30-py3-none-any.whl", hash = "sha256:922820b53db7a7257ffbda3f597266d435245903d80737e34f8a45ff3e3230d8"}, {file = "certifi-2024.8.30.tar.gz", hash = "sha256:bec941d2aa8195e248a60b31ff9f0558284cf01a52591ceda73ea9afffd69fd9"}, @@ -755,6 +755,63 @@ urllib3 = ">=1.21.1,<3" socks = ["PySocks (>=1.5.6,!=1.5.7)"] use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] +[[package]] +name = "sentry-sdk" +version = "2.20.0" +description = "Python client for Sentry (https://sentry.io)" +optional = false +python-versions = ">=3.6" +groups = ["main"] +files = [ + {file = "sentry_sdk-2.20.0-py2.py3-none-any.whl", hash = "sha256:c359a1edf950eb5e80cffd7d9111f3dbeef57994cb4415df37d39fda2cf22364"}, + {file = "sentry_sdk-2.20.0.tar.gz", hash = "sha256:afa82713a92facf847df3c6f63cec71eb488d826a50965def3d7722aa6f0fdab"}, +] + +[package.dependencies] +certifi = "*" +django = {version = ">=1.8", optional = true, markers = "extra == \"django\""} +urllib3 = ">=1.26.11" + +[package.extras] +aiohttp = ["aiohttp (>=3.5)"] +anthropic = ["anthropic (>=0.16)"] +arq = ["arq (>=0.23)"] +asyncpg = ["asyncpg (>=0.23)"] +beam = ["apache-beam (>=2.12)"] +bottle = ["bottle (>=0.12.13)"] +celery = ["celery (>=3)"] +celery-redbeat = ["celery-redbeat (>=2)"] +chalice = ["chalice (>=1.16.0)"] +clickhouse-driver = ["clickhouse-driver (>=0.2.0)"] +django = ["django (>=1.8)"] +falcon = ["falcon (>=1.4)"] +fastapi = ["fastapi (>=0.79.0)"] +flask = ["blinker (>=1.1)", "flask (>=0.11)", "markupsafe"] +grpcio = ["grpcio (>=1.21.1)", "protobuf (>=3.8.0)"] +http2 = ["httpcore[http2] (==1.*)"] +httpx = ["httpx (>=0.16.0)"] +huey = ["huey (>=2)"] +huggingface-hub = ["huggingface_hub (>=0.22)"] +langchain = ["langchain (>=0.0.210)"] +launchdarkly = ["launchdarkly-server-sdk (>=9.8.0)"] +litestar = ["litestar (>=2.0.0)"] +loguru = ["loguru (>=0.5)"] +openai = ["openai (>=1.0.0)", "tiktoken (>=0.3.0)"] +openfeature = ["openfeature-sdk (>=0.7.1)"] +opentelemetry = ["opentelemetry-distro (>=0.35b0)"] +opentelemetry-experimental = ["opentelemetry-distro"] +pure-eval = ["asttokens", "executing", "pure_eval"] +pymongo = ["pymongo (>=3.1)"] +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)"] +starlite = ["starlite (>=1.48)"] +tornado = ["tornado (>=6)"] +unleash = ["UnleashClient (>=6.0.1)"] + [[package]] name = "six" version = "1.17.0" @@ -814,7 +871,7 @@ version = "2.2.3" description = "HTTP library with thread-safe connection pooling, file post, and more." optional = false python-versions = ">=3.8" -groups = ["dev"] +groups = ["main", "dev"] files = [ {file = "urllib3-2.2.3-py3-none-any.whl", hash = "sha256:ca899ca043dcb1bafa3e262d73aa25c465bfb49e0bd9dd5d59f1d0acba2f8fac"}, {file = "urllib3-2.2.3.tar.gz", hash = "sha256:e7d814a81dad81e6caf2ec9fdedb284ecc9c73076b62654547cc64ccdcae26e9"}, @@ -855,4 +912,4 @@ brotli = ["brotli"] [metadata] lock-version = "2.1" python-versions = "^3.13.1" -content-hash = "3a006b567ae24a88cc4a04ef5965e4639d9ab8d58ce27d2d98331282b3732c2f" +content-hash = "ce53fec39f53b0951d878338e28f01e150f17f5f66514be695d82ac83a8390f1" diff --git a/pyproject.toml b/pyproject.toml index c21ff92..a78b732 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,7 @@ whitenoise = "^6.8.2" uuid = "^1.30" django-postgres-setfield = {git = "https://github.com/benperlman/django-postgres-setfield.git"} djangorestframework = "^3.14.0" +sentry-sdk = {extras = ["django"], version = "^2.14.0"} [tool.poetry.group.dev.dependencies] autoflake = "^2.3.1" diff --git a/server/settings.py b/server/settings.py index cbeedaa..0f94cbe 100644 --- a/server/settings.py +++ b/server/settings.py @@ -16,12 +16,29 @@ import dj_database_url from dotenv import find_dotenv, load_dotenv +import sentry_sdk + load_dotenv(find_dotenv()) # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = Path(__file__).resolve().parent.parent PROJECT_ROOT = BASE_DIR +# Initialize Sentry SDK if DSN is set +SENTRY_DSN = os.getenv("SENTRY_DSN") +if SENTRY_DSN: + sentry_sdk.init( + # SECURITY WARNING: keep the Sentry DSN secret! + dsn=SENTRY_DSN, + # Set traces_sample_rate to 1.0 to capture 100% + # of transactions for tracing. + traces_sample_rate=1.0, + # Set profiles_sample_rate to 1.0 to profile 100% + # of sampled transactions. + # We recommend adjusting this value in production. + profiles_sample_rate=1.0, + ) + # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/