| Interface | Description |
| clearCachedData | This API is called to delete all collected data cached locally, including cached data that failed to be sent. |
| enableLog | Enables the console log function of the SDK. The default level is DEBUG. |
| enableLogWithLevel | Enables the console log function of the SDK. The log level is passed. |
| getAAID | This API is called to obtain the app instance ID from AppGallery Connect. |
| onEvent | This API is called to record events. |
| setCurrentScreen | This API is called to set the current screen name, which is used to identify the currently displayed screen. |
| setMinActivitySessions | This API is called to set the minimum interval between two sessions. |
| setSessionDuration | This API is called to set the session timeout interval. |
| setUserId | This API is called to set user IDs. |
| setUserProfile | This API is called to set user attributes. |
| Method |
void clearCachedData() |
| This API is called to delete all collected data cached locally, including cached data that failed to be sent. |
| enabled | Indicates whether to enable automatic event collection. The options are as follows: |
| Method |
void enableLog() |
| Enables the console log function of the SDK. The default level is DEBUG. |
| Parameter | Description |
| Method |
void enableLogWithLevel(String level) |
| Enables the console log function of the SDK. The log level is passed. |
Parameters
| Parameter | Description |
| level | Log level. The value can be debug, info, warn, or error. The value is case sensitive. |
| Method |
| This API is called to obtain the app instance ID from AppGallery Connect. |
Return
| Parameter | Description |
| promise | If the operation is successful, an ID of the string type is returned. If the operation fails, an error message of the string type is returned. The response is obtained from the resolve function. |
| Method |
void onEvent(String name, object params) |
| This API is called to record events. |
Parameters
| Parameter | Description |
| name | Indicates the ID of a customized event.The value cannot be empty and can contain a maximum of 256 characters, including digits, letters, and underscores (_). It cannot start with a digit or underscore. The value of this parameter cannot be an ID of anautomatically collected event. |
| params | Indicates the information carried by the event.The number of built-in key-value pairs in the object cannot exceed 2048 and the size cannot exceed 200 KB. The key value in the object cannot contain spaces or invisible characters. |
| Method |
void setCurrentScreen(String activityName, String activityClassOverride) |
| This API is called to set the current screen name, which is used to identify the currently displayed screen. |
Parameters
| Parameter | Description |
| activityName | Indicates the name of the current activity screen, which is mandatory.This parameter cannot be empty and its value can contain a maximum of 256 characters. |
| screenClassOverride | Indicates the screen class name, which is optional. If this parameter is set to null or left empty, the class name of the current activity is used.The value can contain a maximum of 256 characters. |
Parameters
| Parameter | Description |
| milliseconds | Indicates the minimum interval between two sessions.The value is an integer. Unit: ms |
Parameters
| Type | Description |
| milliseconds | Indicates the session timeout interval.The value is an integer. Unit: ms |
This API is called to set user IDs.
When the API is called, a new session is generated if the old value of userId is not empty and is different from the new value.If you do not want to use userId to identify a user (for example, when a user signs out), you must set userId to null.
id: ID of a user. Huawei Analytics uses this ID to associate user data.The use of userId must comply with related privacy regulations. You need to declare the use of such information in the privacy statement of your app.
Parameters
| Parameter | Description |
| id | Indicates the user ID.This parameter cannot be empty and its value can contain a maximum of 256 characters. |
This API is called to set user attributes.The values of user attributes remain unchanged throughout the app lifecycle and during each session.A maximum of 25 user attributes are supported. If the name of an attribute set later is the same as that of an existing attribute, the value of the existing attribute is updated.
Parameters
| name | Indicates the ID of a user attribute.The value cannot be empty and can contain a maximum of 256 characters, including digits, letters, and underscores (_). It cannot start with a digit or underscore. |
| value | Indicates the attribute value,which is a non-empty string containing up to 256characters. |
| Method |
| Method |