Skip to main content

Django ``window.onerror`` Report

Project description

Django window.onerror Report

Installation

pip install django-onerror

Urls.py

urlpatterns = [
    url(r'^e/', include('django_onerror.urls', namespace='django_onerror')),
]

or:

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) {
        // 构建错误对象
        var errorObj = {
            lineNo: lineNo || null,
            columnNo: columnNo || null,
            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>

Project details


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.0.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

django_onerror-1.0.1-py2.py3-none-any.whl (4.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-onerror-1.0.1.tar.gz.

File metadata

File hashes

Hashes for django-onerror-1.0.1.tar.gz
Algorithm Hash digest
SHA256 5dba9d4512261961ff93b432f3e541a9fad5953d01fe8e5a8e5b2c009324246b
MD5 df087a4e1898658fabb0f4db8e980434
BLAKE2b-256 6e4d33731a609848e0397f21f4d6a2586425327b3378977981318e3f39cb4408

See more details on using hashes here.

File details

Details for the file django_onerror-1.0.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_onerror-1.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1d195b38ff0300b77374069d8b939a60508b46aebc0f426ea9849e8208651951
MD5 d68decf9b49902516b71e0630f26bbee
BLAKE2b-256 bc391fa072bedd80aef22824f47e59b5e79c9cee5e3b399be3f79a454be42cf3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page