捕获所有JavaScript错误并将其发送到服务器

时间:2022-10-28 14:56:37

I wondered if anyone had experience in handling JavaScript errors globally and send them from the client browser to a server.

我想知道是否有人在全球处理JavaScript错误并将其从客户机浏览器发送到服务器。

I think my point is quite clear, I want to know every exception, error, compilation error, etc. that happens on the client side and send them to the server to report them.

我想我的观点很清楚,我想知道客户端发生的每一个异常、错误、编译错误等等,然后将它们发送到服务器报告。

I’m mainly using MooTools and head.js (for the JS side) and Django for the server side.

我主要用情绪工具和头脑。js(用于js端)和Django用于服务器端。

6 个解决方案

#1


15  

I recently tested Sentry on production and it works fine (JS and other languages like PHP)

我最近在产品上测试了哨兵,它工作得很好(JS和其他语言,比如PHP)

1- It's open source (You can install it on your own server) 2- You can use the free plan (100 reports / day)

1-它是开源的(你可以在自己的服务器上安装它)2-你可以使用免费的计划(100个报告/天)

Or install it on ur server : https://github.com/getsentry

或者将它安装到您的服务器:https://github.com/getsentry

#2


286  

I'd check out window.onerror

我看看window.onerror

Example:

例子:

window.onerror = function(message, url, lineNumber) {  
  //save error and send to server for example.
  return true;
};  

Keep in mind that returning true will prevent the firing of the default handler, and returning false will let the default handler run.

请记住,返回true将防止触发默认处理程序,返回false将让默认处理程序运行。

#3


3  

Also, the http://jslogger.com service can help with that:

此外,http://jslogger.com服务也可以帮助实现这一点:

Log Javascript errors and events in the cloud

记录云中的Javascript错误和事件

from http://jslogger.com/features :

从http://jslogger.com/features:

From now on you can spy on all the errors that break your site's user experience. Every Javascript error will be caught and brought to you for later debuging.

从现在开始,你可以监视所有破坏你网站用户体验的错误。每个Javascript错误都将被捕获并提交给您以供以后调试。

DISCLAIMER: not affiliated with the service/company.

免责声明:不隶属于本服务/公司。

#4


2  

You can try Atatus - It is a new JavaScript Error Tracking Service along with Real User Monitoring (RUM) for modern web apps.

您可以尝试Atatus——它是一个新的JavaScript错误跟踪服务,以及现代web应用程序的真实用户监控(RUM)。

We don’t just capture the errors, but also the user events that triggered the error. This gives you steps to reproduce the error at your end.

我们不仅要捕获错误,还要捕获触发错误的用户事件。这将为您在结束时重现错误提供步骤。

Alongside error capturing, we also capture the page load time and showing it across different perspectives - Geo, Browser, Page Drill Down, Page Histogram, Ajax Monitoring and Transaction Monitoring.

除了错误捕获之外,我们还捕获页面加载时间,并在不同的视角(Geo、浏览器、页面向下挖掘、页面直方图、Ajax监视和事务监视)显示它。

https://www.atatus.com/

https://www.atatus.com/

Docs available: https://www.atatus.com/docs

文档:https://www.atatus.com/docs

Disclaimer: I am a web developer at Atatus.

免责声明:我是Atatus的web开发人员。

#5


0  

You might wanna check out this new service, http://rescuejs.com/.

您可能想要查看这个新服务http://rescue ejs.com/。

Lets you log all your javascript errors without writing server side code yourself. It also tracks browser versions and so on.

允许您在不编写服务器端代码的情况下记录所有javascript错误。它还跟踪浏览器版本等等。

I'm not sure I would consider them 100% "enterprise ready", but it's definitely worth checking out.

我不确定我是否会认为它们是100%的“企业准备”,但它绝对值得一看。

#6


0  

If have Google Analytics on your website, you can use it to log Javascript errors for free: https://developers.google.com/analytics/devguides/collection/analyticsjs/exceptions

如果您的网站上有谷歌分析,您可以使用它免费记录Javascript错误:https://developers.google.com/analytics/devguides/collection/analyticsjs/exception

Either use it with try...catch like in the example, or wire it up with window.onerror.

或者用它来尝试……在示例中捕获,或者使用window.onerror将其连接起来。

#1


15  

I recently tested Sentry on production and it works fine (JS and other languages like PHP)

我最近在产品上测试了哨兵,它工作得很好(JS和其他语言,比如PHP)

1- It's open source (You can install it on your own server) 2- You can use the free plan (100 reports / day)

1-它是开源的(你可以在自己的服务器上安装它)2-你可以使用免费的计划(100个报告/天)

Or install it on ur server : https://github.com/getsentry

或者将它安装到您的服务器:https://github.com/getsentry

#2


286  

I'd check out window.onerror

我看看window.onerror

Example:

例子:

window.onerror = function(message, url, lineNumber) {  
  //save error and send to server for example.
  return true;
};  

Keep in mind that returning true will prevent the firing of the default handler, and returning false will let the default handler run.

请记住,返回true将防止触发默认处理程序,返回false将让默认处理程序运行。

#3


3  

Also, the http://jslogger.com service can help with that:

此外,http://jslogger.com服务也可以帮助实现这一点:

Log Javascript errors and events in the cloud

记录云中的Javascript错误和事件

from http://jslogger.com/features :

从http://jslogger.com/features:

From now on you can spy on all the errors that break your site's user experience. Every Javascript error will be caught and brought to you for later debuging.

从现在开始,你可以监视所有破坏你网站用户体验的错误。每个Javascript错误都将被捕获并提交给您以供以后调试。

DISCLAIMER: not affiliated with the service/company.

免责声明:不隶属于本服务/公司。

#4


2  

You can try Atatus - It is a new JavaScript Error Tracking Service along with Real User Monitoring (RUM) for modern web apps.

您可以尝试Atatus——它是一个新的JavaScript错误跟踪服务,以及现代web应用程序的真实用户监控(RUM)。

We don’t just capture the errors, but also the user events that triggered the error. This gives you steps to reproduce the error at your end.

我们不仅要捕获错误,还要捕获触发错误的用户事件。这将为您在结束时重现错误提供步骤。

Alongside error capturing, we also capture the page load time and showing it across different perspectives - Geo, Browser, Page Drill Down, Page Histogram, Ajax Monitoring and Transaction Monitoring.

除了错误捕获之外,我们还捕获页面加载时间,并在不同的视角(Geo、浏览器、页面向下挖掘、页面直方图、Ajax监视和事务监视)显示它。

https://www.atatus.com/

https://www.atatus.com/

Docs available: https://www.atatus.com/docs

文档:https://www.atatus.com/docs

Disclaimer: I am a web developer at Atatus.

免责声明:我是Atatus的web开发人员。

#5


0  

You might wanna check out this new service, http://rescuejs.com/.

您可能想要查看这个新服务http://rescue ejs.com/。

Lets you log all your javascript errors without writing server side code yourself. It also tracks browser versions and so on.

允许您在不编写服务器端代码的情况下记录所有javascript错误。它还跟踪浏览器版本等等。

I'm not sure I would consider them 100% "enterprise ready", but it's definitely worth checking out.

我不确定我是否会认为它们是100%的“企业准备”,但它绝对值得一看。

#6


0  

If have Google Analytics on your website, you can use it to log Javascript errors for free: https://developers.google.com/analytics/devguides/collection/analyticsjs/exceptions

如果您的网站上有谷歌分析,您可以使用它免费记录Javascript错误:https://developers.google.com/analytics/devguides/collection/analyticsjs/exception

Either use it with try...catch like in the example, or wire it up with window.onerror.

或者用它来尝试……在示例中捕获,或者使用window.onerror将其连接起来。