Skip to content

UniApp Application Integration


Prerequisites

Note: If you have activated the RUM Headless service, the prerequisites have been automatically configured for you. You can proceed directly with application integration.

Application Integration

  1. Navigate to RUM > Create Application > Android/iOS;
  2. Create two separate applications for UniApp Android and UniApp iOS to receive RUM data from the Android and iOS platforms respectively;
  3. For each platform's application, input the corresponding Application Name and Application ID;
  4. Choose the application integration method:
    • Public DataWay: Receives RUM data directly without requiring a DataKit collector installation.
    • Local Environment Deployment: Receives RUM data after meeting the prerequisites.

Installation

Local Usage

Source Code: https://github.com/GuanceCloud/datakit-uniapp-native-plugin

Demo: https://github.com/GuanceCloud/datakit-uniapp-native-plugin/Hbuilder_Example

Downloaded SDK Package Structure Description

|--datakit-uniapp-native-plugin
  |-- Hbuilder_Example            // GCUniPlugin plugin example project
    |-- uni_modules           
      |-- GC-JSPlugin         // ⭐️ GC-JSPlugin JS Plugin Package ⭐️
      |   |-- js_sdk          // Folder containing js files
            |-- View/GCPageMixin.js  // js for view auto-capture, used with GCWatchRouter.js
            |-- View/GCWatchRouter.js // js for view auto-capture, used with GCPageMixin.js
            |-- View/GCPageViewMixinOnly.js  // js for view auto-capture, used standalone
            |-- Request/GCRequest.js         // js for resource and trace, provides APM and network request monitoring capabilities
            |-- Error/GCErrorTracking.js     // js for error auto-capture, supports uni.onError, console.error
      |   |-- index.js        
      |   |-- package.json    // Plugin configuration file
    |-- nativeplugins             // Example project's local plugin folder
          |-- GCUniPlugin         // ⭐️ GCUniPlugin Native Plugin Package ⭐️
          |   |-- android         // Contains dependency libraries and resource files required for the android plugin
          |   |-- ios             // Contains dependency libraries and resource files required for the ios plugin
          |   |-- package.json    // Plugin configuration file
  |-- UniPlugin-Android           // Plugin Development Android Main Project 
  |-- UniPlugin-iOS               // Plugin Development iOS Main Project 

Configure the GCUniPlugin folder into your uni_app project's "nativeplugins" directory. Additionally, in the manifest.json file, under the "App Native Plugin Configuration" section, click "Select Local Plugin" and choose the GCUniPlugin plugin from the list:

img

Configure the GC-JSPlugin folder into your uni_app project's "uni_modules" directory.

Note: After saving, you need to submit a cloud build (creating a Custom Debugging Package also counts as a cloud build) for the plugin to take effect.

For more details, refer to: Using Local Plugins in HBuilderX, Custom Debugging Package

Marketplace Plugin Method

(Not provided)

Uni Mini Program SDK Installation

Development Debugging and wgt Release Usage

  • When developing and debugging the uni mini program SDK, integrate GCUniPlugin using the Local Usage method.

  • When the uni mini program SDK is packaged into a wgt file for use by a host App, the host App needs to import the GCUniPlugin dependency libraries (including the Native SDK libraries) and register the GCUniPlugin Module.

Operations required by the host App:

iOS

  • Add GCUniPlugin dependency libraries

    In the Xcode project, select the project name in the left directory, go to TARGETS -> Build Phases -> Link Binary With Libaries, click the "+" button, then click Add Other -> Add Files... in the pop-up window, navigate to the GCUniPlugin/ios/ dependency library directory, select FTMobileSDK.xcframework and GC_UniPlugin_App.xcframework in the directory, and click open to add the dependency libraries to the project.

    When SDK Version < 0.2.0: In TARGETS -> General -> Frameworks,Libaries,and Embedded Content, find FTMobileSDK.xcframework and change the Embed method to Embed & sign.

  • Register GCUniPlugin Module:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    ....
      //  Register GCUniPlugin module
    [WXSDKEngine registerModule:@"GCUniPlugin-MobileAgent" withClass:NSClassFromString(@"FTMobileUniModule")];
    [WXSDKEngine registerModule:@"GCUniPlugin-RUM" withClass:NSClassFromString(@"FTRUMModule")];
    [WXSDKEngine registerModule:@"GCUniPlugin-Logger" withClass:NSClassFromString(@"FTLogModule")];
    [WXSDKEngine registerModule:@"GCUniPlugin-Tracer" withClass:NSClassFromString(@"FTTracerModule")];  
      return YES;
    }

Android

  • Add GCUniPlugin dependency libraries

  • Method 1: Add ft-native-[version].aar, ft-sdk-[version].aar, and gc-uniplugin-[last-version].aar from the GCUniPlugin/android/ folder to the project's libs folder, then modify the build.gradle file to add the dependencies.

  • Method 2: Use the Gradle Maven remote repository for configuration. The configuration method can refer to the UniAndroid-Plugin project configuration.
  dependencies {
      implementation files('libs/ft-native-[version].aar')
      implementation files('libs/ft-sdk-[version].aar')
      implementation files('libs/gc-uniplugin-[last-version].aar')
      implementation 'com.google.code.gson:gson:2.8.5'
  }   
  • Register GCUniPlugin Module:
  public class App extends Application {
      @Override
      public void onCreate() {
          super.onCreate();
          try {
            //  Register GCUniPlugin module
              WXSDKEngine.registerModule("GCUniPlugin-Logger", FTLogModule.class);
              WXSDKEngine.registerModule("GCUniPlugin-RUM", FTRUMModule.class);
              WXSDKEngine.registerModule("GCUniPlugin-Tracer", FTTracerModule.class);
              WXSDKEngine.registerModule("GCUniPlugin-MobileAgent", FTSDKUniModule.class);
          } catch (Exception e) {
              e.printStackTrace();
          }
          ......
      }
  }

UniApp SDK and Native SDK Mixed Usage

  • The Native SDK has already been added to the host project during the above step of adding GCUniPlugin dependency libraries, so Native SDK methods can be called directly.

  • SDK Initialization

    For mixed usage, only initialize the Native SDK within the host App. No initialization configuration is needed within the uni mini program; you can directly call the methods provided by the UniApp SDK.

    The SDK initialization method within the host App please refer to iOS SDK Initialization Configuration, Android SDK Initialization Configuration.

    Note: Ensure the SDK initialization is completed by the host App before loading the uni mini program to make sure the SDK is fully ready before calling any other SDK methods.

  • Additional Configuration for Android Integration:

    Configure the Gradle Plugin ft-plugin to collect App startup events, network request data, and Android Native related events (page navigation, click events, Native network requests, WebView data).

  • Distinguishing Data Collected by uni Mini Program and Native:

    Supported in SDK 0.2.4 and above

    You can add BridgeContext in the uni mini program to filter or correlate data for specific scenarios based on the set key-value pairs.

    For example: Filter by wgt_id:wgt_id_1 to view data collected by the uni mini program.

      var ftModule = uni.requireNativePlugin("GCUniPlugin-MobileAgent");
        ftModule.appendBridgeContext({
                    'wgt_id': 'wgt_id_1'
                });
    

SDK Initialization

Basic Configuration

// Configure in App.vue
<script>
    var ftModule = uni.requireNativePlugin("GCUniPlugin-MobileAgent");
    export default {
        onLaunch: function() {
            ftModule.sdkConfig({
                'datakitUrl': 'your datakitUrl',
                'debug': true,
                'env': 'common',
                'globalContext': {
                    'custom_key': 'custom value'
                }
            })
        }
    }
</script>
<style>
</style>
Parameter Name Parameter Type Required Parameter Description
datakitUrl string Yes Local environment deployment (Datakit) reporting URL address, e.g., http://10.0.0.1:9529. Port defaults to 9529. The device installing the SDK must be able to access this address. Note: Choose one between datakitUrl and datawayUrl
datawayUrl string Yes Public Dataway reporting URL address, obtained from the [RUM] application, e.g., https://open.dataway.url. The device installing the SDK must be able to access this address. Note: Choose one between datakitUrl and datawayUrl
clientToken string Yes Authentication token, must be used together with datawayUrl
debug boolean No Sets whether to allow printing Debug logs, default false
env string No Environment, default prod. Any string, recommended to use a single word like test etc.
service string No Sets the name of the associated business or service, default: df_rum_ios, df_rum_android
globalContext object No Adds custom tags
offlinePakcage boolean No Android only. Whether to use offline packaging or uni mini program, default false. For details, see Difference between Android Cloud Build and Offline Build
autoSync boolean No Whether to automatically sync data to the server after collection. Default YES. When NO, use the flushSyncData method to manage data synchronization manually.
syncPageSize number No Sets the number of entries per sync request. Range [5,). Note: A larger number means the data sync consumes more computational resources. Default is 10.
syncSleepTime number No Sets the sync interval time. Range [0,5000], default not set.
enableDataIntegerCompatible boolean No Recommended to enable when coexistence with web data is needed. This configuration handles web data type storage compatibility issues. Enabled by default in versions after 0.2.1.
compressIntakeRequests boolean No Compresses uploaded sync data using deflate. Default off. Supported in SDK version 0.2.0 and above.
enableLimitWithDbSize boolean No Enables using DB to limit data size, default 100MB, unit Byte. Larger database means more disk pressure. Default off.
Note: After enabling, the Log configuration logCacheLimitCount and RUM configuration rumCacheLimitCount will become invalid. Supported in SDK version 0.2.0 and above.
dbCacheLimit number No DB cache size limit. Range [30MB,), default 100MB, unit byte. Supported in SDK version 0.2.0 and above.
dbDiscardStrategy string No Sets the data discard rule in the database.
Discard strategies: discard discard new data (default), discardOldest discard old data. Supported in SDK version 0.2.0 and above.
dataModifier object No Modifies a single field. Supported in SDK 0.2.2 and above. See example here.
lineDataModifier object No Modifies a single piece of data. Supported in SDK 0.2.2 and above. See example here.

RUM Configuration

var rum = uni.requireNativePlugin("GCUniPlugin-RUM");
rum.setConfig({
  'androidAppId':'YOUR_ANDROID_APP_ID',
  'iOSAppId':'YOUR_IOS_APP_ID',
  'errorMonitorType':'all', // or 'errorMonitorType':['battery','memory']
  'deviceMonitorType':['cpu','memory']// or  'deviceMonitorType':'all'
})
Parameter Name Parameter Type Required Description
androidAppId string Yes appId, applied for in Monitoring
iOSAppId string Yes appId, applied for in Monitoring
samplerate number No Sampling rate, value range [0,1]. 0 means no collection, 1 means full collection. Default is 1. Scope: All View, Action, LongTask, Error data under the same session_id.
sessionOnErrorSampleRate number No Sets the error collection rate. When a session is not sampled by samplerate, if an error occurs during the session, data from 1 minute before the error can be collected. Value range [0,1]. 0 means no collection, 1 means full collection. Default is 0. Scope: All View, Action, LongTask, Error data under the same session_id. Supported in SDK 0.2.2 and above.
enableNativeUserAction boolean No Whether to track Native Action, Button click events. Recommended to turn off for pure uni-app applications. Default false. Not supported in Android cloud builds.
enableNativeUserResource boolean No Whether to enable automatic Native Resource tracking. Default false. Not supported in Android cloud builds. Since uniapp network requests on iOS are implemented using system APIs, enabling this will collect all iOS resource data. Please disable manual collection on iOS at this time to prevent duplicate data collection.
enableNativeUserView boolean No Whether to enable automatic Native View tracking. Recommended to turn off for pure uni-app applications. Default false.
errorMonitorType string/array No Error monitoring supplement types: all, battery, memory, cpu. Default not set.
deviceMonitorType string/array No Page monitoring supplement types: all, battery (Android only), memory, cpu, fps. Default not set.
detectFrequency string No Page monitoring frequency: normal (default), frequent, rare.
globalContext object No Custom global parameters. Special key: track_id (used for tracing functionality).
enableResourceHostIP boolean No Whether to collect the IP address of the requested target domain. Scope: Only affects default collection when enableNativeUserResource is true. iOS: Supported on >= iOS 13. Android: A single Okhttp has an IP caching mechanism for the same domain. Under the same OkhttpClient, and if the server IP doesn't change, it will only be generated once.
enableTrackNativeCrash boolean No Whether to enable monitoring of Android Java Crash and OC/C/C++ crashes. Default false.
enableTrackNativeAppANR boolean No Whether to enable Native ANR monitoring. Default false.
enableTrackNativeFreeze boolean No Whether to collect Native Freeze.
nativeFreezeDurationMs number No Sets the threshold for collecting Native Freeze stalls. Value range [100,), unit milliseconds. iOS default 250ms, Android default 1000ms.
rumDiscardStrategy string No Discard strategy: discard discard new data (default), discardOldest discard old data.
rumCacheLimitCount number No Local cache maximum RUM entry count limit [10_000,), default 100_000.
enableTraceWebView boolean No Configures whether to enable WebView data collection through the native SDK. Default true. Supported in SDK 0.2.6 and above.
allowWebViewHost array No Sets the allowed WebView host addresses for data tracking. null means collect all, default null. Supported in SDK 0.2.6 and above.

Log Configuration

var logger = uni.requireNativePlugin("GCUniPlugin-Logger");
logger.setConfig({
  'enableLinkRumData':true,
  'enableCustomLog':true,
  'discardStrategy':'discardOldest'
})
Parameter Name Parameter Type Required Parameter Description
samplerate number No Sampling rate, value range [0,1]. 0 means no collection, 1 means full collection. Default is 1.
enableLinkRumData boolean No Whether to link with RUM data.
enableCustomLog boolean No Whether to enable custom logs.
discardStrategy string No Log discard strategy: discard discard new data (default), discardOldest discard old data.
logLevelFilters array No Log level filtering. The array should contain log levels: info, warning, error, critical, ok (recovery).
globalContext object No Custom global parameters.
logCacheLimitCount number No Local cache maximum log entry count limit [1000,). Larger logs mean greater disk cache pressure. Default 5000.

Trace Configuration

var tracer = uni.requireNativePlugin("GCUniPlugin-Tracer");
tracer.setConfig({
  'traceType': 'ddTrace'
})
Parameter Name Parameter Type Required Parameter Description
samplerate number No Sampling rate, value range [0,1]. 0 means no collection, 1 means full collection. Default is 1.
traceType string No Trace type: ddTrace (default), zipkinMultiHeader, zipkinSingleHeader, traceparent, skywalking, jaeger.
enableLinkRUMData boolean No Whether to link with RUM data. Default false.
enableNativeAutoTrace boolean No Whether to enable native network auto-tracing for iOS NSURLSession and Android OKhttp. Default false. Not supported in Android cloud builds. Since uniapp network requests on iOS are implemented using system APIs, enabling this will automatically trace network requests initiated by uniapp on iOS. Please disable manual trace collection on iOS at this time to prevent incorrect association between traces and RUM data.

RUM User Data Tracking

var rum = uni.requireNativePlugin("GCUniPlugin-RUM");

Action

API - startAction

Starts a RUM Action.

RUM will bind Resource, Error, LongTask events that might be triggered by this Action. Avoid adding multiple times within 0.1s. Only one Action can be associated with a View at the same time. If a new Action is added before the previous one ends, it will be discarded. Does not interfere with Actions added by the addAction method.

rum.startAction({
  'actionName': 'action name',
  'actionType': 'action type'
})
Parameter Name Parameter Type Required Parameter Description
actionName string Yes Event name
actionType string Yes Event type
property object No Event context (optional)

API - addAction

Adds an Action event. This type of data cannot associate Error, Resource, LongTask data and has no discard logic.

rum.addAction({
  'actionName': 'action name',
  'actionType': 'action type'
})
Parameter Name Parameter Type Required Parameter Description
actionName string Yes Event name
actionType string Yes Event type
property object No Event context (optional)

View

  • Automatic Collection

Method 1 (Recommended):

Import and call the collection method in the project's main.js. Configuration code is as follows:

import {
  gcViewTracking
} from '@/uni_modules/GC-JSPlugin'
// Enable View auto-collection
gcViewTracking.startTracking();

Method 2: App.vue + first page combination configuration. Refer to the example project Hbuilder_Example/App.vue and Hbuilder_Example/pages/index/index.vue in the SDK package's GCUniPlugin plugin.

// step 1. Locally add GC-JSPlugin to your project's uni_modules directory.
// step 2. Add Router monitoring in App.vue, as follows:
<script>
  import {gcWatchRouter} from '@/uni_modules/GC-JSPlugin';
  export default {
    mixins:[gcWatchRouter], //<--- Notice
  }
</script>
// step 3. Add pageMixin to the first displayed page of the application, as follows:
<script>
  import {gcPageMixin} from '@/uni_modules/GC-JSPlugin';
  export default {
    data() {
      return {}
    },
    mixins:[gcPageMixin], //<--- Notice
  }
</script>

Method 3: For monitoring specific pages only, apply to each page that needs monitoring. Refer to the example project Hbuilder_Example/pages/rum/index.vue in the SDK package's GCUniPlugin plugin.

// Locally add GC-JSPlugin to your project's uni_modules directory.
<script>
import  {gcPageViewMixinOnly} from '@/uni_modules/GC-JSPlugin';
export default {
    data() {
        return {            
        }
    },
    mixins:[gcPageViewMixinOnly], //<--- Notice
    methods: {}
}
</script>
  • Manual Collection
// Manually collect View lifecycle
// step 1 (optional)
rum.onCreateView({
  'viewName': 'Current Page Name',
  'loadTime': 100000000,
})
// step 2
rum.startView('Current Page Name')
// step 3  
rum.stopView()         

API - onCreateView

Creates a page load time record.

Field Type Required Description
viewName string Yes Page name
loadTime number Yes Page load time (nanosecond timestamp)

API - startView

Enters a page.

Field Type Required Description
viewName string Yes Page name
property object No Event context (optional)

API - stopView

Leaves a page.

Field Type Required Description
property object No Event context (optional)

Error

  • Automatic Collection
// Locally add GC-JSPlugin to your project's uni_modules directory.
import { gcErrorTracking } from '@/uni_modules/GC-JSPlugin'
gcErrorTracking.startTracking()
  • Manual Collection
// Add manually
rum.addError({
  'message': 'Error message',
  'stack': 'Error stack',
})

API - addError

Adds an Error event.

Field Type Required Description
message string Yes Error message
stack string Yes Stack information
state string No App running state (unknown, startup, run)
type string No Error type, default uniapp_crash
property object No Event context (optional)

Resource

  • Automatic Collection

The SDK provides the method gcRequest.request, which inherits the uni.request network request method and can be used as a replacement for uni.request.

Replacement Method

+ import {gcRequest} from '@/uni_modules/GC-JSPlugin';
- uni.request({
+ gcRequest.request({
  //...
});

Usage Example

// Locally add GC-JSPlugin to your project's uni_modules directory.
 import {gcRequest} from '@/uni_modules/GC-JSPlugin';
gcRequest.request({
  url: requestUrl,
  method: method,
  header: header,
  filterPlatform:["ios"], 
  timeout:30000,
  success(res)  {
    console.log('success:' + JSON.stringify(res))
  },
  fail(err) {
    console.log('fail:' + JSON.stringify(err))
  },
  complete() {
    console.log('complete:' + JSON.stringify(err))
  }
});

Extra Field Type Required Description
filterPlatform array No When the enableNativeUserResource feature is enabled, uniapp on iOS will automatically collect network request data made through system APIs. To avoid duplicate data collection, you can add filterPlatform: ["ios"] parameter when using gc.request to disable manual data collection on the iOS platform.
  • Manual Collection

Implement manually by calling startResource, stopResource, addResource. You can refer to the implementation in GCRequest.js.

API - startResource

HTTP request starts.

Field Type Required Description
key string Yes Request unique identifier
property object No Event context (optional)

API - stopResource

HTTP request ends.

Field Type Required Description
key string Yes Request unique identifier
property object No Event context (optional)

API - addResource

Parameter Name Parameter Type Required Parameter Description
key string Yes Request unique identifier
content content object Yes Request-related data

content object

Prototype Parameter Type Parameter Description
url string Request URL
httpMethod string HTTP method
requestHeader object Request headers
responseHeader object Response headers
responseBody string Response result
resourceStatus string Request result status code

Logger Log Printing

var logger = uni.requireNativePlugin("GCUniPlugin-Logger");
logger.logging({
  'content':`Log content`,
  'status':status
})

API - logging

Field Type Required Description
content string Yes Log content, can be a JSON string
status string Yes Log level
property object No Event context (optional)

Log Levels

String Meaning
info Info
warning Warning
error Error
critical Critical
ok Recovery

Tracer Network Trace

  • Automatic Collection

Using gc.request for requests will automatically add Propagation Headers. Refer to Resource.

  • Manual Collection
//Example using uni.request for network requests
var tracer = uni.requireNativePlugin("GCUniPlugin-Tracer");
let key = Utils.getUUID();//Refer to Hbuilder_Example/utils.js
var header = tracer.getTraceHeader({
      'key': key,
      'url': requestUrl,
})
uni.request({
        url: requestUrl,
        header: header,
        success() {

        },
        complete() {

        }
});

API - getTraceHeader

Gets the request headers needed for trace, which should be added to the HTTP request headers.

Field Type Required Description
key string Yes Request unique identifier
url string Yes Request URL

Return Type: object

User Information Binding and Unbinding

var ftModule = uni.requireNativePlugin("GCUniPlugin-MobileAgent");
ftModule.bindRUMUserData({
  'userId':'Test userId',
  'userName':'Test name',
  'userEmail':'test@123.com',
  'extra':{
    'age':'20'
  }
})

ftModule.unbindRUMUserData()

API - bindRUMUserData

Binds user information:

Field Type Required Description
userId string Yes User Id
userName string No User name
userEmail string No User email
extra object No User's extra information

API - unbindRUMUserData

Unbinds the current user.

Shut Down SDK

var ftModule = uni.requireNativePlugin("GCUniPlugin-MobileAgent");
ftModule.shutDown()

API - shutDown

Shuts down the SDK.

Clear SDK Cache Data

var ftModule = uni.requireNativePlugin("GCUniPlugin-MobileAgent");
ftModule.clearAllData()

API - clearAllData

Clears all data that has not yet been uploaded to the server.

Active Data Sync

var ftModule = uni.requireNativePlugin("GCUniPlugin-MobileAgent");
ftModule.flushSyncData()

API - flushSyncData

When sdkConfig.autoSync is configured as true, no additional action is needed; the SDK will sync automatically.

When sdkConfig.autoSync is configured as false, you need to actively trigger the data sync method to sync data.

WebView Data Monitoring

WebView data monitoring requires integrating the Web Monitoring SDK into the WebView access page.

Android only supports offline packaging and uni mini programs.

Data Masking

If you want to fully mask a field, it is recommended to use dataModifier for better performance. If you need detailed rule replacement, lineDataModifier is recommended.

Single Field Modification (dataModifier)

  • Function: Modifies the value of a single field in the data.
  • Parameter format: {key: newValue}
  • Example: {'device_uuid': 'xxx'} will replace the device_uuid field value in the target data with "xxx".

Single Data Line Modification (lineDataModifier)

  • Function: Modifies the specified field value in a certain type of data.
  • Parameter format: {measurement: {key: newValue}}
  • Example: {'view': {'view_url': 'xxx'}} will modify the view_url field value of all view type data to "xxx".
  • measurement data type list:
  • RUM data: view, resource, action, long_task, error
  • Log data: log
 var ftModule = uni.requireNativePlugin("GCUniPlugin-MobileAgent"); 
  ftModule.sdkConfig({
                 datakitUrl: 'your datakitUrl',
                 debug: true,
         dataModifier: { 'device_uuid':'xxx'},
         lineDataModifier:{ 'resource' :{'response_header':'xxx'},
                            'view' :{'view_url':'xxx'},
    } 
    })

Add Custom Tags

var ftModule = uni.requireNativePlugin("GCUniPlugin-MobileAgent");
ftModule.appendGlobalContext({
          'ft_global_key':'ft_global_value'
})
ftModule.appendRUMGlobalContext({
          'ft_global_rum_key':'ft_global_rum_value'
})
ftModule.appendLogGlobalContext({
          'ft_global_log_key':'ft_global_log_value'
})                

API - appendGlobalContext

Adds custom global parameters. Affects RUM and Log data.

Field Type Required Description
None object Yes Custom global parameters

API - appendRUMGlobalContext

Adds custom RUM global parameters. Affects RUM data.

Field Type Required Description
None object Yes Custom global RUM parameters

API - appendLogGlobalContext

Adds custom Log global parameters. Affects Log data.

Field Type Required Description
None object Yes Custom global Log parameters

Add BridgeContext

Supported in SDK 0.2.4 and above

 var ftModule = uni.requireNativePlugin("GCUniPlugin-MobileAgent");
 ftModule.appendBridgeContext({
            'ft_bridge_context': 'ft_bridge_context_value'
    });

API - appendBridgeContext

Only injects into RUM and log data collected by UniApp. Data collected by the Native end is not injected.

Purpose: Distinguish data sources or mark specific scenarios.

Field Type Required Description
None object Yes UniApp environment parameters

FAQ

Using the Plugin Development iOS Main Project UniPlugin-iOS

Download UniApp Offline Development SDK

According to the version number of the uni-app development tool HBuilderX, download the SDK package required for developing the plugin.

SDK Package Structure Description

|--iOSSDK   
    |-- HBuilder-Hello              // uni-app offline packaging project
    |-- HBuilder-uniPluginDemo      // uni-app plugin development main project (project needed for this document)
    |-- SDK                         // Dependency libraries and resource files

Drag the dependency libraries and resource files SDK folder into the UniPlugin-iOS folder. The directory structure after dragging should be as follows.

|-- UniPlugin-iOS
    |-- HBuilder-uniPluginDemo      // uni-app plugin development main project (project needed for this document)
    |-- SDK                         // Dependency libraries and resource files

For more details, refer to iOS Plugin Development Environment Configuration.

Project Configuration

  1. Architectures Settings

Because the simulator provided by Xcode 12 supports the arm64 architecture, and the framework provided by uni_app supports arm64 for real devices and x86_64 for simulators, set:

Excluded Architectures set Any iOS Simulator SDK: arm64.

  1. Other Linker Flags
$(inherited) -ObjC -framework "FTMobileSDK" -framework "GC_UniPlugin_App"
  1. Framework Search Paths
$(inherited)
"${PODS_CONFIGURATION_BUILD_DIR}/FTMobileSDK"
"${PODS_CONFIGURATION_BUILD_DIR}/GC-UniPlugin-App"
$(DEVELOPER_FRAMEWORKS_DIR)
$(PROJECT_DIR)/../SDK/libs
$(PROJECT_DIR)

Using the Plugin Development Android Main Project UniPlugin-Android

Project Configuration

For detailed dependency configuration, refer to the Demo. For more Gradle extension parameter configuration, refer to Android SDK

|-- UniPlugin-Android
    |-- app
        |--build.gradle
        // ---> Configure ft-plugin
        // apply:'ft-plugin'

    |-- uniplugin_module
        |-- src
            |-- main
                |-- java
                    |-- com.ft.sdk.uniapp
        |-- build.gradle 
        //---> Configure dependencies
        //implementation 'com.cloudcare.ft.mobile.sdk.tracker.agent:ft-sdk:xxxx'
        //implementation 'com.google.code.gson:gson:xxxx'
        //implementation 'com.cloudcare.ft.mobile.sdk.tracker.agent:ft-native:xxxx'

    |-- build.gradle
        //---> Configure repo
        //  maven {
        //          url 'https://mvnrepo.jiagouyun.com/repository/maven-releases'
        //  }
        //
        //--> Configure buildScrpit
        //  classpath 'com.cloudcare.ft.mobile.sdk.tracker.plugin:ft-plugin:xxxx'

Difference Between Android Cloud Build and Offline Build

Android cloud build and offline build use two different integration logics. The offline build integration method is the same as the Guance Android SDK integration method, using the Android Studio Gradle Plugin method. Cloud builds cannot use the Android Studio Gradle Plugin, so they can only implement some functions through the internal code of the Guance UniApp Native Plugin. Therefore, the offline build version has more configurable options than the cloud build version. The offlinePakcage parameter in the SDK configuration is used to distinguish between these two situations.

Others

Feedback

Is this page helpful? ×