diff --git a/CHANGES.txt b/CHANGES.txt index fb97446..4acf480 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,7 @@ +0.4.2 +==================== +* Updated sentry-js config to use Sentry.onLoad. + 0.4.1 (2024-10-11) ==================== * Updated sentry JS config to use username instead of id. diff --git a/ctlsettings/templates/ctlsettings/sentry_js.html b/ctlsettings/templates/ctlsettings/sentry_js.html index c92e469..5699037 100644 --- a/ctlsettings/templates/ctlsettings/sentry_js.html +++ b/ctlsettings/templates/ctlsettings/sentry_js.html @@ -6,17 +6,21 @@ environment: '{{ ENVIRONMENT }}' }); - {% if request.user.is_anonymous %} - Sentry.setUser({ - email: 'none', - username: 'anonymous' - }); - {% else %} - Sentry.setUser({ - email: '{{ request.user.email }}', - username: '{{ request.user.username }}' + Sentry.onLoad(function() { + const client = Sentry.getClient(); + + {% if request.user.is_anonymous %} + client.setUser({ + email: 'none', + username: 'anonymous' + }); + {% else %} + client.setUser({ + email: '{{ request.user.email }}', + username: '{{ request.user.username }}' + }); + {% endif %} }); - {% endif %} };