Skip to content

Data Collection Custom Rules

Automatic Action collection rules require ft-sdk version 0.1.16 or later.

Action

  • FTRUMConfig.setEnableTraceUserAction(true) must be enabled.
  • Purpose: Filter automatic Click Action collection based on ArkUI components.

Set the handler via setActionTrackingHandler(...). When it returns null, the SDK does not collect the Action; when it returns undefined, the SDK reports the Action name, attributes, location, and View association information using the default automatic collection flow.

import {
  ActionEventWrapper,
  FTActionTrackingHandler,
  FTRUMConfig
} from '@guancecloud/ft_sdk/Index';

const actionHandler: FTActionTrackingHandler = {
  resolveHandlerAction: (event: ActionEventWrapper): null | undefined => {
    const source = event.getSource();

    // Ignore Actions triggered by the specified component.
    if (source?.getId() === 'ignore_action_view') {
      return null;
    }

    // For all other operations, continue using the SDK's default automatic collection logic.
    return undefined;
  }
};

const rumConfig = new FTRUMConfig()
  .setEnableTraceUserAction(true)
  .setActionTrackingHandler(actionHandler);
Note

Actions that return null are skipped; when undefined is returned, the SDK continues with default automatic collection. This handler only affects automatic Click collection and does not affect manual calls to FTRUMGlobalManager.addAction(...) or startAction(...).

ActionEventWrapper provides the following information:

  • getSource(): The ArkUI FrameNode that triggered the Action; it can be used to filter by component ID, type, or custom attributes.
  • getSourceType(): The Action source type. The current HarmonyOS automatic collection pipeline passes ActionSourceType.CLICK_VIEW.
  • getExtra(): Additional information; the current automatic Click collection does not pass additional information and returns null.

Feedback

Is this page helpful?