Quick Start¶
This document provides the shortest path to integrate the React Native RUM SDK, helping you complete a verifiable data report with minimal steps.
Prerequisites¶
Before starting, please complete the following preparations:
- Create React Native Android and React Native iOS applications in RUM respectively, and obtain the corresponding
App ID. - Confirm the reporting address and authentication method:
- Local environment deployment: Prepare
datakitUrl. - Public DataWay: Prepare
datawayUrlandclientToken. - Install
@cloudcare/react-native-mobilein your project. - If you need to collect Android native startup, network request, or WebView data, please also configure the Android
ft-plugin.
Integration Steps¶
- Install the React Native SDK.
- Initialize
FTMobileConfigwhen the application starts. - Initialize
FTRUMConfigand pass in the Android and iOSApp ID. - Optional: Initialize
FTLogConfigandFTTraceConfig. - Enable debug logs, run the application, and trigger a page open, click, or network request.
- Confirm in the console and the Guance platform that the data has been successfully reported.
Install SDK¶
For installation methods, please refer directly to Application Access.
Minimal Initialization Example¶
import {
FTMobileReactNative,
FTReactNativeRUM,
FTMobileConfig,
FTRUMConfig,
ErrorMonitorType,
DeviceMetricsMonitorType,
DetectFrequency,
} from '@cloudcare/react-native-mobile';
async function sdkInit() {
// For local environment deployment, use { datakitUrl: 'http://10.0.0.1:9529' }
const config: FTMobileConfig = {
datawayUrl: 'https://open.dataway.url',
clientToken: 'client_token',
debug: true,
};
await FTMobileReactNative.sdkConfig(config);
const rumConfig: FTRUMConfig = {
androidAppId: 'android_app_id',
iOSAppId: 'ios_app_id',
enableAutoTrackUserAction: true,
enableAutoTrackError: true,
enableNativeUserResource: true,
};
await FTReactNativeRUM.setConfig(rumConfig);
}
Please complete SDK initialization before registering the App in the top-level
index.jsto ensure initialization is complete before calling other SDK methods.
import App from './App';
async function initSDK() {
await sdkInit();
}
initSDK();
AppRegistry.registerComponent('main', () => App);
Optional: Initialize Log and Trace¶
import {
FTReactNativeLog,
FTReactNativeTrace,
FTLogConfig,
FTTraceConfig,
} from '@cloudcare/react-native-mobile';
async function setupExtraModules() {
const logConfig: FTLogConfig = {
enableCustomLog: true,
enableLinkRumData: true,
};
await FTReactNativeLog.logConfig(logConfig);
const traceConfig: FTTraceConfig = {
enableNativeAutoTrace: true,
};
await FTReactNativeTrace.setConfig(traceConfig);
}
Verify Integration Success¶
- Keep
debug: trueenabled and run the application. - Open a page, click a button, or initiate a network request.
- Check the debug logs to confirm that SDK initialization and data synchronization have executed normally.
- Return to the Guance console and confirm that corresponding RUM data has appeared in the application.
If further troubleshooting is needed, please refer to Troubleshooting.
Next Steps¶
- For complete installation and integration instructions, continue reading Application Access.
- For explanations of all initialization parameters, read SDK Initialization.
- For detailed configurations of RUM, Log, and Trace, read RUM Configuration, Log Configuration, Trace Configuration.
- If you need to integrate WebView monitoring, read WebView Data Monitoring.
- If you need to integrate Session Replay, read Session Replay.
- If the project involves hybrid development of native and React Native, read Native and React Native Hybrid Development.