Add user id to sentry logs

This commit is contained in:
Ramon Wenger 2021-03-18 14:31:46 +01:00
parent bfc2ccdf8e
commit 8189e05b0d
1 changed files with 17 additions and 0 deletions

View File

@ -318,6 +318,23 @@ LOGGING = {
}
}
if not DEBUG and os.environ.get('SENTRY_DSN'):
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
def before_send(event, hint):
user = event['user']
id = user['id']
event['user'] = {'id': id}
return event
sentry_sdk.init(
dsn=os.environ.get('SENTRY_DSN'),
integrations=[DjangoIntegration()],
send_default_pii=True,
before_send=before_send
)
if not DEBUG and os.environ.get('SENTRY_DSN'):
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration