Skip to content

Quick Start

This document provides the shortest integration path for version 0.3.0 and later. For complete installation and host integration instructions, see Application Integration.

The application supports Agent auto-integration and manual integration. The following steps describe the minimal configuration for manual integration.

Standard uni-app

1. Install Modules

Copy the following directories from the release package of the same version into the project. The version should be 0.3.0 or later:

uni_modules/
├── GC-JSPlugin
└── GC-UniPlugin

Do not install nativeplugins/GCUniPlugin.

2. Load the Bridge and Import APIs

Load setup.js once at the application entry point:

import '@/uni_modules/GC-UniPlugin/setup.js';

import {
    mobileAgent,
    rum,
    logger,
    tracer
} from '@/uni_modules/GC-UniPlugin';

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

3. Initialize

mobileAgent.sdkConfig({
    datakitUrl: 'YOUR_DATAKIT_URL',
    debug: true,
    env: 'prod'
});

rum.setConfig({
    androidAppId: 'YOUR_ANDROID_APP_ID',
    iOSAppId: 'YOUR_IOS_APP_ID',
    harmonyAppId: 'YOUR_HARMONY_APP_ID'
});

logger.setConfig({
    enableCustomLog: true,
    enableLinkRumData: true
});

tracer.setConfig({
    traceType: 'ddTrace',
    enableLinkRUMData: true
});

gcErrorTracking.startTracking();
gcResourceTracking.startTracking();

Only enter the RUM App ID for the actual target platform. When using the public DataWay, replace datakitUrl with datawayUrl and clientToken.

4. Enable Automatic View Collection

For Vue 2, call this before creating the root instance:

gcViewTracking.startTracking();

For Vue 3, pass the application instance returned by createSSRApp():

import App from './App';
import { createSSRApp } from 'vue';

export function createApp() {
    const app = createSSRApp(App);
    gcViewTracking.startTracking(app);
    return { app };
}

The recommended initialization order is:

mobileAgent.sdkConfig
  -> rum.setConfig
  -> logger.setConfig / tracer.setConfig
  -> GC-UniSessionReplay.setConfig (optional)
  -> gcErrorTracking / gcResourceTracking / gcActionTracking
  -> gcViewTracking

Host App + uni Mini Program

A uni Mini Program project only needs to install GC-JSPlugin:

import {
    mobileAgent,
    rum,
    logger,
    tracer,
    gcErrorTracking,
    gcViewTracking,
    gcResourceTracking
} from '@/uni_modules/GC-JSPlugin';

Native SDK, RUM, Log, and Trace are initialized by the host App before it opens the uni Mini Program. The uni Mini Program only starts JS collectors and calls runtime APIs, for example:

mobileAgent.bindRUMUserData({
    userId: 'USER_ID'
});

mobileAgent.appendBridgeContext({
    wgt_id: 'YOUR_WGT_ID'
});

gcErrorTracking.startTracking();
gcResourceTracking.startTracking();

If the iOS host has already enabled automatic Native Resource collection, call gcResourceTracking.startTracking({ enableIOS: false }) instead to avoid duplicate collection.

When the host App has not registered the corresponding module, these calls safely degrade to no-ops, which makes it convenient to debug uni Mini Program pages in a standard base app; the native pipeline must be verified in a host App that has the host extension integrated.

Next Steps

Feedback

Is this page helpful?