Skip to content

Commit

Permalink
[Closes #237] Integrate Sentry.io error reporting (#245)
Browse files Browse the repository at this point in the history
* #237 Sentry server side install and basic init

* Format/lint

* Conditionally init Sentry SDK

* Testing printing DSN

* Don't set an invalid SENTRY_DSN

* remove debugging printf

* Remove Sentry note from README- not needed for development

---------

Co-authored-by: Jimmi <[email protected]>
Co-authored-by: Francis Li <[email protected]>
  • Loading branch information
3 people authored Jan 23, 2025
1 parent 0429ee3 commit 26542c3
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 3 deletions.
1 change: 1 addition & 0 deletions example.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ DEBUG=1
SECRET_KEY=q!=ahgtraat*k4ytuniq)0892h7j5^2koqp55mh6p18$4344ks
TIME_ZONE=America/Los_Angeles
DEPLOY_ENV=development
SENTRY_DSN=
63 changes: 60 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 17 additions & 0 deletions server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand Down

0 comments on commit 26542c3

Please sign in to comment.