• 使用方法配置(推荐)
  • 通过fundebug配置
  1. fundebug.filters = [
  2. {
  3. message: /^Script error\.$/
  4. }
  5. ];
  6. }
  • 它是一个数组,数组中的元素为过滤规则,当错误符合数组中任意一条过滤规则时,则会被过滤
  • 当错误的属性匹配对应正则表达式时,则会被过滤;
  • 当过滤规则的属性值为”inexistence”时,则会过滤某个属性不存在的错误;

示例 1:过滤 name 为 ReferenceError 的错误

  1. fundebug.filters = [
  2. {
  3. name: /^ReferenceError$/
  4. }
  5. ];

示例 2:过滤 name 为 ReferenceError,且 message 中含 aler 的错误

  1. fundebug.filters = [
  2. {
  3. req: {
  4. method: /^GET$/
  5. },
  6. status: /^401$/
  7. }
  8. }
  9. ];

示例 4:过滤特定域名的资源加载错误

  1. fundebug.filters = [
  2. {
  3. target: {
  4. src: /example.com/
  5. }
  6. ];

示例 5:过滤 status 不存在的图片加载错误

  1. fundebug.filters = [
  2. {
  3. message: /^Script error\.$/
  4. },
  5. {
  6. method: /^GET$/
  7. },
  8. res: {
  9. status: /^401$/
  10. }
  11. }
  12. ];

示例 7:只监控特定域名的报错

  1. fundebug.filters = [
  2. {
  3. url: /^((?!(a\.com|b\.com)).)*$/
  4. }
  5. ];

Script error.

  1. fundebug.filters = [
  2. {
  3. message: /WeixinJSBridge is not defined/