uni-app-x API Description
1. Startup Configuration Interfaces
Plugin Startup Interface
| Parameter | Type | Description |
|---|
| appID | string | The unique application ID generated by the Bonree SDK platform |
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
Bonree.start("<#AppID#>")
Set Config Address
Used by private cloud customers to set the config address for private deployment. This interface must be called before calling start.
setConfigAddress(configAddress: string)
| Parameter | Type | Description |
|---|
| configAddress | string | Config address |
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
Bonree.setConfigAddress("<#Config Address#>")
Config Address can be obtained from the platform or by contacting technical support.
Set Log Level
setLogFlag(logFlag: number)
This method is only supported on the iOS platform.
| Parameter | Type | Description |
|---|
| logFlag | number | Log level |
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
Bonree.setLogFlag(0xffffffff)
Set App Version
The App version is obtained from the configuration file by default. If active configuration is required, call the following interface to set the version information before calling start.
setAppVersion(appVersion: string)
| Parameter | Type | Description |
|---|
| appVersion | string | The version information to set |
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
Bonree.setAppVersion("<#APP Version#>")
Set Application Environment
Use this interface to set the current application environment. This interface must be called before calling start.
setAppEnvironment(appEnvironment: string)
| Parameter | Type | Description |
|---|
| appEnvironment | string | The application environment to set |
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
Bonree.setAppEnvironment("<#APP Environment#>")
Set Download Channel Name
Call the following interface to set the channel name before calling start.
setChannelID(channelID: string)
| Parameter | Type | Description |
|---|
| channelID | string | The channel name to set |
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
Bonree.setChannelID("<#ChannelID#>")
Set Custom Device ID
Call the following interface to set the device ID before calling start.
setDeviceID(deviceID: string)
| Parameter | Type | Description |
|---|
| deviceID | string | The device ID to set |
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
Bonree.setDeviceID("<#DeviceID#>")
Custom Cold Launch End Time
To customize the cold launch end timing, the following two interfaces need to be called to complete the custom functionality. The specific usage is:
- Call the custom cold launch switch interface to enable the custom cold launch feature. (This interface must be set before the plugin starts)
useCustomLaunch(used: boolean)
| Parameter | Type | Description |
|---|
| used | boolean | Whether to use custom cold launch end time |
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
Bonree.useCustomLaunch(true)
- Call the cold launch end interface at the desired timing to record the cold launch end.
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
Bonree.recordCustomLaunchEnd()
Note: After enabling the custom cold launch feature, if the record cold launch end interface is not called within 30 seconds, the cold launch monitoring process will be forcibly terminated.
2. Data Acquisition Interfaces
Get Device ID
getDeviceID(): string|null
| Return Type | Description |
|---|
| string | The device ID generated by the embedded SDK in the plugin. If set previously, returns the set value |
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
Bonree.getDeviceID()
Get Embedded SDK Version
| Return Type | Description |
|---|
| string | The version number of the embedded SDK in the plugin |
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
Bonree.getSDKVersion()
3. Custom Function Interfaces
The plugin supports setting user-related information to fulfill scenarios where performance data needs to be associated with actual users.
There are two ways to set user information:
1. Set User ID: Identify the user using a string
setUserID(userID: string)
| Parameter | Type | Description |
|---|
| userID | string | User ID |
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
Bonree.setUserID("<#userID#>")
setUserExtraInfo(extraInfo: UTSJSONObject)
| Parameter | Type | Description |
|---|
| extraInfo | UTSJSONObject | User information |
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
let userInfo: UTSJSONObject = {
name: "Jack"
}
Bonree.setUserExtraInfo(userInfo)
addUserExtraInfo(key: string, value: any)
| Parameter | Type | Description |
|---|
| key | string | User information key |
| value | any | User information value |
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
Bonree.addUserExtraInfo("grade", "one")
removeUserExtraInfo(key: string)
| Parameter | Type | Description |
|---|
| key | string | User information key |
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
Bonree.removeUserExtraInfo("age")
increaseUserExtraInfo(key: string, value: number)
| Parameter | Type | Description |
|---|
| key | string | User information key |
| value | number | Value to accumulate |
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
Bonree.increaseUserExtraInfo("age", 20)
Custom Event Attributes
1. Add Event Common Attributes (Group)
addEventAttributes(attributes: UTSJSONObject, isLocal: boolean)
| Parameter | Type | Description |
|---|
| attributes | UTSJSONObject | Event common attributes |
| isLocal | boolean | Whether to persist to local storage |
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
let eventAttributes = {
"name": "Jack"
}
Bonree.addEventAttributes(eventAttributes, true)
2. Add Event Common Attribute (Single)
addEventAttribute(key: string, value: any, isLocal: boolean)
| Parameter | Type | Description |
|---|
| key | string | Event common attribute key |
| value | any | Event common attribute value |
| isLocal | boolean | Whether to persist to local storage |
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
Bonree.addEventAttribute("name", "Jack", false)
3. Remove Event Common Attributes
removeEventAttribute(keys: Array<string>)
| Parameter | Type | Description |
|---|
| keys | Array<string> | Keys to remove |
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
Bonree.removeEventAttribute(["name"])
4. Remove All Event Common Attributes
removeAllEventAttributes()
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
Bonree.removeAllEventAttributes()
Custom Exceptions
Call the interface with the corresponding parameters to complete the statistics collection for custom exception data.
setCustomException(exceptionType: string, causedBy: string, errorDump: string)
| Parameter | Type | Description |
|---|
| exceptionType | string | Exception type |
| causedBy | string | Cause of the exception |
| errorDump | string | Exception stack trace |
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
Bonree.setCustomException("exceptionType", "reference causedBy", "errorDump")
Custom Views
Call the interface with the corresponding parameters to complete the statistics collection for custom view data.
setCustomPageStart(pageName: string, pageAlias: string)
setCustomPageEnd(pageName: string, pageAlias: string)
| Parameter | Type | Description |
|---|
| pageName | string | Page name |
| pageAlias | string | Page alias |
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
Bonree.setCustomPageStart("page", "page-alias")
Bonree.setCustomPageEnd("page", "page-alias")
Note: The start and end recording interfaces for a custom view must be called in pairs, and the pageName for the same view must be consistent to correctly collect and report a complete custom view data.
Custom Events (Full Version)
setCustomEventStart(eventID: string, eventName: string, eventLabel: string, param: string, info: UTSJSONObject)
setCustomEventEnd(eventID: string, eventName: string, eventLabel: string, param: string, info: UTSJSONObject)
| Parameter | Type | Description |
|---|
| eventID | string | Event ID |
| eventName | string | Event name |
| eventLabel | string | Event label |
| param | string | Event additional information |
| info | UTSJSONObject | Event business information |
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
let eventAttributes = {
"name-event": "Jack"
}
Bonree.setCustomEventStart("complete-id-only", "complete-name-begin", "complete-label-begin", "complete-param-begin", eventAttributes)
Bonree.setCustomEventEnd("complete-id-only", "complete-name-end", "complete-label-end", "complete-param-end", eventAttributes)
Custom Events (Simplified Version)
Call the interface with the corresponding parameters to complete the statistics collection for custom event data.
setCustomEvent(eventID: string, eventName: string, eventLabel: string, param: string, info: UTSJSONObject)
| Parameter | Type | Description |
|---|
| eventID | string | Event ID |
| eventName | string | Event name |
| eventLabel | string | Event label |
| param | string | Event additional information |
| info | UTSJSONObject | Event business information |
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
let eventAttributes = {
"name": "Jack"
}
Bonree.setCustomEvent("id", "name", "label", "param", eventAttributes)
Custom Logs
Call the interface with the corresponding parameters to complete the statistics collection for custom log data.
setCustomLog(logInfo: string, param: string)
| Parameter | Type | Description |
|---|
| logInfo | string | Log information |
| param | string | Additional information |
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
Bonree.setCustomLog("loginfo", "noparam")
Custom Methods
Call the interface with the corresponding parameters to complete the statistics collection for custom method data.
setCustomMethodStart(methodName: string, param: string)
setCustomMethodEnd(methodName: string, param: string)
| Parameter | Type | Description |
|---|
| methodName | string | Method name |
| param | string | Additional information |
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
Bonree.setCustomMethodStart("name", "param")
Bonree.setCustomMethodEnd("name", "param")
Call the interface with the corresponding parameters to associate custom string information with matched network data.
setRequestExtraInfo(headerKey: string, value: string, info: string)
| Parameter | Type | Description |
|---|
| headerKey | string | Request header Key to match |
| value | string | Request header Value to match |
| info | string | Associated custom information |
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
Bonree.setRequestExtraInfo("key", "value", "info")
Custom Metrics
Call the interface with the corresponding parameters to complete the statistics collection for custom metric data.
setCustomMetric(metricName: string, metricValue: Int, param: string)
| Parameter | Type | Description |
|---|
| metricName | string | Metric name |
| metricValue | Int | Metric value |
| param | string | Additional information |
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
Bonree.setCustomMetric("name", 999, "param")