Skip to content

RUM Configuration

RUM Initialization Configuration

var rum = uni.requireNativePlugin("GCUniPlugin-RUM");
rum.setConfig({
    androidAppId: 'YOUR_ANDROID_APP_ID',
    iOSAppId: 'YOUR_IOS_APP_ID',
    errorMonitorType: 'all',
    deviceMonitorType: ['cpu', 'memory']
});
Parameter Name Parameter Type Required Description
androidAppId string Yes Android platform appId
iOSAppId string Yes iOS platform appId
samplerate number No Sampling rate, range [0,1], default 1
sessionOnErrorSampleRate number No Error collection rate, range [0,1], default 0, supported in SDK 0.2.2 and above
enableNativeUserAction boolean No Whether to enable Native Action tracking. It is recommended to turn off for pure uni-app applications. Not supported for Android cloud packaging.
enableNativeUserResource boolean No Whether to enable Native Resource automatic tracking. Not supported for Android cloud packaging. Since uni-app initiates network requests through system APIs on iOS, enabling this will automatically collect iOS requests. Please disable manual Resource collection on the iOS side at this time to avoid duplicate collection.
enableNativeUserView boolean No Whether to enable Native View automatic tracking. It is recommended to turn off for pure uni-app applications.
errorMonitorType string/array No Error supplementary monitoring types: all, battery, memory, cpu
deviceMonitorType string/array No Page monitoring types: all, battery (Android only), memory, cpu, fps
detectFrequency string No Page monitoring frequency: normal, frequent, rare
globalContext object No Custom global parameters, special key: track_id
enableResourceHostIP boolean No Whether to collect target domain IP, only affects default collection when enableNativeUserResource = true
enableTrackNativeCrash boolean No Whether to enable Android Java Crash and OC/C/C++ crash monitoring
enableTrackNativeAppANR boolean No Whether to enable Native ANR monitoring
enableTrackNativeFreeze boolean No Whether to collect Native Freeze
nativeFreezeDurationMs number No Native Freeze threshold, range [100,), unit milliseconds
rumDiscardStrategy string No Discard strategy: discard, discardOldest
rumCacheLimitCount number No Local cache maximum RUM entry count limit, default 100000
enableTraceWebView boolean No Whether to enable WebView data collection through native SDK, default true, supported in SDK 0.2.6 and above
allowWebViewHost array No List of WebView hosts allowed for data tracking, full collection when null

RUM User Data Tracking

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

Action

API - startAction

Start a RUM Action.

RUM will bind Resource, Error, and LongTask events that may be triggered during this Action. Avoid calling multiple times within 0.1s. Only one Action is associated with the same View at the same time. If a previous Action has not ended, a new Action will be discarded. It does not affect addAction.

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

API - addAction

Add an Action event. This type of data cannot be associated with Error, Resource, or LongTask, 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

View

Automatic Collection

It is recommended to import and call the collection method in the project's main.js:

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

gcViewTracking.startTracking();

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

// step 1. Add GC-JSPlugin to the project uni_modules
// step 2. Add Router monitoring in App.vue
<script>
import { gcWatchRouter } from '@/uni_modules/GC-JSPlugin';
export default {
    mixins: [gcWatchRouter],
}
</script>
// step 3. Add pageMixin to the first page page
<script>
import { gcPageMixin } from '@/uni_modules/GC-JSPlugin';
export default {
    mixins: [gcPageMixin],
}
</script>

Method 3: Only collect specified pages. Refer to the SDK package example project Hbuilder_Example/pages/rum/index.vue:

<script>
import { gcPageViewMixinOnly } from '@/uni_modules/GC-JSPlugin';
export default {
    mixins: [gcPageViewMixinOnly],
}
</script>

Manual Collection

rum.onCreateView({
    viewName: 'Current Page Name',
    loadTime: 100000000
});

rum.startView('Current Page Name');
rum.stopView();

API - onCreateView

Create a page load duration record.

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

API - startView

Enter a page.

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

API - stopView

Leave a page.

Field Type Required Description
property object No Event context

Error

Automatic Collection

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

gcErrorTracking.startTracking();

Manual Collection

rum.addError({
    message: 'Error message',
    stack: 'Error stack'
});

API - addError

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

Resource

Automatic Collection

The SDK provides gcRequest.request, which inherits from uni.request, and can replace the original request method to collect Resource data.

+ import { gcRequest } from '@/uni_modules/GC-JSPlugin';
- uni.request({
+ gcRequest.request({
  // ...
});
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');
    }
});
Extra Field Type Required Description
filterPlatform array No After enabling enableNativeUserResource, to avoid duplicate automatic and manual collection on iOS, you can set filterPlatform: ["ios"] to disable manual collection on iOS.

Manual Collection

Implement manually by calling startResource, stopResource, addResource. Refer to GCRequest.js.

API - startResource

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

API - stopResource

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

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 header
responseHeader object Response header
responseBody string Response result
resourceStatus string Request result status code