Skip to main content
Version: 3.7.0

uni-app API Description

1. Startup Configuration Interfaces

Plugin Startup Interface

start(appID)
  • Interface Description
ParameterTypeDescription
appIDStringThe unique application ID generated by the Bonree SDK platform
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call method
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)
  • Interface Description
ParameterTypeDescription
configAddressStringConfig address
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call method
Bonree.setConfigAddress("<#Config Address#>")

Config Address can be obtained from the platform or by contacting technical support.

Set Log Level

setLogFlag(logFlag)

This method is only supported on the iOS platform.

  • Interface Description
ParameterTypeDescription
logFlagNumberLog level
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call method
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)
  • Interface Description
ParameterTypeDescription
appVersionStringThe version information to set
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call method
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)
  • Interface Description
ParameterTypeDescription
appEnvironmentStringThe application environment to set
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call method
Bonree.setAppEnvironment("<#APP Environment#>")

Set Download Channel Name

Call the following interface to set the channel name before calling start.

setChannelID(channelID)
  • Interface Description
ParameterTypeDescription
channelIDStringThe channel name to set
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call method
Bonree.setChannelID("<#ChannelID#>")

Set Custom Device ID

Call the following interface to set the device ID before calling start.

setDeviceID(deviceID)
  • Interface Description
ParameterTypeDescription
deviceIDStringThe device ID to set
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call method
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:

  1. 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)
  • Interface Description
ParameterTypeDescription
usedBooleanWhether to use custom cold launch end time
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call method
Bonree.useCustomLaunch(true)
  1. Call the cold launch end interface at the desired timing to record the cold launch end.
recordCustomLaunchEnd()
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call method
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()
  • Interface Description
Return TypeDescription
StringThe device ID generated by the embedded SDK in the plugin. If set previously, returns the set value
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call method
Bonree.getDeviceID()

Get Embedded SDK Version

getSDKVersion()
  • Interface Description
Return TypeDescription
StringThe version number of the embedded SDK in the plugin
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call method
Bonree.getSDKVersion()

3. Custom Function Interfaces

Custom User Information

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)
  • Interface Description
ParameterTypeDescription
userIDStringUser ID
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call
Bonree.setUserID("<#userID#>")

2. Set User Additional Information

setUserExtraInfo(extraInfo)
  • Interface Description
ParameterTypeDescription
extraInfoObjectUser information
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call
let userInfo = {
name: "Jack"
}
Bonree.setUserExtraInfo(userInfo)

3. Add User Additional Information

addUserExtraInfo(key, value)
  • Interface Description
ParameterTypeDescription
keyStringUser information key
valueObjectUser information value
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call
Bonree.addUserExtraInfo("grade", "one")

4. Remove User Additional Information

removeUserExtraInfo(key)
  • Interface Description
ParameterTypeDescription
keyStringUser information key
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call
Bonree.removeUserExtraInfo("age")

5. Accumulate User Additional Information

increaseUserExtraInfo(key, value)
  • Interface Description
ParameterTypeDescription
keyStringUser information key
valueNumberValue to accumulate
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call
Bonree.increaseUserExtraInfo("age", 20)

Custom Event Attributes

1. Add Event Common Attributes (Group)

addEventAttributes(attributes, isLocal) 
  • Interface Description
ParameterTypeDescription
attributesObjectEvent common attributes
isLocalBooleanWhether to persist to local storage
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call
let eventAttributes = {
"name": "Jack"
}
Bonree.addEventAttributes(eventAttributes, true)

2. Add Event Common Attribute (Single)

addEventAttribute(key, value, isLocal)
  • Interface Description
ParameterTypeDescription
keyStringEvent common attribute key
valueObjectEvent common attribute value
isLocalBooleanWhether to persist to local storage
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call
Bonree.addEventAttribute("name", "Jack", false)

3. Remove Event Common Attributes

removeEventAttribute(keys)
  • Interface Description
ParameterTypeDescription
keysArrayKeys to remove
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call
Bonree.removeEventAttribute(["name"])

4. Remove All Event Common Attributes

removeAllEventAttributes()
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call
Bonree.removeAllEventAttributes()

Custom Exceptions

Call the interface with the corresponding parameters to complete the statistics collection for custom exception data.

setCustomException(exceptionType, causedBy, errorDump)
  • Interface Description
ParameterTypeDescription
exceptionTypeStringException type. Required parameter
causedByStringCause of the exception
errorDumpStringException stack trace
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call
Bonree.setCustomException("exceptionType", "reference causedBy", "errorDump")

Custom Views

Call the interface with the corresponding parameters to complete the statistics collection for custom view data.

// Custom view start
setCustomPageStart(pageName, pageAlias)
// Custom view end
setCustomPageEnd(pageName, pageAlias)
  • Interface Description
ParameterTypeDescription
pageNameStringPage name. Required parameter
pageAliasStringPage alias
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call
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)

// Custom event start
setCustomEventStart(eventID, eventName, eventLabel, param, info)
// Custom event end
setCustomEventEnd(eventID, eventName, eventLabel, param, info)
  • Interface Description
ParameterTypeDescription
eventIDStringEvent ID. Required parameter
eventNameStringEvent name
eventLabelStringEvent label
paramStringEvent additional information
infoObjectEvent business information
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call
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)
  • Interface Description
ParameterTypeDescription
eventIDStringEvent ID. Required parameter
eventNameStringEvent name
eventLabelStringEvent label
paramStringEvent additional information
infoObjectEvent business information
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call
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) 
  • Interface Description
ParameterTypeDescription
logInfoStringLog information. Required parameter
paramStringAdditional information
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call
Bonree.setCustomLog("loginfo", "noparam")

Custom Methods

Call the interface with the corresponding parameters to complete the statistics collection for custom method data.

// Custom method start
setCustomMethodStart(methodName, param)
// Custom method end
setCustomMethodEnd(methodName, param)
  • Interface Description
ParameterTypeDescription
methodNameStringMethod name. Required parameter
paramStringAdditional information
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call
Bonree.setCustomMethodStart("name", "param")
Bonree.setCustomMethodEnd("name", "param")

Set Custom Request Information Interface

Call the interface with the corresponding parameters to associate custom string information with matched network data.

setRequestExtraInfo(headerKey, value, info)
  • Interface Description
ParameterTypeDescription
headerKeyStringRequest header Key to match. Required parameter
valueStringRequest header Value to match. Required parameter
infoStringAssociated custom information
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call
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)
  • Interface Description
ParameterTypeDescription
metricNameStringMetric name. Required parameter
metricValueNumberMetric value. Required parameter
paramStringAdditional information
  • Example
// Import plugin
var Bonree = uni.requireNativePlugin("BonreeUniAppNativePlugin")
// Call
Bonree.setCustomMetric("name", 999, "param")