我的JS代码让它工作是
<script src="/assets/js/jquery.min.js"></script>
<script src="https://cdn.ravenjs.com/3.26.4/raven.min.js" crossorigin="anonymous"></script>
<script type="text/javascript">
$(window).load(function (argument) {
Raven.config('https://xxxxxxxxxxxxxxxxxxxxxxxx@sentry.io/xxxxxx').install();
});
</script>
但它不会向哨兵发送控制台错误
<script src="/assets/js/jquery.min.js"></script>
<script src="https://cdn.ravenjs.com/3.26.4/raven.min.js" crossorigin="anonymous"></script>
<script type="text/javascript">
$(window).load(function (argument) {
Raven.config('https://xxxxxxxxxxxxxxxxxxxxxxxx@sentry.io/xxxxxx').install();
Raven.captureException("catch error");
});
</script>
将catch error
送到哨兵 还尝试手动捕获错误并将其发送给也不起作用的哨兵
<script type="text/javascript">
$(window).load(function (argument) {
Raven.config('https://d28cbc1dcf354e91aefb0bc3480dd7d4@sentry.io/1214721').install();
});
window.onerror = function(message, source, lineno, colno, error) {
Raven.captureException(error);
return false;
}
</script>
我错过了什么?
删除$(window).load(function (argument) {});
对我有用。只需将Raven.config('https://d28cbc1dcf354e91aefb0bc3480dd7d4@sentry.io/1214721').install();
直接放在文件之后jquery.js