Skip to content

Instantly share code, notes, and snippets.

@mjumbewu
Created April 7, 2016 20:36
Show Gist options
  • Save mjumbewu/7399a09dc8fdd913c85922219e52757d to your computer and use it in GitHub Desktop.
Save mjumbewu/7399a09dc8fdd913c85922219e52757d to your computer and use it in GitHub Desktop.
JS Sentry Config in a Django template
{% if settings.SENTRY_DSN %}
<script src="https://cdn.ravenjs.com/2.2.0/raven.min.js"></script>
<script>Raven.config('{{ settings.SENTRY_DSN }}').install()</script>
<script>
$(document).ajaxError(function(event, jqXHR, ajaxSettings, thrownError) {
Raven.captureMessage('Ajax: (' + jqXHR.status + ') "' + thrownError || jqXHR.statusText + '" at ' + ajaxSettings.url, {
extra: {
type: ajaxSettings.type,
url: ajaxSettings.url,
data: ajaxSettings.data,
status: jqXHR.status,
error: thrownError || jqXHR.statusText,
response: jqXHR.responseText.substring(0, 2048)
}
});
});
</script>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment