Skip to main content
Version: 3.7.0

uni-app-x API Description

1. Startup Configuration Interfaces

Plugin Startup Interface

start(appID: string)
  • Interface Description
ParameterTypeDescription
appIDstringThe unique application ID generated by the Bonree SDK platform
  • Example
// Import plugin
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// 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: string)
  • Interface Description
ParameterTypeDescription
configAddressstringConfig address
  • Example
// Import plugin
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// Call method
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.

  • Interface Description
ParameterTypeDescription
logFlagnumberLog level
  • Example
// Import plugin
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// 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: string)
  • Interface Description
ParameterTypeDescription
appVersionstringThe version information to set
  • Example
// Import plugin
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// 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: string)
  • Interface Description
ParameterTypeDescription
appEnvironmentstringThe application environment to set
  • Example
// Import plugin
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// Call method
Bonree.setAppEnvironment("<#APP Environment#>")

Set Download Channel Name

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

setChannelID(channelID: string)
  • Interface Description
ParameterTypeDescription
channelIDstringThe channel name to set
  • Example
// Import plugin
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// Call method
Bonree.setChannelID("<#ChannelID#>")

Set Custom Device ID

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

setDeviceID(deviceID: string)
  • Interface Description
ParameterTypeDescription
deviceIDstringThe device ID to set
  • Example
// Import plugin
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// 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: boolean)
  • Interface Description
ParameterTypeDescription
usedbooleanWhether to use custom cold launch end time
  • Example
// Import plugin
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// 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
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// 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(): string|null
  • 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
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// Call method
Bonree.getDeviceID()

Get Embedded SDK Version

getSDKVersion(): string
  • Interface Description
Return TypeDescription
stringThe version number of the embedded SDK in the plugin
  • Example
// Import plugin
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// 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: string)
  • Interface Description
ParameterTypeDescription
userIDstringUser ID
  • Example
// Import plugin
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// Call
Bonree.setUserID("<#userID#>")

2. Set User Additional Information

setUserExtraInfo(extraInfo: UTSJSONObject)
  • Interface Description
ParameterTypeDescription
extraInfoUTSJSONObjectUser information
  • Example
// Import plugin
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// Call
let userInfo: UTSJSONObject = {
name: "Jack"
}
Bonree.setUserExtraInfo(userInfo)

3. Add User Additional Information

addUserExtraInfo(key: string, value: any)
  • Interface Description
ParameterTypeDescription
keystringUser information key
valueanyUser information value
  • Example
// Import plugin
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// Call
Bonree.addUserExtraInfo("grade", "one")

4. Remove User Additional Information

removeUserExtraInfo(key: string)
  • Interface Description
ParameterTypeDescription
keystringUser information key
  • Example
// Import plugin
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// Call
Bonree.removeUserExtraInfo("age")

5. Accumulate User Additional Information

increaseUserExtraInfo(key: string, value: number)
  • Interface Description
ParameterTypeDescription
keystringUser information key
valuenumberValue to accumulate
  • Example
// Import plugin
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// Call
Bonree.increaseUserExtraInfo("age", 20)

Custom Event Attributes

1. Add Event Common Attributes (Group)

addEventAttributes(attributes: UTSJSONObject, isLocal: boolean) 
  • Interface Description
ParameterTypeDescription
attributesUTSJSONObjectEvent common attributes
isLocalbooleanWhether to persist to local storage
  • Example
// Import plugin
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// Call
let eventAttributes = {
"name": "Jack"
}
Bonree.addEventAttributes(eventAttributes, true)

2. Add Event Common Attribute (Single)

addEventAttribute(key: string, value: any, isLocal: boolean)
  • Interface Description
ParameterTypeDescription
keystringEvent common attribute key
valueanyEvent common attribute value
isLocalbooleanWhether to persist to local storage
  • Example
// Import plugin
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// Call
Bonree.addEventAttribute("name", "Jack", false)

3. Remove Event Common Attributes

removeEventAttribute(keys: Array<string>)
  • Interface Description
ParameterTypeDescription
keysArray<string>Keys to remove
  • Example
// Import plugin
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// Call
Bonree.removeEventAttribute(["name"])

4. Remove All Event Common Attributes

removeAllEventAttributes()
  • Example
// Import plugin
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// Call
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)
  • Interface Description
ParameterTypeDescription
exceptionTypestringException type
causedBystringCause of the exception
errorDumpstringException stack trace
  • Example
// Import plugin
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// 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: string, pageAlias: string)
// Custom view end
setCustomPageEnd(pageName: string, pageAlias: string)
  • Interface Description
ParameterTypeDescription
pageNamestringPage name
pageAliasstringPage alias
  • Example
// Import plugin
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// 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: string, eventName: string, eventLabel: string, param: string, info: UTSJSONObject)
// Custom event end
setCustomEventEnd(eventID: string, eventName: string, eventLabel: string, param: string, info: UTSJSONObject)
  • Interface Description
ParameterTypeDescription
eventIDstringEvent ID
eventNamestringEvent name
eventLabelstringEvent label
paramstringEvent additional information
infoUTSJSONObjectEvent business information
  • Example
// Import plugin
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// 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: string, eventName: string, eventLabel: string, param: string, info: UTSJSONObject)
  • Interface Description
ParameterTypeDescription
eventIDstringEvent ID
eventNamestringEvent name
eventLabelstringEvent label
paramstringEvent additional information
infoUTSJSONObjectEvent business information
  • Example
// Import plugin
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// 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: string, param: string) 
  • Interface Description
ParameterTypeDescription
logInfostringLog information
paramstringAdditional information
  • Example
// Import plugin
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// 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: string, param: string)
// Custom method end
setCustomMethodEnd(methodName: string, param: string)
  • Interface Description
ParameterTypeDescription
methodNamestringMethod name
paramstringAdditional information
  • Example
// Import plugin
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// 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: string, value: string, info: string)
  • Interface Description
ParameterTypeDescription
headerKeystringRequest header Key to match
valuestringRequest header Value to match
infostringAssociated custom information
  • Example
// Import plugin
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// 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: string, metricValue: Int, param: string)
  • Interface Description
ParameterTypeDescription
metricNamestringMetric name
metricValueIntMetric value
paramstringAdditional information
  • Example
// Import plugin
import { Bonree } from '@/uni_modules/bonree-unix-plugin';
// Call
Bonree.setCustomMetric("name", 999, "param")