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 || 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>

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

Uploaded Source

Built Distribution

django_onerror-1.0.7-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.7.tar.gz.

File metadata

  • Download URL: django-onerror-1.0.7.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 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.7.tar.gz
Algorithm Hash digest
SHA256 c47ceb77686f1c198e3414fec39940d204001ca55ee8ad7ef7de58846ba3479f
MD5 fbf5baa1bfe0f9c5f89eb2137254435b
BLAKE2b-256 32cc571ac90b48a4e0e2faaf508c2a7b9a361796ee50ce9b564f723c04881e1c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_onerror-1.0.7-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.12.1 pkginfo/1.4.2 requests/2.20.0 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.7-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1c9b14cd0fe7a4ba6fdce9ddda1a5877d32bc9c7f3b8bace53b3a44352b27be6
MD5 ee979138df7a5eb4ffae639859e5526e
BLAKE2b-256 5bbf241f788a0da66082cc43b5890bbcdcf76ccc73e3898b28eaf908ebb55630

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