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

Uploaded Source

Built Distribution

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

File metadata

  • Download URL: django-onerror-1.0.6.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.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.6.tar.gz
Algorithm Hash digest
SHA256 d8d81b1bd8a901d88a6e56852ceeaa45ce8aed46201580ca60d0c1947c2c03a3
MD5 cc2186d383eabfac5b377f5ebc32fc59
BLAKE2b-256 16be51753c888b847dd43d6d5c000959bb75a62fc0cea3a484161ac698052c6e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_onerror-1.0.6-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.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.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 91d9723e51e65295ee20e12333337da2647d004cfeb01e7c370a86a3640bdfc3
MD5 30d977724d6daf279a0ef5e2755e94b7
BLAKE2b-256 04ff04760394a7360e735b4b9a2426427e018281d1085e828d6a23f9e3ce1559

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