diff --git a/src/backend/app/config.py b/src/backend/app/config.py index 634bb3387c..5189f8c3c7 100644 --- a/src/backend/app/config.py +++ b/src/backend/app/config.py @@ -114,6 +114,8 @@ def assemble_db_connection(cls, v: str, values: dict[str, Any]) -> Any: OSM_SECRET_KEY: str OAUTHLIB_INSECURE_TRANSPORT: Optional[str] = 1 + SENTRY_DSN: Optional[str] + class Config: """Pydantic settings config.""" diff --git a/src/backend/app/main.py b/src/backend/app/main.py index 75787ddb8d..acb30f7c73 100644 --- a/src/backend/app/main.py +++ b/src/backend/app/main.py @@ -23,6 +23,7 @@ import sys from typing import Union +import sentry_sdk from fastapi import FastAPI, Request from fastapi.exceptions import RequestValidationError from fastapi.middleware.cors import CORSMiddleware @@ -34,12 +35,12 @@ from .central import central_routes from .config import settings from .db.database import Base, engine, get_db +from .organization import organization_routes from .projects import project_routes from .projects.project_crud import read_xlsforms from .submission import submission_routes from .tasks import tasks_routes from .users import user_routes -from .organization import organization_routes # Env variables os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = settings.OAUTHLIB_INSECURE_TRANSPORT @@ -58,6 +59,12 @@ logger = logging.getLogger(__name__) +sentry_sdk.init( + dsn=settings.SENTRY_DSN, + traces_sample_rate=0.1, +) + + def get_application() -> FastAPI: """Get the FastAPI app instance, with settings.""" _app = FastAPI( diff --git a/src/backend/pdm.lock b/src/backend/pdm.lock index 2dd94ffb91..99369c7726 100644 --- a/src/backend/pdm.lock +++ b/src/backend/pdm.lock @@ -1,3 +1,6 @@ +# This file is @generated by PDM. +# It is not intended for manual editing. + [[package]] name = "alembic" version = "1.8.1" @@ -717,6 +720,15 @@ version = "1.5.2" requires_python = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" summary = "QR Code and Micro QR Code generator for Python 2 and Python 3" +[[package]] +name = "sentry-sdk" +version = "1.9.6" +summary = "Python client for Sentry (https://sentry.io)" +dependencies = [ + "certifi", + "urllib3>=1.26.11; python_version >= \"3.6\"", +] + [[package]] name = "shapely" version = "2.0.1" @@ -897,7 +909,7 @@ summary = "Backport of pathlib-compatible object wrapper for zip files" lock_version = "4.2" cross_platform = true groups = ["default", "dev"] -content_hash = "sha256:f7aa374b3d8f41551fba6e5884a090347089de18d25f9136b2f31880f3f4ad77" +content_hash = "sha256:1fc6cfe35039ddc838a4e1a087b2136c3af90b31e2debc1cd7a6292f4fdc3f19" [metadata.files] "alembic 1.8.1" = [ @@ -1887,6 +1899,10 @@ content_hash = "sha256:f7aa374b3d8f41551fba6e5884a090347089de18d25f9136b2f31880f {url = "https://files.pythonhosted.org/packages/10/57/bef22e1ec64200bd5887c6012221e018fc1f2a25697a7f90f661b9689c00/segno-1.5.2-py2.py3-none-any.whl", hash = "sha256:b17ace8171aad3987e01bb4aeadf7e0450c40674024c4c57b4da54028e55f1e9"}, {url = "https://files.pythonhosted.org/packages/90/2a/2fedf1023f9273d8326362df7936748ebadef92ba53ab7970d9b8df1a6c2/segno-1.5.2.tar.gz", hash = "sha256:983424b296e62189d70fc73460cd946cf56dcbe82b9bda18c066fc1b24371cdc"}, ] +"sentry-sdk 1.9.6" = [ + {url = "https://files.pythonhosted.org/packages/0a/3d/4ef597b13bf0a4b373b9f4a28f6bef9639fcf3ea620206a6037a4698aa2e/sentry_sdk-1.9.6-py2.py3-none-any.whl", hash = "sha256:630faec958e09b1151d88b8655bb749274c6b1acd19baa6f7a5ec3106276f752"}, + {url = "https://files.pythonhosted.org/packages/c4/d1/1649fbbf654d9caeef95bfe2578509e2ca9d2921d7ed3d0b2701e071b1d5/sentry-sdk-1.9.6.tar.gz", hash = "sha256:f713f33ff7f82658c30e7e8cdec72c432218e6dd41b0f004905733793bd9719b"}, +] "shapely 2.0.1" = [ {url = "https://files.pythonhosted.org/packages/04/67/05e96af1c4ee130e12ac228da1ab86f7581809d8f008aa3a9ec19ea22eb2/shapely-2.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:70a18fc7d6418e5aea76ac55dce33f98e75bd413c6eb39cfed6a1ba36469d7d4"}, {url = "https://files.pythonhosted.org/packages/0e/da/055d5b854a9a702fed0965d37754b79967ecfd67fe8377264e6a00b521ea/shapely-2.0.1-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c43755d2c46b75a7b74ac6226d2cc9fa2a76c3263c5ae70c195c6fb4e7b08e79"}, diff --git a/src/backend/pyproject.toml b/src/backend/pyproject.toml index f035bfae61..33cf2b7189 100644 --- a/src/backend/pyproject.toml +++ b/src/backend/pyproject.toml @@ -47,6 +47,7 @@ dependencies = [ "bcrypt==4.0.1", "segno==1.5.2", "osm-fieldwork==0.3.2", + "sentry-sdk==1.9.6" ] requires-python = ">=3.10" readme = "../../README.md"