Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to hide the "BugReporting extraData" in React Native? (Using Expo)

Every time I open a React Native app with Expo, I get this massive message in the console with meta data about the app, that doesn't actually do much to help me debug. Especially because it's the same info every time, and it shows up every time the app reloads (even with hot or live reloading):

Running application "main"
with appParams: {
    "rootTag": 171,
    "initialProps": {
        "exp": {
            "manifest": {
                "splash": {
                    "backgroundColor": "#1c2d3c"
                },
                "packagerOpts": {
                    "lanType": "ip",
                    "urlRandomness": "e4-nfi",
                    "hostType": "tunnel",
                    "dev": true,
                    "minify": false
                },
                "debuggerHost": "localhost:19001",
                "bundleUrl": "http://localhost:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false&assetPlugin=pathToProjectFiles",
                "facebookAppId": "FBAppIdGoesHere",
                "android": {
                    "splash": {
                        "xxhdpi": "./src/assets/img/splash-android.png",
                        "backgroundColor": "#1c2d3c",
                        "xxxhdpiUrl": "http://localhost:19001/assets/./src/assets/img/splash-android.png",
                        "xhdpi": "./src/assets/img/splash-android.png",
                        "hdpi": "./src/assets/img/splash-android.png",
                        "xxxhdpi": "./src/assets/img/splash-android.png",
                        "resizeMode": "cover",
                        "ldpi": "./src/assets/img/splash-android.png",
                        "xxhdpiUrl": "http://localhost:19001/assets/./src/assets/img/splash-android.png",
                        "ldpiUrl": "http://localhost:19001/assets/./src/assets/img/splash-android.png",
                        "xhdpiUrl": "http://localhost:19001/assets/./src/assets/img/splash-android.png",
                        "hdpiUrl": "http://localhost:19001/assets/./src/assets/img/splash-android.png",
                        "mdpi": "./src/assets/img/splash-android.png",
                        "mdpiUrl": "http://localhost:19001/assets/./src/assets/img/splash-android.png"
                    },
                    "config": {
                        "googleSignIn": {
                            "apiKey": "APIKeyGoesHere",
                            "certificateHash": "HashGoesHere"
                        }
                    },
                    "iconUrl": "http://localhost:19001/assets/./src/assets/img/icon-android.png",
                    "package": "com.organizationName.apps",
                    "permissions": ["CAMERA", "INTERNET", "LOCATION", "READ_EXTERNAL_STORAGE", "READ_INTERNAL_STORAGE", "WRITE_EXTERNAL_STORAGE", "com.anddoes.launcher.permission.UPDATE_COUNT", "com.android.launcher.permission.INSTALL_SHORTCUT", "com.google.android.c2dm.permission.RECEIVE", "com.google.android.gms.permission.ACTIVITY_RECOGNITION", "com.google.android.providers.gsf.permission.READ_GSERVICES", "com.htc.launcher.permission.READ_SETTINGS", "com.htc.launcher.permission.UPDATE_SHORTCUT", "com.majeur.launcher.permission.UPDATE_BADGE", "com.sec.android.provider.badge.permission.READ", "com.sec.android.provider.badge.permission.WRITE", "com.sonyericsson.home.permission.BROADCAST_BADGE"],
                    "icon": "./src/assets/img/icon-android.png",
                    "versionCode": 10
                },
                "slug": "app-name-goes-here",
                "facebookDisplayName": "NameOfApp",
                "icon": "./src/assets/img/icon-android.png",
                "primaryColor": "#cccccc",
                "isVerified": true,
                "version": "1.1.5",
                "xde": true,
                "name": "NameOfApp",
                "facebookScheme": "SomeFBSchemeCodeGoesHere",
                "iconUrl": "http://localhost:19001/assets/./src/assets/img/icon-android.png",
                "id": "@jhwheeler/name-of-app",
                "hostUri": "localhost:19000",
                "orientation": "portrait",
                "sdkVersion": "27.0.0",
                "env": {},
                "hooks": {
                    "postPublish": [{
                        "config": {
                            "organization": "organizationNameHere",
                            "project": "projectNameHere",
                            "authToken": "authTokenGoesHere"
                        },
                        "file": "sentry-expo/upload-sourcemaps"
                    }]
                },
                "loadedFromCache": false,
                "ios": {
                    "splash": {
                        "resizeMode": "cover",
                        "imageUrl": "http://localhost:19001/assets/./src/assets/img/splash-ios.png",
                        "backgroundColor": "#1c2d3c",
                        "image": "./src/assets/img/splash-ios.png"
                    },
                    "supportsTablet": false,
                    "iconUrl": "http://localhost:19001/assets/./src/assets/img/icon-ios.png",
                    "infoPlist": {
                        "NSLocationAlwaysUsageDescription": "Nice message goes here",
                        "NSLocationWhenInUseUsageDescription": "Nice message goes here"
                    },
                    "bundleIdentifier": "com.orgName.apps",
                    "buildNumber": "1",
                    "icon": "./src/assets/img/icon-ios.png"
                },
                "logUrl": "http://localhost:19000/logs",
                "privacy": "unlisted",
                "mainModuleName": "node_modules/expo/AppEntry",
                "developer": {
                    "projectRoot": "/path/to/project",
                    "tool": "xde"
                },
                "description": "descriptionOfApp"
            },
            "appOwnership": "expo",
            "initialUri": "exp://localhost:19000",
            "shell": 0
        }
    }
}.__DEV__ === true, development - level warning are ON, performance optimizations are OFF

If I'm looking at the Expo console, it is prefaced with BugReporting extraData: and wraps the above in a JS object. I don't know if this is unique to Expo or a React Native message, but either way:

Is there any way to get rid of this message? It's so large that it makes finding actual errors much more laborious.

like image 662
Alacritas Avatar asked Jul 26 '18 13:07

Alacritas


2 Answers

I solved a similar problem by adding to the project root:

const ignoreConsoleMessages = [
  'Running "main" with'
]
const origLog = console.log
console.log = (...params) => (
  typeof params[0] === 'string' &&
  ignoreConsoleMessages.reduce((acc, i) => acc + ~params[0].indexOf(i), 0)
    ? null
    : origLog(...params)
)
like image 55
Hoxz Avatar answered Nov 09 '22 20:11

Hoxz


I'm not familiar with Expo, but I encountered this log message recently with a vanilla RN project. I was able to remove it by adding the following to my index file:

   console.ignoredYellowBox = ['react-native BugReporting extraData:'];
like image 1
Shaun Saker Avatar answered Nov 09 '22 18:11

Shaun Saker