summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Godwin2022-11-20 11:18:42 -0700
committerAndrew Godwin2022-11-20 11:18:55 -0700
commit4b4032be6f984cea34aeb7a52cbfcc38bc389b35 (patch)
tree1a26fdf489ff7ccfbbc2bcd7a3cd1c60daa9bc57
parent75e73859688c8893edc2650d12b10e3005d9db76 (diff)
downloadtakahe-4b4032be6f984cea34aeb7a52cbfcc38bc389b35.tar.gz
takahe-4b4032be6f984cea34aeb7a52cbfcc38bc389b35.tar.bz2
takahe-4b4032be6f984cea34aeb7a52cbfcc38bc389b35.zip
Add Sentry error integration option
-rw-r--r--activities/admin.py6
-rw-r--r--requirements.txt1
-rw-r--r--takahe/settings/production.py14
-rw-r--r--templates/500.html6
-rw-r--r--users/admin.py6
5 files changed, 33 insertions, 0 deletions
diff --git a/activities/admin.py b/activities/admin.py
index e24304d..ba809a8 100644
--- a/activities/admin.py
+++ b/activities/admin.py
@@ -32,6 +32,12 @@ class PostAdmin(admin.ModelAdmin):
def object_json(self, instance):
return instance.to_ap()
+ def has_add_permission(self, request, obj=None):
+ """
+ Disables admin creation of posts as it will skip steps
+ """
+ return False
+
@admin.register(TimelineEvent)
class TimelineEventAdmin(admin.ModelAdmin):
diff --git a/requirements.txt b/requirements.txt
index 8eed5d8..b32f91c 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -14,3 +14,4 @@ django-htmx~=1.13.0
django-storages[google,boto3]~=1.13.1
whitenoise~=6.2.0
sphinx~=5.3.0
+sentry-sdk~=1.11.0
diff --git a/takahe/settings/production.py b/takahe/settings/production.py
index 34116af..4120217 100644
--- a/takahe/settings/production.py
+++ b/takahe/settings/production.py
@@ -77,3 +77,17 @@ STATOR_TOKEN = os.environ.get("TAKAHE_STATOR_TOKEN")
# Error email recipients
if "TAKAHE_ERROR_EMAILS" in os.environ:
ADMINS = [("Admin", e) for e in os.environ["TAKAHE_ERROR_EMAILS"].split(",")]
+
+# Sentry integration
+if "SENTRY_DSN" in os.environ:
+ import sentry_sdk
+ from sentry_sdk.integrations.django import DjangoIntegration
+
+ sentry_sdk.init(
+ dsn=os.environ["SENTRY_DSN"],
+ integrations=[
+ DjangoIntegration(),
+ ],
+ traces_sample_rate=1.0,
+ send_default_pii=True,
+ )
diff --git a/templates/500.html b/templates/500.html
new file mode 100644
index 0000000..e828f68
--- /dev/null
+++ b/templates/500.html
@@ -0,0 +1,6 @@
+{% extends "base.html" %}
+
+{% block content %}
+ <h1>Internal Server Error</h1>
+ <p>Sorry about that.</p>
+{% endblock %}
diff --git a/users/admin.py b/users/admin.py
index 0901307..7a54c52 100644
--- a/users/admin.py
+++ b/users/admin.py
@@ -44,6 +44,12 @@ class IdentityAdmin(admin.ModelAdmin):
def actor_json(self, instance):
return instance.to_ap()
+ def has_add_permission(self, request, obj=None):
+ """
+ Disables admin creation of identities as it will skip steps
+ """
+ return False
+
@admin.register(Follow)
class FollowAdmin(admin.ModelAdmin):