Django ``window.onerror`` Report
Project description
django-onerror
Django window.onerror
Report
Installation
pip install django-onerror
Urls.py
urlpatterns = [
url(r'^e/', include('django_onerror.urls', namespace='django_onerror')),
]
or
from django.conf.urls import include, url
from django_onerror import views as err_views
urlpatterns = [
url(r'^report', err_views.err_report, name='err_report'),
]
Settings.py
INSTALLED_APPS = (
...
'django_onerror',
...
)
FrontEnd
<script>
window.onerror = function(errorMessage, scriptURI, lineNo, columnNo, error) {
if (['Uncaught ReferenceError: WeixinJSBridge is not defined', 'ResizeObserver loop limit exceeded'].indexOf(errorMessage) >= 0) {
return
}
// 构建错误对象
var errorObj = {
href: window.location.href,
ua: window.navigator.userAgent,
lineNo: lineNo || 0,
columnNo: columnNo || 0,
scriptURI: scriptURI || null,
errorMessage: errorMessage || null,
stack: error && error.stack ? error.stack : null
};
// 构建Http请求
if (XMLHttpRequest) {
var xhr = new XMLHttpRequest();
xhr.open('post', '/e/report', true);
xhr.setRequestHeader('Content-Type', 'application/json'); // 设置请求头
xhr.send(JSON.stringify(errorObj)); // 发送参数
}
}
</script>
Ignore
- Uncaught ReferenceError: WeixinJSBridge is not defined
- ResizeObserver loop limit exceeded
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-onerror-1.1.1.tar.gz
(5.2 kB
view hashes)
Built Distribution
Close
Hashes for django_onerror-1.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fa722aa1461d300e2bb6ddee8d62066adc92ce3aea7703886fe7024b87e16b8 |
|
MD5 | 7f073ae8aeadeb016675b55d3a94a4c8 |
|
BLAKE2b-256 | 8bf2e010c58ae59b3b218b270f0e88abd5c24b3aea5c6a15124123805d980003 |