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
| Parameter | Type | Description |
|---|---|---|
| appID | String | The unique application ID generated by the Bonree SDK platform |
| Vue | Object | The 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
| Parameter | Type | Description | Parameter Restrictions |
|---|---|---|---|
| configAddress | String | Config address | String 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
| Parameter | Type | Description | Parameter Restrictions |
|---|---|---|---|
| appVersion | String | The version information to set | String 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
| Parameter | Type | Description | Parameter Restrictions |
|---|---|---|---|
| channelID | String | The channel name to set | String 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
| Parameter | Type | Description | Parameter Restrictions |
|---|---|---|---|
| deviceID | String | The device ID to set | String 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
| Parameter | Type | Description |
|---|---|---|
| time | Int | Continuous 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:
- Call the custom cold launch switch interface to enable the custom cold launch feature. (This interface must be set before calling
start) - 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
| Parameter | Type | Description |
|---|---|---|
| used | BOOL | Whether 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
| Parameter | Type | Description |
|---|---|---|
| headers | Object | The 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 Type | Description |
|---|---|
| String | The 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 Type | Description |
|---|---|
| String | The 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
| Parameter | Type | Description | Parameter Restrictions |
|---|---|---|---|
| userID | String | User ID | Can 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
| Parameter | Type | Description | Parameter Restrictions |
|---|---|---|---|
| extraInfo | Object | User 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
| Parameter | Type | Description | Parameter Restrictions |
|---|---|---|---|
| exceptionType | String | Exception 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. |
| causedBy | String | Cause of the exception | Can be empty or an empty string. String length less than or equal to 512, truncated if too long. |
| errorDump | String | Exception stack trace | Will 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
| Parameter | Type | Description | Parameter Restrictions |
|---|---|---|---|
| pageName | String | Page 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. |
| pageAlias | String | Page alias | Can 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
pageNamefor 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
| Parameter | Type | Description | Parameter Restrictions |
|---|---|---|---|
| eventID | String | Event 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. |
| eventName | String | Event name | Can be empty or an empty string. String length less than or equal to 256, truncated if too long. |
| eventLabel | String | Event label | Can be empty or an empty string. String length less than or equal to 256, truncated if too long. |
| param | String | Event additional information | Can be empty or an empty string. String length less than or equal to 7000, truncated if too long. |
| info | Object | Event business information | Can 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
| Parameter | Type | Description | Parameter Restrictions |
|---|---|---|---|
| eventID | String | Event 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. |
| eventName | String | Event name | Can be empty or an empty string. String length less than or equal to 256, truncated if too long. |
| eventLabel | String | Event label | Can be empty or an empty string. String length less than or equal to 256, truncated if too long. |
| param | String | Event additional information | Can be empty or an empty string. String length less than or equal to 7000, truncated if too long. |
| info | Object | Event business information | Can 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
| Parameter | Type | Description | Parameter Restrictions |
|---|---|---|---|
| logInfo | String | Log 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. |
| param | String | Additional 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
| Parameter | Type | Description | Parameter Restrictions |
|---|---|---|---|
| metricName | String | Metric 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. |
| metricValue | Int | Metric value. Required parameter. Interface call is invalid if the metric is empty. | - |
| param | String | Additional 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
| Parameter | Type | Description | Parameter Restrictions |
|---|---|---|---|
| methodName | String | Method 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. |
| param | String | Additional 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
| Parameter | Type | Description | Parameter Restrictions |
|---|---|---|---|
| headerKey | String | Request 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. |
| value | String | Request 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. |
| info | String | Associated 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");