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) {
        if (['Uncaught ReferenceError: WeixinJSBridge is not defined', 'ResizeObserver loop limit exceeded'].indexOf(errorMessage) >= 0) {
            return
        }
        // 构建错误对象
        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.1.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distributions

django_onerror-1.1.0-py3.11.egg (14.7 kB view details)

Uploaded Source

django_onerror-1.1.0-py2.py3-none-any.whl (6.5 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

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

File hashes

Hashes for django-onerror-1.1.0.tar.gz
Algorithm Hash digest
SHA256 c9606dc2d0ea8844806b89c20dad563e3c144aa18b735bf03b0c099d15ffdb89
MD5 629c8e83123672a37ac16d8c8cfaf44e
BLAKE2b-256 9c05d318f3951cf2a9de3a53450453b45bc925bf26e5629ed14816fe3136f637

See more details on using hashes here.

Provenance

File details

Details for the file django_onerror-1.1.0-py3.11.egg.

File metadata

  • Download URL: django_onerror-1.1.0-py3.11.egg
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for django_onerror-1.1.0-py3.11.egg
Algorithm Hash digest
SHA256 5ad32126435fdcf7e5a1cf8b99bdbaa32faffd8321699ec291845c866b4376c7
MD5 88c44a5482033545cfad83d42f3f16a9
BLAKE2b-256 289d4f4515f2f7ded6f52eaca2b35e77fb95cd0511cfd2d57081280fa7a73148

See more details on using hashes here.

Provenance

File details

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

File metadata

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

File hashes

Hashes for django_onerror-1.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e407a6462cecd6325b69eeca812269abee9f0de2b1909fbe845b09e5170de285
MD5 593d0f8b8634f2970f4033fdb32e138c
BLAKE2b-256 8ab167d0ae8e49573766cebe52ab925e0b20a0a932a2701cbf4ca51145c99a98

See more details on using hashes here.

Provenance

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