Skip to content

Commit ba2c11a

Browse files
feat: add sentry
1 parent 36283f4 commit ba2c11a

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
django
2-
djangorestframework
2+
djangorestframework
3+
sentry-sdk==0.14.4

rtd/settings.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,21 @@
131131
'DEFAULT_RENDERER_CLASSES': (
132132
'rest_framework.renderers.JSONRenderer',
133133
)
134-
}
134+
}
135+
136+
137+
# Sentry
138+
# Enable this if on production
139+
import sentry_sdk
140+
from sentry_sdk.integrations.django import DjangoIntegration
141+
142+
SENTRY_DNS = os.environ.get('SENTRY_DNS')
143+
144+
sentry_sdk.init(
145+
dsn=SENTRY_DNS,
146+
integrations=[DjangoIntegration()],
147+
148+
# If you wish to associate users to errors (assuming you are using
149+
# django.contrib.auth) you may enable sending PII data.
150+
send_default_pii=True
151+
)

rtd/urls.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@
1616
from django.contrib import admin
1717
from django.urls import path, include
1818

19+
20+
def trigger_error(request):
21+
division_by_zero = 1 / 0
22+
1923
urlpatterns = [
24+
path('sentry-debug/', trigger_error),
2025
path('admin/', admin.site.urls),
2126
path('api/', include('api.urls')),
2227
path('', include('frontend.urls')),
28+
2329
]

0 commit comments

Comments
 (0)