Skip to content

Quick Start

This topic provides the shortest onboarding path for the HarmonyOS RUM SDK to help you quickly complete a verifiable data reporting cycle.

The application supports Agent Auto-Integration and Manual Integration. The following steps describe the minimal configuration for manual integration.

Prerequisites

  1. In Real User Monitoring (RUM), create a HarmonyOS application and obtain the RUM App ID.
  2. Confirm the reporting method:
    • Local environment deployment: Prepare datakitUrl.
    • Public DataWay: Prepare datawayUrl and clientToken.
  3. Select an installation method:
    • Third-party repository configured: Install @guancecloud/ft_sdk directly via ohpm.
    • Local HAR: Download ft_sdk.har and use @guancecloud/ft_sdk as the dependency name in oh-package.json5.
  4. To use the HTTP interceptor chain capability based on @kit.NetworkKit, additionally install @guancecloud/ft_sdk_ext or download ft_sdk_ext.har; this capability requires HarmonyOS API 22 or later.
  5. To collect Native Crash data, additionally install @guancecloud/ft_native or download ft_native.har.
  6. When using the bytecode HAR, the project must use HarmonyOS API 12 or later and enable useNormalizedOHMUrl in the root build-profile.json5; for complete configuration and obfuscation instructions, see Bytecode HAR Build Configuration.

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 a scoped dependency in oh-package.json5; if you also use ft_sdk_ext.har, you also need to remap @guancecloud/ft_sdk to the local HAR via overrides in the project root's oh-package.json5 before running ohpm install.
  3. Initialize FTSDKConfig when the application starts.
  4. Initialize FTRUMConfig and enable View, Action, Resource, ANR, and Crash collection.
  5. Enable debug logs, run the application, and trigger a page open or a network request.
  6. Return to the console and confirm that RUM data has been reported successfully.

Minimal Dependency Setup

  • 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"
  }
}

We recommend starting with the minimal dependency setup, verifying basic data reporting, and then adding 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 environment 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')
      .setSessionSamplingRate(100)
      .setEnableTraceUserAction(true)
      .setEnableTraceUserView(true)
      .setEnableTraceUserResource(true)
      .setEnableTrackAppANR(true)
      .setEnableTrackAppCrash(true);

    FTSDK.installRUMConfig(rumConfig);
  }
}

Verify Integration

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

When verifying network requests, you also need to mount the corresponding RCP, Axios, or NetworkKit interceptor according to Automatic Resource Tracking. Enabling only setEnableTraceUserResource(true) does not track all business requests.

Next Steps

Feedback

Is this page helpful?