插件版本 >= 0.6.1

插件版本 <= 0.5.0

  1. {
  2. error: /b is not defined/
  3. }]

filters属性有以下特点:

  • 它是一个数组,数组中的元素为过滤规则,当错误符合数组中任意一条过滤规则时,则会被过滤
  • 过滤规则是JavaScript对象,该对象的Key为错误的属性名,Value为正则表达式(唯一的特例是”inexistence”);
  • 当错误的属性匹配对应正则表达式时,则会被过滤;
  • 当过滤规则的属性值为”inexistence”时,则会过滤某个属性不存在的错误;

测试Fundebug时,在微信开发者工具的调试器中,可以在Network中看到发送到https://fundebug.com/wxjs/的网络请求,这个请求的body就是我们捕获的错误事件

  1. {
  2. "notifierVersion": "0.4.0",
  3. "systemInfo":
  4. {
  5. "errMsg": "getSystemInfo:ok",
  6. "model": "iPhone 5",
  7. "pixelRatio": 2,
  8. "windowWidth": 320,
  9. "windowHeight": 504,
  10. "system": "iOS 10.0.1",
  11. "language": "zh_CN",
  12. "version": "6.6.3",
  13. "screenWidth": 320,
  14. "screenHeight": 568,
  15. "SDKVersion": "1.9.91",
  16. "brand": "devtools",
  17. "fontSizeSetting": 16,
  18. "benchmarkLevel": 1,
  19. "batteryLevel": 100,
  20. "statusBarHeight": 20,
  21. "platform": "devtools"
  22. },
  23. "apikey": "0abbf8337ed309d1e0337ab47a4e904d2ed2a30fcc18d22efd807f190192e24c",
  24. "releaseStage": "production",
  25. "metaData":
  26. {
  27. "tier": "free"
  28. },
  29. {
  30. "type": "function",
  31. "time": 1527556801032,
  32. "belong": "App",
  33. "method": "onLaunch",
  34. "path": "pages/start/start",
  35. "query":
  36. {},
  37. },
  38. {
  39. "type": "function",
  40. "time": 1527556801328,
  41. "belong": "App",
  42. "method": "onShow",
  43. "path": "pages/start/start",
  44. "query":
  45. {},
  46. "scene": 1001
  47. }],
  48. "time": 1527556801343,
  49. "error": "thirdScriptError\nTEST 01;at App lifeCycleMethod onLaunch function\nError: TEST 01\n at e.onLaunch (http://127.0.0.1:52992/appservice/app.js:19:15)\n at e._0x4c25b0.(anonymous function) (http://127.0.0.1:52992/appservice/release/fundebug.0.3.1.min.js:192:78)\n at e.o (http://127.0.0.1:52992/appservice/__dev__/WAService.js:18:19145)\n at new e (http://127.0.0.1:52992/appservice/__dev__/WAService.js:18:20499)\n at Function.<anonymous> (http://127.0.0.1:52992/appservice/__dev__/WAService.js:18:20988)\n at http://127.0.0.1:52992/appservice/__dev__/WAService.js:17:31961\n at Object._0x27d8dc.(anonymous function) [as bipMe] (http://127.0.0.1:52992/appservice/release/fundebug.0.3.1.min.js:113:12)\n at App (http://127.0.0.1:52992/appservice/release/fundebug.0.3.1.min.js:358:37)\n at http://127.0.0.1:52992/appservice/app.js:16:1\n at require (http://127.0.0.1:52992/appservice/__dev__/WAService.js:18:26712)",
  50. "type": "uncaught",
  51. "scene": 1001
  52. };

示例1:过滤ReferenceError的错误

  1. fundebug.init(
  2. {
  3. filters: [
  4. {
  5. error: /ReferenceError/
  6. }]
  7. })

插件版本 <= 0.5.0

插件版本 >= 0.6.1

  1. fundebug.init(
  2. {
  3. filters: [
  4. {
  5. req:
  6. {
  7. url: /example\.com/,
  8. method: /^GET$/
  9. }
  10. }]
  11. })

插件版本 <= 0.5.0

  1. fundebug.filters = [
  2. req:
  3. {
  4. url: /example\.com/,
  5. method: /^GET$/
  6. }];

示例3:过滤statusCode为401的HTTP请求错误

插件版本 >= 0.6.1

  1. fundebug.init(
  2. {
  3. filters: [
  4. {
  5. res: {
  6. statusCode: /^401$/
  7. }
  8. }]
  9. })

插件版本 >= 0.6.1

  1. fundebug.init(
  2. {
  3. filters: [
  4. {
  5. error: /^ReferenceError$/,
  6. systemInfo:
  7. {
  8. "model": /^iPhone 5$/,
  9. }
  10. }]
  11. })

插件版本 <= 0.5.0

  1. fundebug.filters = [
  2. {
  3. error: /^ReferenceError$/,
  4. systemInfo:
  5. {
  6. "model": /^iPhone 5$/,
  7. }
  8. }]

示例5:配置多条过滤规则

插件版本 >= 0.6.1

  1. fundebug.init(
  2. {
  3. filters: [
  4. {
  5. scene: /^1002$/
  6. },
  7. {
  8. error: /TEST 02/,
  9. scene: /1001/
  10. }]

插件版本 <= 0.5.0