Quick Start¶
This article provides the quickest integration path for the HarmonyOS RUM SDK, helping you quickly complete a verifiable data upload.
Prerequisites¶
- Create a HarmonyOS application in RUM and obtain the
RUM App ID - Confirm the upload method:
- Local environment deployment: prepare
datakitUrl - Public network DataWay: prepare
datawayUrlandclientToken
- Local environment deployment: prepare
- Choose the installation method:
- Third-party repository configured: Install directly via
ohpm@guancecloud/ft_sdk - Use local HAR: Download
ft_sdk.har, and use@guancecloud/ft_sdkas the dependency name inoh-package.json5
- Third-party repository configured: Install directly via
- If you need to use the HTTP interceptor chain capability based on
@kit.NetworkKit, also install@guancecloud/ft_sdk_extor downloadft_sdk_ext.har - If you need to collect Native Crash, also install
@guancecloud/ft_nativeor downloadft_native.har - When using bytecode HAR, the project must use HarmonyOS API Level 12 or higher, and enable
useNormalizedOHMUrlin the rootbuild-profile.json5; see Bytecode HAR Build Configuration for complete configuration and obfuscation instructions.
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 the scoped dependency inoh-package.json5; if you also useft_sdk_ext.har, you need to override@guancecloud/ft_sdkto the local HAR in the project root'soh-package.json5viaoverridesbefore runningohpm install - Initialize
FTSDKConfigwhen the application starts - Initialize
FTRUMConfig, enable View, Action, Resource, ANR, and Crash collection - Enable debug logging, run the application, and trigger a page opening or a network request
- Return to the console to confirm that RUM data has been successfully uploaded
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 prioritize the minimal dependency integration, get the basic data upload working, and then 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 local 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')
.setSamplingRate(1.0)
.setEnableTraceUserAction(true)
.setEnableTraceUserView(true)
.setEnableTraceUserResource(true)
.setEnableTrackAppANR(true)
.setEnableTrackAppCrash(true);
FTSDK.installRUMConfig(rumConfig);
}
}
Verify Integration Success¶
- Keep
setDebug(true)enabled - Open a page, or initiate a network request
- Search for
[FT-SDK]inhilogto confirm that the SDK initialization and data upload flow are normal - Go back to the Guance console and confirm that the corresponding RUM data appears
Next Steps¶
- Complete integration guide: See App Access
- Old HAR migration guide: See Old Package 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