Skip to main content
Version: 3.7.0

Weex API Description

1. Startup Configuration Interfaces

<#Config Address#> and <#AppID#> can be obtained from the platform. For the method to obtain them, please refer to How to Query AppID and Config Address?. If you have any questions, please contact technical support.

BonreeSDK Startup Interface

function start();
  • Interface Description
ParameterTypeDescription
appIDStringThe unique application ID generated by the Bonree SDK platform
VueObjectThe Vue instance of the current environment
  • Example

    Bonree.start("<#AppID#>", Vue);

Set Config Address

Used by private cloud customers to set the config address for private deployment. This interface must be called before calling start.

function setConfigAddress()
  • Interface Description
ParameterTypeDescriptionParameter Restrictions
configAddressStringConfig addressString length must be greater than 0 and less than or equal to 2083, otherwise the interface call fails
  • Example

    Bonree.setConfigAddress("<#Config Address#>");

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.

function setAppVersion();
  • Interface Description
ParameterTypeDescriptionParameter Restrictions
appVersionStringThe version information to setString length must be greater than 0 and less than or equal to 64, otherwise the interface call fails
  • Example

    Bonree.setAppVersion("3.2.1");

Set Download Channel Name

If active configuration is required, call the following interface to set the channel name before calling start.

function setChannelID();
  • Interface Description
ParameterTypeDescriptionParameter Restrictions
channelIDStringThe channel name to setString length must be greater than 0 and less than or equal to 256, otherwise the interface call fails
  • Example

    Bonree.setChannelID("AppStore");

Set Custom Device ID

The device ID (deviceID) is generated and saved by the SDK by default. If active configuration is required, call the following interface to set the device ID before calling start.

function setDeviceID();
  • Interface Description
ParameterTypeDescriptionParameter Restrictions
deviceIDStringThe device ID to setString length must be greater than 0 and less than or equal to 256, and must not contain special characters (only letters, numbers, underscore _, and hyphen - are supported), otherwise the interface call fails
  • Example

    Bonree.setDeviceID("0123456789");

Set Continuous Frame Drop Time

Set the continuous frame drop time required to determine stuttering. This interface must be called before calling start.

function setDropFrameTime();
  • Interface Description
ParameterTypeDescription
timeIntContinuous frame drop time (s), 0 < dropFrameTime <= 30. If not set, defaults to 5s.
  • Example

    Bonree.setDropFrameTime(5);

Custom Cold Launch End Time

To customize the cold launch end timing, the following two interfaces can 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 calling start)
  2. Call the cold launch end interface at the desired timing to record the cold launch end.
// Indicate the use of custom cold launch end time (must be set before calling start)
function useCustomLaunch();
  • Interface Description
ParameterTypeDescription
usedBOOLWhether to use custom cold launch end time
// Record cold launch end
function recordCustomLaunchEnd();
  • Example

    // Must be set before calling start
    Bonree.useCustomLaunch(true);

    // ...

    // Call at the desired timing
    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.

Set SDK Request Headers

Call this interface to add information to the request headers of requests initiated by the SDK itself. This interface must be called before calling start.

function setSDKRequestHeaders();
  • Interface Description
ParameterTypeDescription
headersObjectThe key-value pairs of request headers to set (maximum 64 pairs, key length limited to 256 characters, value length limited to 512 characters)
  • Example

    Bonree.setSDKRequestHeaders(
    {
    "headerKey0":"headerValue0",
    "headerKey1":"headerValue1"
    }
    );

2. Data Acquisition Interfaces

Get Device ID

By default, the unique device ID is generated and persistently maintained internally by BonreeSDK to identify the device that generates various performance data. We provide an interface to obtain this device ID to support scenarios such as autonomous correlation of monitoring data at the device level.

function getDeviceID();
  • Interface Description
Return TypeDescription
StringThe device ID generated by the SDK. If set previously, returns the set value.
  • Example

    var deviceID = Bonree.getDeviceID();

Get SDK Version

This interface returns the native agent version number. Note that the returned values may differ between Android and iOS.

function getSDKVersion();
  • Interface Description
Return TypeDescription
StringThe version number of the SDK
  • Example

    var version = Bonree.getSDKVersion();

3. Custom Function Interfaces

Custom User Information

BonreeSDK 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. The interface is as follows:

function setUserID();
  • Interface Description
ParameterTypeDescriptionParameter Restrictions
userIDStringUser IDCan be empty or an empty string.
String length must be less than or equal to 256 and must not contain special characters (only letters, numbers, underscore _, and hyphen - are supported), otherwise the interface call fails.
  • Example
    Bonree.setUserID("user-id");

2. Set user additional information in Key-Value form. The interface is as follows:

// Set additional information
function setExtraInfo();
  • Interface Description
ParameterTypeDescriptionParameter Restrictions
extraInfoObjectUser additional information.Can be empty or an empty Map.
The length after converting to JSON must be within 7000 characters, otherwise the interface call fails.
  • Example

    Bonree.setExtraInfo(
    {
    "id":"123456",
    "name":"Tom"
    }
    );

Custom Exceptions

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

function setCustomException();
  • Interface Description
ParameterTypeDescriptionParameter Restrictions
exceptionTypeStringException type. Required parameter. Interface call is invalid if empty or null.String length must be greater than 0 and less than or equal to 256, otherwise the interface call fails.
causedByStringCause of the exceptionCan be empty or an empty string.
String length less than or equal to 512, truncated if too long.
errorDumpStringException stack traceWill be truncated if exceeding 10000 characters
  • Example

    Bonree.setCustomException("Custom exception type", "Caused by customer.", "Custom error dump 0\nCustom error dump 1");

Custom Views

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

// Custom View - Mark View Start (called in pair with the view end method)
function setCustomPageStart();
// Custom View - Mark View End (called in pair with the view start method)
function setCustomPageEnd();
  • Interface Description
ParameterTypeDescriptionParameter Restrictions
pageNameStringPage name. Required parameter. Interface call is invalid if empty or null.String length must be greater than 0 and less than or equal to 256, otherwise the interface call fails.
pageAliasStringPage aliasCan be empty or an empty string.
String length less than or equal to 256, truncated if too long.
  • Example

    Bonree.setCustomPageStart("page01", "Home Page");

    Bonree.setCustomPageEnd("page01", "Home Page");

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)

Call the start and end interfaces respectively with the corresponding parameters to complete the statistics collection for custom event data and event duration.

// Custom event start
function setCustomEventStart();
// Custom event end
function setCustomEventEnd();
  • Interface Description
ParameterTypeDescriptionParameter Restrictions
eventIDStringEvent ID. Required parameter. Interface call is invalid if empty or null.String length must be greater than 0 and less than or equal to 256, otherwise the interface call fails.
eventNameStringEvent nameCan be empty or an empty string.
String length less than or equal to 256, truncated if too long.
eventLabelStringEvent labelCan be empty or an empty string.
String length less than or equal to 256, truncated if too long.
paramStringEvent additional informationCan be empty or an empty string.
String length less than or equal to 7000, truncated if too long.
infoObjectEvent business informationCan be empty.
The length after converting to JSON must be within 7000 characters, otherwise the interface call fails.
  • Example

    Bonree.setCustomEventStart("001", "User Login", "Login", "", {"text":"Login"});
    // Some code...
    Bonree.setCustomEventEnd("001", "User Login", "Login", "", {"text":"Login"});

Note: The start and end of a custom event are matched uniquely by eventID. Please ensure the uniqueness of the event ID for unfinished events.

Custom Events (Simplified Version)

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

function setCustomEvent();
  • Interface Description
ParameterTypeDescriptionParameter Restrictions
eventIDStringEvent ID. Required parameter. Interface call is invalid if empty or null.String length must be greater than 0 and less than or equal to 256, otherwise the interface call fails.
eventNameStringEvent nameCan be empty or an empty string.
String length less than or equal to 256, truncated if too long.
eventLabelStringEvent labelCan be empty or an empty string.
String length less than or equal to 256, truncated if too long.
paramStringEvent additional informationCan be empty or an empty string.
String length less than or equal to 7000, truncated if too long.
infoObjectEvent business informationCan be empty.
The length after converting to JSON must be within 7000 characters, otherwise the interface call fails.
  • Example

    Bonree.setCustomEvent("001", "User Login", "Login", "", {"text":"Login"});

Custom Logs

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

function setCustomLog();
  • Interface Description
ParameterTypeDescriptionParameter Restrictions
logInfoStringLog information. Required parameter. Interface call is invalid if empty or null.String length must be greater than 0, otherwise the interface call fails.
String length less than or equal to 10000, truncated if too long.
paramStringAdditional information (reserved field, no current usage scenario)-
  • Example

    Bonree.setCustomLog("2020-01-01 08:30:00 Print log info.", "");

Custom Metrics

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

function setCustomMetric();
  • Interface Description
ParameterTypeDescriptionParameter Restrictions
metricNameStringMetric name. Required parameter. Interface call is invalid if empty or null.String length must be greater than 0 and less than or equal to 256, otherwise the interface call fails.
metricValueIntMetric value. Required parameter. Interface call is invalid if the metric is empty.-
paramStringAdditional information (reserved field, no current usage scenario)-
  • Example

    Bonree.setCustomMetric("Test Metric 01", 1, "");

Custom Methods

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

// Custom method start
function setCustomMethodStart();

// Custom method end
function setCustomMethodEnd();
  • Interface Description
ParameterTypeDescriptionParameter Restrictions
methodNameStringMethod name. Required parameter. Interface call is invalid if empty or null.String length must be greater than 0 and less than or equal to 256, otherwise the interface call fails.
paramStringAdditional information (reserved field, no current usage scenario)-
  • Example

    Bonree.setCustomMethodStart("testCustomMethod", "");

    // Do something...

    Bonree.setCustomMethodEnd("testCustomMethod", "");

Note: Custom methods use the method name parameter to match the front and back calls of the same method. Please ensure the method name is unique during execution.

Set Custom Request Information Interface

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

function setRequestExtraInfo();
  • Interface Description
ParameterTypeDescriptionParameter Restrictions
headerKeyStringRequest header Key to match. Required parameter. Interface call is invalid if empty or null.String length must be greater than 0 and less than or equal to 256, otherwise the interface call fails.
valueStringRequest header Value to match. Required parameter. Interface call is invalid if empty or null.String length must be greater than 0 and less than or equal to 256, otherwise the interface call fails.
infoStringAssociated custom information. If empty, clears the information cached for the corresponding key-value.String length must be greater than 0 and less than or equal to 256. If empty, clears the information cached for the corresponding key-value.
  • Example

    Bonree.setRequestExtraInfo("brkey", "30F032AA-7837-479E-971D-E382B0F90D9B", "name=TOM&age=12");

Before using this interface, ensure that the target request has a unique identifier in its request header. For example, a request header might look like:

POST /upload HTTP/1.1
Host: sdkupload.bonree.com
Content-Type: application/json
Content-Length: 781
Connection: keep-alive
Br-Content-Encoding: gzip
brkey: 30F032AA-7837-479E-971D-E382B0F90D9B

Here, brkey is the unique identifier field for this request. To associate information with this request:

name=TOM&age=12

You need to call the following before the request is sent:

Bonree.setRequestExtraInfo("brkey", "30F032AA-7837-479E-971D-E382B0F90D9B", "name=TOM&age=12");