Skip to content

Commit

Permalink
🔊(dashboard) add Sentry integration
Browse files Browse the repository at this point in the history
Sentry integration to enable error tracking and performance monitoring
- install Sentry SDK and DjangoIntegration to Sentry.
- add Sentry configuration (in settings).
- add `SENTRY_DSN` to .env
  • Loading branch information
ssorin committed Dec 13, 2024
1 parent 1c1ad0b commit 3de40fb
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 3 deletions.
13 changes: 11 additions & 2 deletions env.d/dashboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
PORT=8000

# django
DASHBOARD_DEBUG=1
DASHBOARD_ALLOWED_HOSTS=*
DASHBOARD_SECRET_KEY=the_secret_key

# database
DASHBOARD_DB_NAME=qualicharge-dashboard
DASHBOARD_DATABASE_URL=psql://qualicharge:pass@postgresql:5432/qualicharge-dashboard
DASHBOARD_DEBUG=1
DASHBOARD_SECRET_KEY=the_secret_key

# tools
DASHBOARD_SENTRY_DSN=

# superuser
DJANGO_SUPERUSER_PASSWORD=admin
DJANGO_SUPERUSER_USERNAME=admin
[email protected]
1 change: 1 addition & 0 deletions src/dashboard/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to
- add dashboard homepage
- add consent form to manage consents of one or many entities
- integration of custom 403, 404 and 500 pages
- sentry integration

[unreleased]: https://github.com/MTES-MCT/qualicharge/compare/main...bootstrap-dashboard-project

1 change: 1 addition & 0 deletions src/dashboard/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ django-environ = "==0.11.2"
django-extensions = "==3.2.3"
gunicorn = "==23.0.0"
psycopg = {extras = ["pool", "binary"], version = "==3.2.3"}
sentry-sdk = {extras = ["django"], version = "==2.19.2"}
whitenoise = "==6.8.2"

[dev-packages]
Expand Down
13 changes: 12 additions & 1 deletion src/dashboard/Pipfile.lock

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

16 changes: 16 additions & 0 deletions src/dashboard/dashboard/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
from pathlib import Path

import environ
import sentry_sdk
from django.utils.translation import gettext_lazy as _
from sentry_sdk.integrations.django import DjangoIntegration

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
Expand All @@ -21,6 +23,7 @@
env = environ.Env(
DASHBOARD_DEBUG=(bool, False),
DASHBOARD_ALLOWED_HOSTS=(list, ["localhost"]),
DASHBOARD_SENTRY_DSN=(str, ""),
)
env.prefix = "DASHBOARD_"

Expand Down Expand Up @@ -153,3 +156,16 @@
LOGOUT_REDIRECT_URL = "/"

AUTH_USER_MODEL = "qcd_auth.DashboardUser"

# Sentry
sentry_sdk.init(
dsn=env.str("SENTRY_DSN"),
integrations=[DjangoIntegration()],
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
# We recommend adjusting this value in production.
traces_sample_rate=1.0,
# If you wish to associate users to errors (assuming you are using
# django.contrib.auth) you may enable sending PII data.
send_default_pii=True,
)

0 comments on commit 3de40fb

Please sign in to comment.