Quick Start¶
This topic provides the shortest onboarding path for the HarmonyOS RUM SDK to help you quickly complete a verifiable data reporting cycle.
The application supports Agent Auto-Integration and Manual Integration. The following steps describe the minimal configuration for manual integration.
Prerequisites¶
- In Real User Monitoring (RUM), create a HarmonyOS application and obtain the
RUM App ID. - Confirm the reporting method:
- Local environment deployment: Prepare
datakitUrl. - Public DataWay: Prepare
datawayUrlandclientToken.
- Local environment deployment: Prepare
- Select an installation method:
- Third-party repository configured: Install
@guancecloud/ft_sdkdirectly viaohpm. - Local HAR: Download
ft_sdk.harand use@guancecloud/ft_sdkas the dependency name inoh-package.json5.
- Third-party repository configured: Install
- To use the HTTP interceptor chain capability based on
@kit.NetworkKit, additionally install@guancecloud/ft_sdk_extor downloadft_sdk_ext.har; this capability requires HarmonyOS API 22 or later. - To collect Native Crash data, additionally install
@guancecloud/ft_nativeor downloadft_native.har. - When using the bytecode HAR, the project must use HarmonyOS API 12 or later and enable
useNormalizedOHMUrlin the rootbuild-profile.json5; for complete configuration and obfuscation instructions, see Bytecode HAR Build Configuration.
Integration Steps¶
- When using a third-party repository, run
ohpm install @guancecloud/ft_sdk. - When using a local HAR, place the HAR file in the project's
libsdirectory and declare a scoped dependency inoh-package.json5; if you also useft_sdk_ext.har, you also need to remap@guancecloud/ft_sdkto the local HAR viaoverridesin the project root'soh-package.json5before runningohpm install. - Initialize
FTSDKConfigwhen the application starts. - Initialize
FTRUMConfigand enable View, Action, Resource, ANR, and Crash collection. - Enable debug logs, run the application, and trigger a page open or a network request.
- Return to the console and confirm that RUM data has been reported successfully.
Minimal Dependency Setup¶
- Install the core SDK via ohpm:
- When using a local HAR, add the minimal dependency in
oh-package.json5:
We recommend starting with the minimal dependency setup, verifying basic data reporting, and then adding extension packages as needed.
Minimal Initialization Example¶
import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
import { FTSDK, FTSDKConfig, FTRUMConfig, EnvType, SDKLogLevel } from '@guancecloud/ft_sdk/Index';
export default class EntryAbility extends UIAbility {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
// For local environment deployment, change to FTSDKConfig.builder(datakitUrl)
const sdkConfig = FTSDKConfig.builder(datawayUrl, clientToken)
.setDebug(true)
.setSdkLogLevel(SDKLogLevel.D)
.setServiceName('Your-App-Name')
.setEnv(EnvType.PROD);
FTSDK.install(sdkConfig, this.context);
const rumConfig = new FTRUMConfig()
.setRumAppId('your-app-id')
.setSessionSamplingRate(100)
.setEnableTraceUserAction(true)
.setEnableTraceUserView(true)
.setEnableTraceUserResource(true)
.setEnableTrackAppANR(true)
.setEnableTrackAppCrash(true);
FTSDK.installRUMConfig(rumConfig);
}
}
Verify Integration¶
- Keep
setDebug(true)enabled. - Open a page or initiate a network request.
- Search for
[FT-SDK]inhilogto confirm that SDK initialization and data reporting are working properly. - Return to the Guance console and confirm that the corresponding RUM data appears.
When verifying network requests, you also need to mount the corresponding RCP, Axios, or NetworkKit interceptor according to Automatic Resource Tracking. Enabling only setEnableTraceUserResource(true) does not track all business requests.
Next Steps¶
- Complete integration instructions: See Application Integration.
- Legacy HAR migration instructions: See Legacy Configuration Migration.
- SDK initialization parameters: See SDK Initialization.
- Detailed RUM configuration and manual collection: See RUM Configuration.
- Log and Trace: See Log Configuration and Trace Configuration.
- WebView scenarios: See WebView Data Monitoring.
- Session Replay: See HarmonyOS Session Replay (Experimental).