Skip to content

Quick Start

This article provides the quickest integration path for the HarmonyOS RUM SDK, helping you quickly complete a verifiable data upload.

Prerequisites

  1. Create a HarmonyOS application in RUM and obtain the RUM App ID
  2. Confirm the upload method:
    • Local environment deployment: prepare datakitUrl
    • Public network DataWay: prepare datawayUrl and clientToken
  3. 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_sdk as the dependency name in oh-package.json5
  4. If you need to use the HTTP interceptor chain capability based on @kit.NetworkKit, also install @guancecloud/ft_sdk_ext or download ft_sdk_ext.har
  5. If you need to collect Native Crash, also install @guancecloud/ft_native or download ft_native.har
  6. When using bytecode HAR, the project must use HarmonyOS API Level 12 or higher, and enable useNormalizedOHMUrl in the root build-profile.json5; see Bytecode HAR Build Configuration for complete configuration and obfuscation instructions.

Integration Steps

  1. When using a third-party repository, run ohpm install @guancecloud/ft_sdk
  2. When using a local HAR, place the HAR file in the project's libs directory and declare the scoped dependency in oh-package.json5; if you also use ft_sdk_ext.har, you need to override @guancecloud/ft_sdk to the local HAR in the project root's oh-package.json5 via overrides before running ohpm install
  3. Initialize FTSDKConfig when the application starts
  4. Initialize FTRUMConfig, enable View, Action, Resource, ANR, and Crash collection
  5. Enable debug logging, run the application, and trigger a page opening or a network request
  6. Return to the console to confirm that RUM data has been successfully uploaded

Minimal Dependency Method

  • Install the core SDK via ohpm:
ohpm install @guancecloud/ft_sdk
  • When using a local HAR, add the minimal dependency in oh-package.json5:
{
  "dependencies": {
    "@guancecloud/ft_sdk": "file:../libs/ft_sdk.har"
  }
}

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

  1. Keep setDebug(true) enabled
  2. Open a page, or initiate a network request
  3. Search for [FT-SDK] in hilog to confirm that the SDK initialization and data upload flow are normal
  4. Go back to the Guance console and confirm that the corresponding RUM data appears

Next Steps

Feedback

Is this page helpful? ×