Send the request URL to Sentry

Also removed some dead code.
This commit is contained in:
Sybren A. Stüvel 2018-09-05 14:54:30 +02:00
parent 2ad5b20880
commit 5e07cfb9b2

View File

@ -1,3 +1,5 @@
import flask
import raven.breadcrumbs
from raven.contrib.flask import Sentry from raven.contrib.flask import Sentry
from .auth import current_user from .auth import current_user
@ -14,16 +16,14 @@ class PillarSentry(Sentry):
def init_app(self, app, *args, **kwargs): def init_app(self, app, *args, **kwargs):
super().init_app(app, *args, **kwargs) super().init_app(app, *args, **kwargs)
# We perform authentication of the user while handling the request, flask.request_started.connect(self.__add_sentry_breadcrumbs, self)
# so Sentry calls get_user_info() too early.
def get_user_context_again(self, ): def __add_sentry_breadcrumbs(self, sender, **extra):
from flask import request raven.breadcrumbs.record(
message='Request started',
try: category='http',
self.client.user_context(self.get_user_info(request)) data={'url': flask.request.url}
except Exception as e: )
self.client.logger.exception(str(e))
def get_user_info(self, request): def get_user_info(self, request):
user_info = super().get_user_info(request) user_info = super().get_user_info(request)