baodz-network-logger-debug-controller
v0.1.1
Published
React Native network logger debug controller with a shake-toggle floating button.
Maintainers
Readme
baodz-network-logger-debug-controller
React Native controller for react-native-network-logger. It starts request capture, shows a native floating button with the total request count and a flying +1 animation when a request starts, toggles the button with a device shake, and opens a full-screen request viewer.
Install
npm install baodz-network-logger-debug-controller react-native-network-logger react-native-safe-area-context
cd ios && pod installThe package autolinks its iOS and Android native modules. It requires React Native 0.73 or later and React 18 or later. The native module uses React Native's classic bridge; the two IVIE projects currently have the New Architecture disabled.
Use
Mount one controller under SafeAreaProvider, near the app root:
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { NetworkLoggerDebugController } from 'baodz-network-logger-debug-controller';
function App() {
return (
<SafeAreaProvider>
<NetworkLoggerDebugController enabled={__DEV__} />
{/* The rest of the app */}
</SafeAreaProvider>
);
}The controller starts request capture when enabled. To start capture earlier from the app entry point, call startNetworkLogger directly; it is safe to call more than once:
import { startNetworkLogger } from 'baodz-network-logger-debug-controller';
startNetworkLogger({ enabled: __DEV__, maxRequests: 200 });On Android, the floating button uses the system “Display over other apps” permission. Request it from a user action before mounting the controller:
import { requestOverlayPermission } from 'baodz-network-logger-debug-controller';
await requestOverlayPermission();The library manifest declares SYSTEM_ALERT_WINDOW; the user still needs to grant the special permission in Android Settings. iOS does not require this permission.
API
NetworkLoggerDebugController: propsenabled(defaulttrue),maxRequests(default200), andmaxRows(default200).startNetworkLogger({ enabled, maxRequests }): starts capture once and returns whether it started.stopNetworkLogger(): stops capture and returns whether it stopped.hasOverlayPermission(): checks Android overlay access; resolvestrueon iOS.requestOverlayPermission(): opens the Android overlay permission settings; resolvestrueon iOS.
Publish
From the package directory, authenticate to the intended npm registry and publish the version in package.json:
npm login
npm publishThe package name is unscoped, so the registry must allow publishing baodz-network-logger-debug-controller. The podspec is intended for React Native autolinking from the installed npm package; add a repository s.source if you later want to distribute this as a standalone CocoaPods pod.
The package metadata is marked UNLICENSED because no distribution license was specified. Set the intended license before publishing it to a public registry.
