-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add report rrweb event data with error request
- Loading branch information
Showing
3 changed files
with
48 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,65 @@ | ||
/** | ||
* @file error event center | ||
* @author JYkid | ||
* @author JYkidrecord | ||
* @version 0.0.1-beta | ||
*/ | ||
|
||
/* eslint-disable */ | ||
import { ajax } from "./ajax"; | ||
import Wrap from "./wrap"; | ||
|
||
const wrap = new Wrap(); | ||
const getErrorData = function(err, initMonitor) { | ||
let data = wrap._getErrorMessage(err); | ||
data.record = []; | ||
|
||
let config = initMonitor._config; | ||
if (config.record) { | ||
data.record = initMonitor._getRrwebEvent(); | ||
} | ||
return data; | ||
}; | ||
|
||
// 服务端返回错误 | ||
export const getServerError = function() {}; | ||
|
||
// ajaxError | ||
export const ajaxError = function(err, config) { | ||
export const ajaxError = function(err, initMonitor) { | ||
// 处理err 上报 | ||
if (err.type === "ajaxLoad" && err.detail.status >= 400) { | ||
let data = new Wrap()._getErrorMessage(err); | ||
ajax.post(config.protocol + config.url, data, function() {}, | ||
let data = getErrorData(err, initMonitor); | ||
let config = initMonitor._config; | ||
ajax.post(config.protocol + config.url, data, function() { | ||
initMonitor._clearEvent(); | ||
}, | ||
function(error) { | ||
console.log(error); | ||
}); | ||
} | ||
} | ||
|
||
// js 抛出的错误 | ||
export const getJsError = function(err, config) { | ||
let data = new Wrap()._getErrorMessage(err); | ||
export const getJsError = function(err, initMonitor) { | ||
let data = getErrorData(err, initMonitor); | ||
let config = initMonitor._config; | ||
ajax.post(config.protocol + config.url, data, | ||
function() {}, | ||
function() { | ||
initMonitor._clearEvent(); | ||
}, | ||
function(error) { | ||
console.log(error); | ||
}); | ||
} | ||
|
||
// 资源加载错误 | ||
export const geetResourceError = function (err, config) { | ||
let data = new Wrap()._getErrorMessage(err); | ||
ajax.post(config.protocol + config.url, data, | ||
function() {}, | ||
function(error) { | ||
console.log(error); | ||
}); | ||
export const geetResourceError = function (err, initMonitor) { | ||
let data = getErrorData(err, initMonitor); | ||
let config = initMonitor._config; | ||
ajax.post(config.protocol + config.url, data, | ||
function() { | ||
initMonitor._clearEvent(); | ||
}, | ||
function(error) { | ||
console.log(error); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,7 +134,7 @@ Wrap.prototype = { | |
total++ | ||
} | ||
return stack; | ||
} | ||
}, | ||
} | ||
|
||
module.exports = Wrap; |