Skip to content

Quick Start

This document provides the shortest integration path for the UniApp RUM SDK, helping you complete a verifiable data upload with minimal steps.

Prerequisites

Before you begin, complete the following:

  1. In Real User Monitoring (RUM), create a UniApp Android app and a UniApp iOS app, and obtain their respective RUM App IDs.
  2. Confirm the upload URL and authentication method:
  3. On-premise deployment: Prepare datakitUrl.
  4. Public DataWay: Prepare datawayUrl and clientToken.

  5. Download the datakit-uniapp-native-plugin and prepare GCUniPlugin and GC-JSPlugin.

Integration Steps

  1. Copy GCUniPlugin into your project’s nativeplugins directory, and enable the local plugin in manifest.json.
  2. Copy GC-JSPlugin into your project’s uni_modules directory.
  3. In App.vue, call sdkConfig to initialize the SDK.
  4. Call rum.setConfig to configure the App ID for Android and iOS.
  5. To automatically collect pages, errors, or requests, integrate the corresponding capabilities in GC-JSPlugin.
  6. Enable debug, run the app, and verify that data is uploaded successfully.

Minimal Initialization Example

<script>
var ftModule = uni.requireNativePlugin("GCUniPlugin-MobileAgent");
var rum = uni.requireNativePlugin("GCUniPlugin-RUM");

export default {
    onLaunch: function() {
        ftModule.sdkConfig({
            datawayUrl: "https://open.dataway.url",
            clientToken: "client-token",
            debug: true,
            env: "common"
        });

        rum.setConfig({
            androidAppId: "YOUR_ANDROID_APP_ID",
            iOSAppId: "YOUR_IOS_APP_ID"
        });
    }
}
</script>

Automatic View Collection Example

The following is the Vue 2 calling method; for Vue 3, call gcViewTracking.startTracking(app). For the full example, see RUM View Auto-collection.

import { gcViewTracking } from '@/uni_modules/GC-JSPlugin';

gcViewTracking.startTracking();

Automatic Resource Collection Example

Start the global collector before the first call to uni.request. Subsequent requests do not need to replace the original method:

import { gcResourceTracking } from '@/uni_modules/GC-JSPlugin';

gcResourceTracking.startTracking();

uni.request({
    url: 'https://example.com/api'
});

If iOS has already enabled native Resource collection via rum.setConfig({ enableNativeUserResource: true }), call gcResourceTracking.startTracking({ enableIOS: false }) instead to avoid duplicate collection. For full details, see RUM Resource Auto-collection.

Verify Integration Success

  1. Keep debug: true enabled and run the app.
  2. Open a page, or after enabling gcResourceTracking, initiate a network request using standard uni.request.
  3. Verify in the debug environment that SDK initialization and data sync logs are output normally.
  4. Return to the console and confirm that RUM data for the corresponding platform appears in the application.

Next Steps

Feedback

Is this page helpful?