Quick Start¶
This document provides the shortest path to integrate 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 DataWay: Prepare
datawayUrlandclientToken. - Choose the installation method:
- If a third-party repository is 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 a 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 rootoh-package.json5of the project, 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 a local HAR, add the minimal dependency 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 } from '@guancecloud/ft_sdk/src/main/ets/components/FTSDK';
import { FTSDKConfig, FTRUMConfig } from '@guancecloud/ft_sdk/src/main/ets/components/Configs';
import { EnvType } from '@guancecloud/ft_sdk/src/main/ets/components/enum/Enums';
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 the SDK initialization and data reporting process is normal.
- Return to the Guance console to confirm the corresponding RUM data appears.
Next Steps¶
- Complete Integration Instructions: See App Access.
- 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.