filters

通过配置filters属性,用户可以过滤掉一些不需要捕获的错误,例如:

  1. fundebug.init(
  2. {
  3. filters: [
  4. {
  5. message: /b is not defined/
  6. }]
  7. })

配置规则

filters属性有以下特点:

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

错误事件示例:

  1. {
  2. "notifierVersion": "0.0.0",
  3. "apikey": "e9c3a22f94a5f757b4608edd2e87f3ae085a447ee2bde4d1446aa9871ea3ac95",
  4. "appVersion": "0.1.0",
  5. "releaseStage": "development",
  6. "metaData": {
  7. "name": "test"
  8. },
  9. "breadcrumbs": [
  10. {
  11. "type": "console",
  12. "time": 1531293322820,
  13. "method": "log",
  14. "args": {
  15. "0": "Running application \"main\" with appParams: {\"rootTag\":1,\"initialProps\":{\"exp\":{\"manifest\":{\"description\":\"This project is really great.\",\"developer\":{\"projectRoot\":\"/Users/kiwenlau/Desktop/Fundebug/reactnative-notifier\",\"tool\":\"xde\"},\"loadedFromCache\":false,\"orientation\":\"portrait\",\"env\":{},\"platforms\":[\"ios\",\"android\"],\"xde\":true,\"id\":\"@kiwenlau/reactnative-notifier\",\"hostUri\":\"localhost:19000\",\"iconUrl\":\"http://localhost:19001/assets/./assets/icon.png\",\"assetBundlePatterns\":[\"**/*\"],\"mainModuleName\":\"node_modules/expo/AppEntry\",\"sdkVersion\":\"28.0.0\",\"isVerified\":true,\"packagerOpts\":{\"lanType\":\"ip\",\"dev\":true,\"minify\":false,\"urlRandomness\":\"3p-hmx\",\"hostType\":\"tunnel\"},\"ios\":{\"supportsTablet\":true},\"updates\":{\"fallbackToCacheTimeout\":0},\"bundleUrl\":\"http://localhost:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false&assetPlugin=%2FUsers%2Fkiwenlau%2FDesktop%2FFundebug%2Freactnative-notifier%2Fnode_modules%2Fexpo%2Ftools%2FhashAssetFiles\",\"version\":\"1.0.0\",\"debuggerHost\":\"localhost:19001\",\"icon\":\"./assets/icon.png\",\"slug\":\"reactnative-notifier\",\"name\":\"reactnative-notifier\",\"privacy\":\"public\",\"logUrl\":\"http://localhost:19000/logs\",\"splash\":{\"resizeMode\":\"contain\",\"image\":\"./assets/splash.png\",\"backgroundColor\":\"#ffffff\",\"imageUrl\":\"http://localhost:19001/assets/./assets/splash.png\"}},\"initialUri\":\"exp://localhost:19000\",\"appOwnership\":\"expo\",\"shell\":0}}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF"
  16. }
  17. }
  18. ],
  19. "time": 1531293323868,
  20. "type": "uncaught",
  21. "name": "TypeError",
  22. "message": "undefined is not an object (evaluating 'b.c')",
  23. "line": 115833,
  24. "column": 34,
  25. "stack": "http://localhost:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false&assetPlugin=%2FUsers%2Fkiwenlau%2FDesktop%2FFundebug%2Freactnative-notifier%2Fnode_modules%2Fexpo%2Ftools%2FhashAssetFiles:115833:34\n_callTimer@http://localhost:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false&assetPlugin=%2FUsers%2Fkiwenlau%2FDesktop%2FFundebug%2Freactnative-notifier%2Fnode_modules%2Fexpo%2Ftools%2FhashAssetFiles:3115:17\ncallTimers@http://localhost:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false&assetPlugin=%2FUsers%2Fkiwenlau%2FDesktop%2FFundebug%2Freactnative-notifier%2Fnode_modules%2Fexpo%2Ftools%2FhashAssetFiles:3322:19\n__callFunction@http://localhost:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false&assetPlugin=%2FUsers%2Fkiwenlau%2FDesktop%2FFundebug%2Freactnative-notifier%2Fnode_modules%2Fexpo%2Ftools%2FhashAssetFiles:2726:49\nhttp://localhost:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false&assetPlugin=%2FUsers%2Fkiwenlau%2FDesktop%2FFundebug%2Freactnative-notifier%2Fnode_modules%2Fexpo%2Ftools%2FhashAssetFiles:2496:31\n__guardSafe@http://localhost:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false&assetPlugin=%2FUsers%2Fkiwenlau%2FDesktop%2FFundebug%2Freactnative-notifier%2Fnode_modules%2Fexpo%2Ftools%2FhashAssetFiles:2688:13\ncallFunctionReturnFlushedQueue@http://localhost:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false&assetPlugin=%2FUsers%2Fkiwenlau%2FDesktop%2FFundebug%2Freactnative-notifier%2Fnode_modules%2Fexpo%2Ftools%2FhashAssetFiles:2495:21\ncallFunctionReturnFlushedQueue@[native code]",
  26. "sourceURL": "http://localhost:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false&assetPlugin=%2FUsers%2Fkiwenlau%2FDesktop%2FFundebug%2Freactnative-notifier%2Fnode_modules%2Fexpo%2Ftools%2FhashAssetFiles",
  27. "isFatal": true
  28. }

示例1:过滤TypError

  1. fundebug.init(
  2. {
  3. filters: [
  4. {
  5. name: /^TypeError$/
  6. }]
  7. })

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

  1. fundebug.init(
  2. {
  3. filters: [
  4. {
  5. name: /^ReferenceError$/
  6. },
  7. {
  8. name: /^TypeError$/
  9. message: /b\.c/
  10. }]
  11. })