Quick Start¶
This document provides the shortest integration path for the HarmonyOS RUM SDK, helping you quickly complete a verifiable data report.
Prerequisites¶
- Create a HarmonyOS app in RUM and obtain the
RUM App ID - Determine the reporting method:
- On-premises deployment: prepare
datakitUrl - Public DataWay: prepare
datawayUrlandclientToken
- On-premises deployment: prepare
- Choose an installation method:
- If a third-party repository is configured: install
@guancecloud/ft_sdkdirectly viaohpm - Use a local HAR: download
ft_sdk.harand use@guancecloud/ft_sdkas the dependency name inoh-package.json5
- If a third-party repository is 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, 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
libsdirectory and declare the scoped dependency inoh-package.json5. Ifft_sdk_ext.haris also used, useoverridesin the rootoh-package.json5to rewrite@guancecloud/ft_sdkto the local HAR before runningohpm install - Initialize
FTSDKConfigat app startup - Initialize
FTRUMConfigto enable View, Action, Resource, ANR, and Crash collection - Enable debug logging, run the app, and trigger a page open or network request
- Return to the console to confirm that the RUM data was reported successfully
Minimal Dependency Setup¶
- Install the core SDK via ohpm:
- When using a local HAR, add the minimal dependency in
oh-package.json5:
It is recommended to integrate with the minimal dependencies first. After basic data reporting works, add 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 on-premises deployment, use FTSDKConfig.builder(datakitUrl) instead
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')
.setSamplingRate(1.0)
.setEnableTraceUserAction(true)
.setEnableTraceUserView(true)
.setEnableTraceUserResource(true)
.setEnableTrackAppANR(true)
.setEnableTrackAppCrash(true);
FTSDK.installRUMConfig(rumConfig);
}
}
Verify the Integration¶
- Keep
setDebug(true)enabled - Open a page or initiate a network request
- Search for
[FT-SDK]inhilogto confirm that the SDK initialization and data reporting flow are normal - Return to the Guance console to confirm that the corresponding RUM data appears
Next Steps¶
- Full integration instructions: See App Integration
- Old HAR migration instructions: See Old Configuration Migration
- SDK initialization parameters: See SDK Initialization
- RUM detailed configuration and manual collection: See RUM Configuration
- Log and Trace: See Log Configuration, Trace Configuration
- WebView scenarios: See WebView Data Monitoring