Skip to content

Quick Start

This document provides the shortest path to integrate the HarmonyOS RUM SDK, helping you quickly complete a verifiable data reporting.

Prerequisites

  1. Create a HarmonyOS application in RUM and obtain the RUM App ID.
  2. Confirm the reporting method:
  3. Local environment deployment: Prepare datakitUrl.
  4. Public DataWay: Prepare datawayUrl and clientToken.
  5. Choose the installation method:
  6. If a third-party repository is configured: Install @guancecloud/ft_sdk directly via ohpm.
  7. Using local HAR: Download ft_sdk.har and use @guancecloud/ft_sdk as the dependency name in oh-package.json5.
  8. If you need to use the HTTP interceptor chain capability based on @kit.NetworkKit, additionally install @guancecloud/ft_sdk_ext or download ft_sdk_ext.har.
  9. If you need to collect Native Crash, additionally install @guancecloud/ft_native or download ft_native.har.

Integration Steps

  1. When using a third-party repository, execute 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 ft_sdk_ext.har is also used, you need to rewrite @guancecloud/ft_sdk to the local HAR via overrides in the root oh-package.json5 of the project, then execute ohpm install.
  3. Initialize FTSDKConfig when the application starts.
  4. Initialize FTRUMConfig, enabling View, Action, Resource, ANR, and Crash collection.
  5. Enable debug logs, run the application, and trigger a page open or network request.
  6. Return to the Guance console to confirm that RUM data has been successfully reported.

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 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

  1. Keep setDebug(true) enabled.
  2. Open a page or initiate a network request.
  3. Check the application logs to confirm the SDK initialization and data reporting process is normal.
  4. Return to the Guance console to confirm the corresponding RUM data appears.

Next Steps