Quick Start¶
This document provides the shortest integration path for the HarmonyOS RUM SDK, helping you quickly complete a verifiable data reporting.
Prerequisites¶
- Create a HarmonyOS application in RUM and obtain the
RUM App ID. - Confirm the reporting method:
- Local environment deployment: Prepare
datakitUrl. - Public network DataWay: Prepare
datawayUrlandclientToken. - Choose the installation method:
- If third-party repositories are configured: Install
@guancecloud/ft_sdkdirectly viaohpm. - Using local HAR: Download
ft_sdk.harand use@guancecloud/ft_sdkas the dependency name inoh-package.json5. - If you need to use the HTTP interceptor chain capability based on
@kit.NetworkKit, additionally install@guancecloud/ft_sdk_extor downloadft_sdk_ext.har. - If you need to collect Native Crash, additionally install
@guancecloud/ft_nativeor downloadft_native.har.
Integration Steps¶
- When using a third-party repository, execute
ohpm install @guancecloud/ft_sdk. - When using local HAR, place the HAR file in the project's
libsdirectory and declare the scoped dependency inoh-package.json5. Ifft_sdk_ext.haris also used, you need to rewrite@guancecloud/ft_sdkto the local HAR viaoverridesin the project root'soh-package.json5and then executeohpm install. - Initialize
FTSDKConfigwhen the application starts. - Initialize
FTRUMConfig, enabling View, Action, Resource, ANR, and Crash collection. - Enable debug logs, run the application, and trigger a page open or network request.
- Return to the Guance console to confirm that RUM data has been successfully reported.
Minimal Dependency Method¶
- Install the core SDK via ohpm:
- When using local HAR, add minimal dependencies in
oh-package.json5:
It is recommended to integrate with minimal dependencies first, verify basic data reporting, and then add extension packages as needed.
Minimal Initialization Example¶
import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
import { FTSDK, FTSDKConfig, FTRUMConfig, EnvType } from '@guancecloud/ft_sdk/Index';
export default class EntryAbility extends UIAbility {
async onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): Promise<void> {
// For local environment deployment, change to FTSDKConfig.builder(datakitUrl)
const sdkConfig = FTSDKConfig.builder(datawayUrl, clientToken)
.setDebug(true)
.setServiceName('Your-App-Name')
.setEnv(EnvType.PROD);
await 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);
await FTSDK.installRUMConfig(rumConfig);
}
}
Verify Integration Success¶
- Keep
setDebug(true)enabled. - Open a page or initiate a network request.
- Check the application logs to confirm that SDK initialization and data reporting processes are normal.
- Return to the Guance console to confirm that corresponding RUM data appears.
Next Steps¶
- Complete integration instructions: See Application Integration.
- Old HAR migration instructions: See Old Configuration Migration.
- SDK initialization parameters: See SDK Initialization.
- Detailed RUM configuration and manual collection: See RUM Configuration.
- Log and Trace: See Log Configuration, Trace Configuration.
- WebView scenarios: See WebView Data Monitoring.