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

Uploaded Source

Built Distribution

django_onerror-1.0.5-py2.py3-none-any.whl (5.7 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: django-onerror-1.0.5.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.19.8 CPython/2.7.12+

File hashes

Hashes for django-onerror-1.0.5.tar.gz
Algorithm Hash digest
SHA256 40753d16fd23119a04a05fe1600724677ca9124d9e95e5861e7e4b2af268e1ed
MD5 a70bdfecddd7776bf4f3c9814b1f9f62
BLAKE2b-256 d024f63cf5927d09b0d08a74097a8b9824a26ba0a527eb04086294cb9240e20d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_onerror-1.0.5-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.19.8 CPython/2.7.12+

File hashes

Hashes for django_onerror-1.0.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 28fe8ae1779404702f95dd16675db951e9ec76850b1d3be0a0606ec9e242e7eb
MD5 8eec68c9c8953dac0a77206123a82141
BLAKE2b-256 d47fdfad8a0fc4383cc15dcdc246ec1383d424c2a3f081e88a03d11cc7865cee

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