| Class Info |
|---|
Provides methods to obtain HiAnalytics instances and implement analysis functions. |
| Qualifier and Type | Method Name and Description |
|---|---|
+ (void) | Obtains a HiAnalytics instance with the given context. |
+ (void) | onEvent:(nonnull NSString *)eventId setParams:(nonnull NSDictionary<NSString *, id> *)params Records custom events. |
+ (void) | setUserProfile:(nonnull NSString *)name setValue:(nonnull NSString *)value Sets user attributes. |
+ (nullable NSDictionary<NSString *, id> *) | Obtains predefined and custom user attributes in the A/B test. |
+ (void) | setAnalyticsEnabled:(BOOL)enabled Specifies whether to enable data collection based on predefined tracing points. |
+ (nonnull NSString *) | Obtains the app instance ID from AppGallery Connect. |
+ (void) | setUserId:(nullable NSString *)userId Sets a user ID. |
+ (void) | setSessionDuration:(NSTimeInterval)milliseconds Sets the session timeout interval. |
+ (void) | Deletes all collected data cached locally, including cached data that failed to be sent. |
| Method |
|---|
+ (void)config Obtains a HiAnalytics instance with the given context. The Analytics Kit will be initialized in the main thread, based on the configuration. |
| Method |
|---|
+ (void)onEvent:(nonnull NSString *)eventId setParams:(nonnull NSDictionary<NSString *, id> *)params Records custom events. |
Parameters
Name | Description |
eventId | Event ID, a string of up to 256 characters excluding spaces and invisible characters. The value cannot be empty and cannot be set to the ID of an automatically collected event. |
params | Information carried in the event. The value cannot contain spaces or invisible characters. |
| Method |
|---|
+ (void)setUserProfile:(nonnull NSString *)name setValue:(nonnull NSString *)value Sets 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 | Description |
|---|---|
name | Name of the user attribute, a string of up to 256 characters excluding spaces and invisible characters. The value cannot be empty. |
value | Value of the user attribute, a string of up to 256 characters. The value cannot be empty. |
| Method |
|---|
+ (nullable NSDictionary<NSString *, id> *)userProfiles:(BOOL)preDefined Obtains predefined and custom user attributes in the A/B test. |
Parameters
| Name | Description |
|---|---|
preDefined | Indicates whether to obtain predefined user attributes. |
| Method |
|---|
+ (void)setAnalyticsEnabled:(BOOL)enabled Specifies whether to enable data collection based on predefined tracing points. If this function is disabled, all cached data is cleared and no data is recorded. |
Parameters
| Name | Description |
|---|---|
enabled | Indicates whether to enable the collection function. The collection function is enabled by default. The options are as follows: YES: Enables the collection function. NO: Disables the collection function. |
| Method |
|---|
+ (nonnull NSString *)aaid Obtains the app instance ID from AppGallery Connect. |
| Method |
|---|
+ (void)setUserId:(nullable NSString *)userId Sets a user ID. 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. userId refers to the ID of a user. HUAWEI Analytics Kit 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
| Name | Description |
|---|---|
User ID, a string of up to 256 characters. The value cannot be empty. | User ID, a string of up to 256 characters. The value cannot be empty. |
| Method |
|---|
+ (void)setSessionDuration:(NSTimeInterval)milliseconds Sets the session timeout interval. A new session is generated when an app is running in the foreground but the interval between two adjacent events exceeds the specified timeout interval. The value is 30 minutes by default. |
Parameters
| Name | Description |
|---|---|
milliseconds | Session timeout interval. Unit: millisecond |
| Method |
|---|
+ (void)clearCachedData Deletes all collected data cached locally, including cached data that failed to be sent. |