# django-onerror
Django ``window.onerror`` Report
## Installation
```shell
pip install django-onerror
```
## Urls.py
```python
urlpatterns = [
url(r'^e/', include('django_onerror.urls', namespace='django_onerror')),
]
```
or
```python
from django.conf.urls import include, url
from django_onerror import views as err_views
urlpatterns = [
url(r'^report', err_views.err_report, name='err_report'),
]
```
## Settings.py
```python
INSTALLED_APPS = (
...
'django_onerror',
...
)
```
## FrontEnd
```javascript
<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>
```
## Ignore
* Uncaught ReferenceError: WeixinJSBridge is not defined
* ResizeObserver loop limit exceeded
* [ResizeObserver - loop limit exceeded](https://stackoverflow.com/questions/49384120/resizeobserver-loop-limit-exceeded)
Raw data
{
"_id": null,
"home_page": "https://github.com/django-xxx/django-onerror",
"name": "django-onerror",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "Django window.onerror Report",
"author": "Hackathon",
"author_email": "kimi.huang@brightcells.com",
"download_url": "https://files.pythonhosted.org/packages/83/6b/ae98bdc06bf40e78a6f47a83dc35b55bc0df2a3b60cc365dbe497e8f3983/django-onerror-1.1.1.tar.gz",
"platform": null,
"description": "# django-onerror\nDjango ``window.onerror`` Report\n\n## Installation\n```shell\npip install django-onerror\n```\n\n## Urls.py\n```python\nurlpatterns = [\n url(r'^e/', include('django_onerror.urls', namespace='django_onerror')),\n]\n```\nor\n```python\nfrom django.conf.urls import include, url\nfrom django_onerror import views as err_views\n\nurlpatterns = [\n url(r'^report', err_views.err_report, name='err_report'),\n]\n```\n\n## Settings.py\n```python\nINSTALLED_APPS = (\n ...\n 'django_onerror',\n ...\n)\n```\n\n## FrontEnd\n```javascript\n<script>\n window.onerror = function(errorMessage, scriptURI, lineNo, columnNo, error) {\n if (['Uncaught ReferenceError: WeixinJSBridge is not defined', 'ResizeObserver loop limit exceeded'].indexOf(errorMessage) >= 0) {\n return\n }\n // \u6784\u5efa\u9519\u8bef\u5bf9\u8c61\n var errorObj = {\n href: window.location.href,\n ua: window.navigator.userAgent,\n lineNo: lineNo || 0,\n columnNo: columnNo || 0,\n scriptURI: scriptURI || null,\n errorMessage: errorMessage || null,\n stack: error && error.stack ? error.stack : null\n };\n // \u6784\u5efaHttp\u8bf7\u6c42\n if (XMLHttpRequest) {\n var xhr = new XMLHttpRequest();\n xhr.open('post', '/e/report', true);\n xhr.setRequestHeader('Content-Type', 'application/json'); // \u8bbe\u7f6e\u8bf7\u6c42\u5934\n xhr.send(JSON.stringify(errorObj)); // \u53d1\u9001\u53c2\u6570\n }\n }\n</script>\n```\n\n## Ignore\n* Uncaught ReferenceError: WeixinJSBridge is not defined\n* ResizeObserver loop limit exceeded\n * [ResizeObserver - loop limit exceeded](https://stackoverflow.com/questions/49384120/resizeobserver-loop-limit-exceeded)\n",
"bugtrack_url": null,
"license": "",
"summary": "Django ``window.onerror`` Report",
"version": "1.1.1",
"split_keywords": [
"django",
"window.onerror",
"report"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8bf2e010c58ae59b3b218b270f0e88abd5c24b3aea5c6a15124123805d980003",
"md5": "7f073ae8aeadeb016675b55d3a94a4c8",
"sha256": "7fa722aa1461d300e2bb6ddee8d62066adc92ce3aea7703886fe7024b87e16b8"
},
"downloads": -1,
"filename": "django_onerror-1.1.1-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "7f073ae8aeadeb016675b55d3a94a4c8",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 6635,
"upload_time": "2023-02-03T07:09:47",
"upload_time_iso_8601": "2023-02-03T07:09:47.115690Z",
"url": "https://files.pythonhosted.org/packages/8b/f2/e010c58ae59b3b218b270f0e88abd5c24b3aea5c6a15124123805d980003/django_onerror-1.1.1-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "836bae98bdc06bf40e78a6f47a83dc35b55bc0df2a3b60cc365dbe497e8f3983",
"md5": "09ae10317fbba3eaee8480d9759c2d46",
"sha256": "181410f826f2369c7037488a86efdad2f4e8484f7ce8ba7408bcbb6d4df1c87d"
},
"downloads": -1,
"filename": "django-onerror-1.1.1.tar.gz",
"has_sig": false,
"md5_digest": "09ae10317fbba3eaee8480d9759c2d46",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5244,
"upload_time": "2023-02-03T07:09:49",
"upload_time_iso_8601": "2023-02-03T07:09:49.263328Z",
"url": "https://files.pythonhosted.org/packages/83/6b/ae98bdc06bf40e78a6f47a83dc35b55bc0df2a3b60cc365dbe497e8f3983/django-onerror-1.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-02-03 07:09:49",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "django-xxx",
"github_project": "django-onerror",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "django-onerror"
}