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

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

Uploaded Source

Built Distribution

django_onerror-1.0.8-py2.py3-none-any.whl (6.4 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: django-onerror-1.0.8.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/18.5 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.10

File hashes

Hashes for django-onerror-1.0.8.tar.gz
Algorithm Hash digest
SHA256 ec0154d5fc3e1e2af0bd2f378183050170ac35db38a809c48eefc1c4d264d2e6
MD5 d9bc7e6304d2dff32c073cf6a0c02980
BLAKE2b-256 a66feb38ec08e23dfe417039c7cb9cd5942d6aba8f8b8dff3c6ded164f39d21a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_onerror-1.0.8-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/18.5 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.10

File hashes

Hashes for django_onerror-1.0.8-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 fd93daee70c5cd42dabe8a314d89071ee3711d8d233d83ccbdf7afff8fd1cedb
MD5 4f7ad892b91a6f7b88f46c14b3f46775
BLAKE2b-256 dad9745283cb95d32d41c932736df0965154bb5adb8a8afc8084462cfa2a2ec1

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