diff --git a/packages/react-native/ReactCommon/jsinspector-modern/network/CMakeLists.txt b/packages/react-native/ReactCommon/jsinspector-modern/network/CMakeLists.txt index 67017852a2f..1749a26b3e0 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/network/CMakeLists.txt +++ b/packages/react-native/ReactCommon/jsinspector-modern/network/CMakeLists.txt @@ -23,6 +23,5 @@ target_include_directories(jsinspector_network PUBLIC ${REACT_COMMON_DIR}) target_link_libraries(jsinspector_network folly_runtime - glog jsinspector_cdp ) diff --git a/packages/react-native/ReactCommon/jsinspector-modern/network/NetworkReporter.cpp b/packages/react-native/ReactCommon/jsinspector-modern/network/NetworkReporter.cpp index a3e0ee29c5b..44e49417ece 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/network/NetworkReporter.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/network/NetworkReporter.cpp @@ -7,16 +7,23 @@ #include "NetworkReporter.h" +#ifdef REACT_NATIVE_DEBUGGER_ENABLED #include "CdpNetwork.h" +#endif +#ifdef REACT_NATIVE_DEBUGGER_ENABLED #include #include +#endif +#ifdef REACT_NATIVE_DEBUGGER_ENABLED #include +#endif #include namespace facebook::react::jsinspector_modern { +#ifdef REACT_NATIVE_DEBUGGER_ENABLED namespace { /** @@ -34,6 +41,7 @@ double getCurrentUnixTimestampSeconds() { } } // namespace +#endif NetworkReporter& NetworkReporter::getInstance() { static NetworkReporter instance; @@ -67,6 +75,8 @@ void NetworkReporter::reportRequestStart( const RequestInfo& requestInfo, int encodedDataLength, const std::optional& redirectResponse) const { +#ifdef REACT_NATIVE_DEBUGGER_ENABLED + // Debug build: CDP event handling if (!isDebuggingEnabledNoSync()) { return; } @@ -94,32 +104,41 @@ void NetworkReporter::reportRequestStart( frontendChannel_( cdp::jsonNotification("Network.requestWillBeSent", params.toDynamic())); +#endif } void NetworkReporter::reportConnectionTiming( const std::string& /*requestId*/) const { +#ifdef REACT_NATIVE_DEBUGGER_ENABLED + // Debug build: CDP event handling if (!isDebuggingEnabledNoSync()) { return; } // TODO(T218236597) throw std::runtime_error("Not implemented"); +#endif } void NetworkReporter::reportRequestFailed( const std::string& /*requestId*/) const { +#ifdef REACT_NATIVE_DEBUGGER_ENABLED + // Debug build: CDP event handling if (!isDebuggingEnabledNoSync()) { return; } // TODO(T218236855) throw std::runtime_error("Not implemented"); +#endif } void NetworkReporter::reportResponseStart( const std::string& requestId, const ResponseInfo& responseInfo, int encodedDataLength) const { +#ifdef REACT_NATIVE_DEBUGGER_ENABLED + // Debug build: CDP event handling if (!isDebuggingEnabledNoSync()) { return; } @@ -137,21 +156,27 @@ void NetworkReporter::reportResponseStart( frontendChannel_( cdp::jsonNotification("Network.responseReceived", params.toDynamic())); +#endif } void NetworkReporter::reportDataReceived( const std::string& /*requestId*/) const { +#ifdef REACT_NATIVE_DEBUGGER_ENABLED + // Debug build: CDP event handling if (!isDebuggingEnabledNoSync()) { return; } // TODO(T218236266) throw std::runtime_error("Not implemented"); +#endif } void NetworkReporter::reportResponseEnd( const std::string& requestId, int encodedDataLength) const { +#ifdef REACT_NATIVE_DEBUGGER_ENABLED + // Debug build: CDP event handling if (!isDebuggingEnabledNoSync()) { return; } @@ -164,6 +189,7 @@ void NetworkReporter::reportResponseEnd( frontendChannel_( cdp::jsonNotification("Network.loadingFinished", params.toDynamic())); +#endif } } // namespace facebook::react::jsinspector_modern diff --git a/packages/react-native/ReactCommon/jsinspector-modern/network/NetworkReporter.h b/packages/react-native/ReactCommon/jsinspector-modern/network/NetworkReporter.h index fc8c4d6f69c..c6d281e15c7 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/network/NetworkReporter.h +++ b/packages/react-native/ReactCommon/jsinspector-modern/network/NetworkReporter.h @@ -25,6 +25,8 @@ using FrontendChannel = std::function; /** * [Experimental] An interface for reporting network events to the modern * debugger server and Web Performance APIs. + * + * In a production (non dev or profiling) build, CDP reporting is disabled. */ class NetworkReporter { public: