1. Startup Configuration Interfaces
Plugin Startup Interface
| Parameter | Type | Description |
|---|
| appID | String | The unique application ID generated by the Bonree SDK platform |
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
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)
| Parameter | Type | Description |
|---|
| configAddress | String | Config address |
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
Bonree.setConfigAddress("<#Config Address#>")
Config Address can be obtained from the platform or by contacting technical support.
Set Log Level
This method is only supported on the iOS platform.
| Parameter | Type | Description |
|---|
| logFlag | Number | Log level |
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
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)
| Parameter | Type | Description |
|---|
| appVersion | String | The version information to set |
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
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)
| Parameter | Type | Description |
|---|
| appEnvironment | String | The application environment to set |
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
Bonree.setAppEnvironment("<#APP Environment#>")
Set Download Channel Name
Call the following interface to set the channel name before calling start.
| Parameter | Type | Description |
|---|
| channelID | String | The channel name to set |
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
Bonree.setChannelID("<#ChannelID#>")
Set Custom Device ID
Call the following interface to set the device ID before calling start.
| Parameter | Type | Description |
|---|
| deviceID | String | The device ID to set |
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
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)
| Parameter | Type | Description |
|---|
| used | Boolean | Whether to use custom cold launch end time |
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
Bonree.useCustomLaunch(true)
- Call the cold launch end interface at the desired timing to record the cold launch end.
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
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
| Return Type | Description |
|---|
| String | The device ID generated by the embedded SDK in the plugin. If set previously, returns the set value |
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
Bonree.getDeviceID()
Get Embedded SDK Version
| Return Type | Description |
|---|
| String | The version number of the embedded SDK in the plugin |
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
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
| Parameter | Type | Description |
|---|
| userID | String | User ID |
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
Bonree.setUserID("<#userID#>")
setUserExtraInfo(extraInfo)
| Parameter | Type | Description |
|---|
| extraInfo | Object | User information |
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
let userInfo = {
name: "Jack"
}
Bonree.setUserExtraInfo(userInfo)
addUserExtraInfo(key, value)
| Parameter | Type | Description |
|---|
| key | String | User information key |
| value | Object | User information value |
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
Bonree.addUserExtraInfo("grade", "one")
| Parameter | Type | Description |
|---|
| key | String | User information key |
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
Bonree.removeUserExtraInfo("age")
increaseUserExtraInfo(key, value)
| Parameter | Type | Description |
|---|
| key | String | User information key |
| value | Number | Value to accumulate |
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
Bonree.increaseUserExtraInfo("age", 20)
Custom Event Attributes
1. Add Event Common Attributes (Group)
addEventAttributes(attributes, isLocal)
| Parameter | Type | Description |
|---|
| attributes | Object | Event common attributes |
| isLocal | Boolean | Whether to persist to local storage |
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
let eventAttributes = {
"name": "Jack"
}
Bonree.addEventAttributes(eventAttributes, true)
2. Add Event Common Attribute (Single)
addEventAttribute(key, value, isLocal)
| Parameter | Type | Description |
|---|
| key | String | Event common attribute key |
| value | Object | Event common attribute value |
| isLocal | Boolean | Whether to persist to local storage |
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
Bonree.addEventAttribute("name", "Jack", false)
3. Remove Event Common Attributes
removeEventAttribute(keys)
| Parameter | Type | Description |
|---|
| keys | Array | Keys to remove |
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
Bonree.removeEventAttribute(["name"])
4. Remove All Event Common Attributes
removeAllEventAttributes()
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
Bonree.removeAllEventAttributes()
Custom Exceptions
Call the interface with the corresponding parameters to complete the statistics collection for custom exception data.
setCustomException(exceptionType, causedBy, errorDump)
| Parameter | Type | Description |
|---|
| exceptionType | String | Exception type. Required parameter |
| causedBy | String | Cause of the exception |
| errorDump | String | Exception stack trace |
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
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, pageAlias)
setCustomPageEnd(pageName, pageAlias)
| Parameter | Type | Description |
|---|
| pageName | String | Page name. Required parameter |
| pageAlias | String | Page alias |
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
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, eventName, eventLabel, param, info)
setCustomEventEnd(eventID, eventName, eventLabel, param, info)
| Parameter | Type | Description |
|---|
| eventID | String | Event ID. Required parameter |
| eventName | String | Event name |
| eventLabel | String | Event label |
| param | String | Event additional information |
| info | Object | Event business information |
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
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, eventName, eventLabel, param, info)
| Parameter | Type | Description |
|---|
| eventID | String | Event ID. Required parameter |
| eventName | String | Event name |
| eventLabel | String | Event label |
| param | String | Event additional information |
| info | Object | Event business information |
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
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, param)
| Parameter | Type | Description |
|---|
| logInfo | String | Log information. Required parameter |
| param | String | Additional information |
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
Bonree.setCustomLog("loginfo", "noparam")
Custom Methods
Call the interface with the corresponding parameters to complete the statistics collection for custom method data.
setCustomMethodStart(methodName, param)
setCustomMethodEnd(methodName, param)
| Parameter | Type | Description |
|---|
| methodName | String | Method name. Required parameter |
| param | String | Additional information |
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
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, value, info)
| Parameter | Type | Description |
|---|
| headerKey | String | Request header Key to match. Required parameter |
| value | String | Request header Value to match. Required parameter |
| info | String | Associated custom information |
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
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, metricValue, param)
| Parameter | Type | Description |
|---|
| metricName | String | Metric name. Required parameter |
| metricValue | Number | Metric value. Required parameter |
| param | String | Additional information |
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
Bonree.setCustomMetric("name", 999, "param")