diff --git a/tildes/production.ini.example b/tildes/production.ini.example index 37ab06c..e805a9d 100644 --- a/tildes/production.ini.example +++ b/tildes/production.ini.example @@ -18,6 +18,9 @@ redis.sessions.timeout_trigger = 0 # set session timeout to 1 hour by default, we'll extend it when people log in redis.sessions.timeout = 3600 +# this should only be set if you have a Sentry instance you want to send errors to +sentry_dsn = https://key@sentry.io/project + sqlalchemy.url = postgresql+psycopg2://tildes:@:6432/tildes tildes.default_user_comment_label_weight = 1.0 diff --git a/tildes/tildes/__init__.py b/tildes/tildes/__init__.py index 185ff8a..a61ffd2 100644 --- a/tildes/tildes/__init__.py +++ b/tildes/tildes/__init__.py @@ -11,6 +11,8 @@ from pyramid.httpexceptions import HTTPTooManyRequests from pyramid.registry import Registry from pyramid.request import Request from redis import Redis +import sentry_sdk +from sentry_sdk.integrations.pyramid import PyramidIntegration from webassets import Bundle from tildes.lib.ratelimit import RATE_LIMITED_ACTIONS, RateLimitResult @@ -59,6 +61,9 @@ def main(global_config: Dict[str, str], **settings: str) -> PrefixMiddleware: config.add_request_method(current_listing_base_url, "current_listing_base_url") config.add_request_method(current_listing_normal_url, "current_listing_normal_url") + if settings.get("sentry_dsn"): + sentry_sdk.init(dsn=settings["sentry_dsn"], integrations=[PyramidIntegration()]) + app = config.make_wsgi_app() force_port = global_config.get("prefixmiddleware_force_port")