Compliance guide for the App Monitor SDK (Harmony)

更新时间:
复制 MD 格式

Note

In accordance with the Personal Information Protection Law (PIPL), Data Security Law (DSL), Network Security Law (CSL), and other relevant laws and regulations, app developers must respect and protect the personal information of end users. You must not illegally collect or use personal information. This guide explains how to use the application performance management (APM) software development kit (SDK) in compliance with personal information protection requirements to avoid infringing on the rights and interests of end users.

1. System permission requests for the App Monitor SDK

Permission

Required

Purpose

INTERNET

Yes

The basic permission that lets the SDK connect to the internet. It is used to upload crash and performance logs.

GET_NETWORK_INFO

Yes

Lets the application get data network information for crash log collection.

2. App Monitor SDK features and related personal information

Feature

Personal information fields collected

Purpose of collection

Configuration and example

Crash Analytics

(Basic feature)

Device information (CPU, model, brand, resolution), system info (system version), and network information (ISP, network type)

To generate crash and abnormal logs. This provides useful information for troubleshooting.

Not applicable

App Performance Analytics

(Basic feature)

Device information (CPU, model, brand, resolution), system info (system version), and network information (ISP, network type)

To generate performance and network logs. This provides useful information for troubleshooting.

Not applicable

3. Configuration for optional personal information fields

Optional personal information fields

Purpose of collection

Configuration and example

Not applicable

Not applicable

Not applicable

4. Compliant initialization configuration for the App Monitor SDK

import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
import { window } from '@kit.ArkUI';
import { APM, APMConfig, Logger } from '@aliyun/apm';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { performanceApi } from '@aliyun/apm_perf';
import { crashAnalysisApi } from '@aliyun/apm_crash';

class MyCustomLog implements Logger {
  print(domain: number, tag: string, level: hilog.LogLevel, msg: string): void {
    switch (level) {
      case hilog.LogLevel.DEBUG:
        console.debug(`Custom log msg:${msg}`);
        break;
      case hilog.LogLevel.INFO:
        console.info(`Custom log msg:${msg}`);
        break;
      case hilog.LogLevel.WARN:
        console.warn(`Custom log msg:${msg}`);
        break;
      case hilog.LogLevel.ERROR:
      case hilog.LogLevel.FATAL:
        console.error(`Custom log msg:${msg}`);
        break;
    }
  }
}

export default class EntryAbility extends UIAbility {
  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');

    const apm_config: APMConfig = {
      context: this.context,  // Required
      appKey: 'YOUR_APP_KEY',    // Required
      appSecret: 'YOUR_APP_SECRET',  // Required
      nick: 'USER_NICKNAME',  // Optional
      userId: 'USER_ID',  // Optional
      channel: 'USER_CHANNEL',  // Optional
      hiLog: true, // Switch for hilog in the SDK. Optional.
      customLogger: new MyCustomLog(), // Custom log interface. Optional.
    }
    // When you call init, select the crash and performance APIs based on the features you use.
    APM.init(apm_config, [performanceApi, crashAnalysisApi])
    APM.start();

  }

  // Other code omitted.
}
Important
  • Ensure that the end user agrees to the Privacy Policy before you call the APM.init() and APM.start() methods.