TingyunAPM.ets 998 Bytes
import { common } from '@kit.AbilityKit';
import tingyun, { LogLevel } from '@tingyun/harmonyos';


export class TingyunAPM {

  private static TINGYUN_APP_KEY = "ebe0ed7f09f54af681201b784858dde2"
  private static TINGYUN_REDIRECT_HOST = "wkrt.tingyun.com"

  private static logEnable() {
    return true
  }

  //
  static initApp(context: common.UIAbilityContext, deviceId?: string) {
    tingyun.init({
      redirectHost: TingyunAPM.TINGYUN_REDIRECT_HOST,
      appKey: TingyunAPM.TINGYUN_APP_KEY,
      context: context,

      httpEnabled: true,
      logLevel: TingyunAPM.logEnable() ? LogLevel.DEBUG : LogLevel.NONE,

      // TODO: axios实例对象
      // axios:axiosInstance,
      network: {
        enabled: true,
      },

      crash: {
        enabled: true,
        jsCrashEnabled: true,
        cppCrashEnabled: true,
      },

      freeze: {
        enabled: true
      }
    });
    if (deviceId) {
      tingyun.setUserId(deviceId)
    }
    tingyun.startNextSession()
  }
}