UTS SDK

Updated at:

Use the UTS SDK to add QuickTracking's Application Performance Monitoring (APM) to your uniapp projects.

1. Download the plugin

QuickTracking UTS plugin download

Platform compatibility

Android

iOS

Supported versions: 4.4 and later

Supported versions: 9 and later

Import and configure the SDK

1.1 Download and import plugin into HBuilderX

image

1.2 Select the project for plugin integration

image

1.3 Plugin usage

Before using the plugin, get your unique app key and data collection endpoint from the QuickTracking platform.

image

1.4 Android SDK pre-initialization

You must call the QtConfigure.preInit() pre-initialization function in the Application.onCreate method. This pre-initialization function does not collect device information.

Modify the index.uts file in the corresponding module, as shown in the following figure:

image

Important

The UTS plugin is compatible with uni-app-x. If you experience an initialization failure, replace the original index.uts file in the Android directory with the linked index.uts file.

1.5 HarmonyOS NEXT SDK pre-initialization

Due to architectural constraints, you must pre-initialize the SDK in the application's stage.

Modify the index.uts file in the corresponding module, as shown in the following figure:

image

2. SDK API

2.1 Initialization

To start collecting data, you must initialize the SDK.

App.uvue

<script>
  // #ifdef APP
  import * as QtAnalytics from '@/uni_modules/QT-Analytics';
  import { initWithConfig, ApmConfig } from '@/uni_modules/QT-APM';
  // #endif
    
  export default {
    data() {
      return {
        title: 'Hello'
      }
    },
    onLoad() {
      // #ifdef APP-ANDROID || APP-HARMONY
      QtAnalytics.init()
      // #endif
      // #ifdef APP-IOS
      QtAnalytics.setCustomDomain('YOUR_DATA_COLLECTION_ENDPOINT', 'YOUR_BACKUP_DATA_COLLECTION_ENDPOINT');
      QtAnalytics.initWithAppkey('YOUR_APP_KEY', 'App Store');
      // #endif
      const apmConfig : ApmConfig = {
        crashAndBlockMonitorEnable: true,
        sendBeatInterval: 30,
        initSendPVEnable: true,
      };
      initWithConfig(apmConfig);
    }	
  }
</script>

For H5 integration, refer to the Web SDK documentation.

For mini program integration, refer to the Mini Program SDK documentation.

2.2 API Reference

1. Configure feature flags

export type ApmConfig = {
  // Java crash capture (Android)
  enableCrashJava ?: boolean,
  // Native crash capture (Android)
  enableCrashNative ?: boolean,
  // ANR capture (Android)
  enableAnr ?: boolean,
  // Application hang capture (Android)
  enablePa ?: boolean,
  // Application hang timeout (Android)
  paTimeOut ?: number,
  // App launch monitoring (Android)
  enableLaunch ?: boolean,
  // Memory monitoring (Android)
  enableMemory ?: boolean,
  // JavaScript bridge (Android)
  enableH5 ?: boolean,
  // Log retrieval (Android)
  enableCodeLog ?: boolean,
  // User ID for log retrieval (Android)
  logUserId ?: string,
  // Enable PV reporting on cold start (Android)
  enableSendPv ?: boolean,
  // Enable app launch monitoring module (iOS)
  launchMonitorEnable ?: boolean,
  // Enable memory monitoring module (iOS)
  memMonitorEnable ?: boolean,
  // Enable network monitoring module (iOS)
  networkEnable ?: boolean,
  // Enable JavaScript bridge module (iOS)
  javaScriptBridgeEnable ?: boolean,
  // Enable OOM (Out of Memory) monitoring module (iOS)
  oomMonitorEnable ?: boolean,
  // Enable native page monitoring module (iOS)
  pageMonitorEnable ?: boolean,
  // Send a PV (Page View) on initialization (iOS)
  initSendPVEnable ?: boolean,
  // Used for front-end and back-end trace correlation (iOS)
  rumConfig ?: string,
  // Enable crash and application hang monitoring (iOS)
  crashAndBlockMonitorEnable ?: boolean,
  // Heartbeat interval for application hang monitoring (iOS)
  sendBeatInterval ?: number,
  // Hang detection interval for application hang monitoring (iOS)
  checkBeatInterval ?: number,
  // Number of missed heartbeats that trigger a hang event (iOS)
  toleranceBeatMissingCount ?: number,
}

Example:

const apmConfig : ApmConfig = {
  crashAndBlockMonitorEnable: true,
  sendBeatInterval: 30,
  initSendPVEnable: true,
};

2. Crash callback

export function registerUMCrashCallback(callback : QTCrash) {
  const crashCall = new QTCrashCallback(callback);
  UMCrash.registerUMCrashCallback(crashCall)
}

3. Custom exception

export function generateCustomLog(e : string, type : string)

4. Enable JavaScript bridge for H5 pages

export function enableJavaScriptBridge(view : WebView)

5. Log retrieval (Android)

export class QTlog