• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# HiAppEvent
2
3
4## Overview
5
6Provides APIs for implementing the application event logging function.
7
8This function allows your application to record fault events, statistics events, security events, and user behavior events reported during system running. Based on the event information, you can analyze the operating status of your application.
9
10**System capability**: SystemCapability.HiviewDFX.HiAppEvent
11
12**Since**: 8
13
14
15## Summary
16
17
18### File
19
20| Name| Description|
21| -------- | -------- |
22| [hiappevent.h](hiappevent_8h.md) | Defines the application event logging functions of the HiAppEvent module.<br>**File to include**: <hiappevent/hiappevent.h><br>**Library**: libhiappevent_ndk.z.so|
23| [hiappevent_cfg.h](hiappevent__cfg_8h.md) | Defines the configuration items of the event logging configuration function.<br>**File to include**: <hiappevent/hiappevent_event.h><br>**Library**: libhiappevent_ndk.z.so|
24| [hiappevent_event.h](hiappevent__event_8h.md) | Defines the names of all predefined events.<br>**File to include**: <hiappevent/hiappevent_param.h><br>**Library**: libhiappevent_ndk.z.so|
25| [hiappevent_param.h](hiappevent__param_8h.md) | Defines the names of all predefined event parameters.<br>**File to include**: <hiappevent/hiappevent_cfg.h><br>**Library**: libhiappevent_ndk.z.so|
26
27
28### Structs
29
30| Name| Description|
31| -------- | -------- |
32| struct&nbsp;&nbsp;[HiAppEvent_AppEventInfo](_hi_app_event___app_event_info.md) | Defines the information about a single event, including the event domain, event name, event type, and custom parameter list in JSON string format. |
33| struct&nbsp;&nbsp;[HiAppEvent_AppEventGroup](_hi_app_event___app_event_group.md) | Event array with the same event name. |
34
35
36### Macros
37
38| Name| Description|
39| -------- | -------- |
40| [DISABLE](#disable)&nbsp;&nbsp;&nbsp;"disable" | Whether to disable event logging. The default value is **false**. The value **true** means to disable the event logging function, and the value **false** means the opposite. |
41| [MAX_STORAGE](#max_storage)&nbsp;&nbsp;&nbsp;"max_storage" | Storage quota of the event file directory. The default value is **10M**. |
42| [EVENT_USER_LOGIN](#event_user_login)&nbsp;&nbsp;&nbsp;"hiappevent.user_login" | User login event. |
43| [EVENT_USER_LOGOUT](#event_user_logout)&nbsp;&nbsp;&nbsp;"hiappevent.user_logout" | User logout event. |
44| [EVENT_DISTRIBUTED_SERVICE_START](#event_distributed_service_start)&nbsp;&nbsp;&nbsp;"hiappevent.distributed_service_start" | Distributed service event. |
45| [EVENT_APP_CRASH](#event_app_crash)&nbsp;&nbsp;&nbsp;"APP_CRASH" | Application crash event. |
46| [EVENT_APP_FREEZE](#event_app_freeze)&nbsp;&nbsp;&nbsp;"APP_FREEZE" | Application freeze event. |
47| [EVENT_APP_LAUNCH](#event_app_launch)&nbsp;&nbsp;&nbsp;"APP_LAUNCH" | Application loading event. |
48| [EVENT_SCROLL_JANK](#event_scroll_jank)&nbsp;&nbsp;&nbsp;"SCROLL_JANK" | Event indicating application freeze during swiping. |
49| [EVENT_CPU_USAGE_HIGH](#event_cpu_usage_high)&nbsp;&nbsp;&nbsp;"CPU_USAGE_HIGH" | Event indicating high CPU usage of an application. |
50| [EVENT_BATTERY_USAGE](#event_battery_usage)&nbsp;&nbsp;&nbsp;"BATTERY_USAGE" | Application power usage event. |
51| [EVENT_RESOURCE_OVERLIMIT](#event_resource_overlimit)&nbsp;&nbsp;&nbsp;"RESOURCE_OVERLIMIT" | Application resource threshold-crossing event. |
52| [DOMAIN_OS](#domain_os)&nbsp;&nbsp;&nbsp;"OS" | OS scope. |
53| [PARAM_USER_ID](#param_user_id)&nbsp;&nbsp;&nbsp;"user_id" | User ID. |
54| [PARAM_DISTRIBUTED_SERVICE_NAME](#param_distributed_service_name)&nbsp;&nbsp;&nbsp;"ds_name" | Distributed service name. |
55| [PARAM_DISTRIBUTED_SERVICE_INSTANCE_ID](#param_distributed_service_instance_id)&nbsp;&nbsp;&nbsp;"ds_instance_id" | Distributed service instance ID. |
56
57
58### Types
59
60| Name| Description|
61| -------- | -------- |
62| typedef struct [HiAppEvent_AppEventInfo](_hi_app_event___app_event_info.md) [HiAppEvent_AppEventInfo](#hiappevent_appeventinfo) | Defines a struct for the information about a single event, including the event domain, event name, event type, and custom parameter list in JSON string format. |
63| typedef struct [HiAppEvent_AppEventGroup](_hi_app_event___app_event_group.md) [HiAppEvent_AppEventGroup](#hiappevent_appeventgroup) | Event array with the same event name. |
64| typedef struct ParamListNode \* [ParamList](#paramlist) | Event parameter list node. |
65| typedef struct [HiAppEvent_Watcher](#hiappevent_watcher) [HiAppEvent_Watcher](#hiappevent_watcher) | Watcher for application events. |
66| typedef struct [HiAppEvent_Config](#hiappevent_config) [HiAppEvent_Config](#hiappevent_config) | Defines a struct for the configuration object used to set the conditions for triggering system events. |
67| typedef void(\* [OH_HiAppEvent_OnReceive](#oh_hiappevent_onreceive)) (const char \*domain, const struct [HiAppEvent_AppEventGroup](_hi_app_event___app_event_group.md) \*appEventGroups, uint32_t groupLen) | Callback invoked to pass event content to the caller. |
68| typedef void(\* [OH_HiAppEvent_OnTrigger](#oh_hiappevent_ontrigger)) (int row, int size) | Defines a callback invoked if the event received by the watcher meets the conditions specified by **OH_HiAppEvent_SetTriggerCondition**. When the **OH_HiAppEvent_OnReceive** callback is not set in the watcher, the event received by the watcher will be saved.  After the callback is complete, if a newly saved event meets the specified condition, the callback is invoked again. |
69| typedef void(\* [OH_HiAppEvent_OnTake](#oh_hiappevent_ontake)) (const char \*const \*events, uint32_t eventLen) | Callback invoked to pass the events received by the watcher to the caller when OH_HiAppEvent_TakeWatcherData is used to obtain the events. |
70
71
72### Enums
73
74| Name| Description|
75| -------- | -------- |
76| [HiAppEvent_ErrorCode](#hiappevent_errorcode) {<br>HIAPPEVENT_SUCCESS = 0, HIAPPEVENT_INVALID_PARAM_VALUE_LENGTH = 4, HIAPPEVENT_PROCESSOR_IS_NULL = -7, HIAPPEVENT_PROCESSOR_NOT_FOUND = -8,<br>HIAPPEVENT_INVALID_PARAM_VALUE = -9, HIAPPEVENT_EVENT_CONFIG_IS_NULL = -10, HIAPPEVENT_OPERATE_FAILED = -100, HIAPPEVENT_INVALID_UID = -200<br>} | Enumerates the error codes used in the HiAppEvent module. |
77| [EventType](#eventtype) { FAULT = 1, STATISTIC = 2, SECURITY = 3, BEHAVIOR = 4 } | Event type. |
78
79
80### Functions
81
82| Name| Description|
83| -------- | -------- |
84| [ParamList](#paramlist) [OH_HiAppEvent_CreateParamList](#oh_hiappevent_createparamlist) (void) | Creates a pointer to a parameter list object. |
85| void [OH_HiAppEvent_DestroyParamList](#oh_hiappevent_destroyparamlist) ([ParamList](#paramlist) list) | Destroys a pointer to a parameter list object and releases its allocated memory. |
86| [ParamList](#paramlist) [OH_HiAppEvent_AddBoolParam](#oh_hiappevent_addboolparam) ([ParamList](#paramlist) list, const char \*name, bool boolean) | Adds an event parameter of the Boolean type to the parameter list. |
87| [ParamList](#paramlist) [OH_HiAppEvent_AddBoolArrayParam](#oh_hiappevent_addboolarrayparam) ([ParamList](#paramlist) list, const char \*name, const bool \*booleans, int arrSize) | Adds an event parameter of the Boolean array type to the parameter list. |
88| [ParamList](#paramlist) [OH_HiAppEvent_AddInt8Param](#oh_hiappevent_addint8param) ([ParamList](#paramlist) list, const char \*name, int8_t num) | Adds an event parameter of the int8_t type to the parameter list. |
89| [ParamList](#paramlist) [OH_HiAppEvent_AddInt8ArrayParam](#oh_hiappevent_addint8arrayparam) ([ParamList](#paramlist) list, const char \*name, const int8_t \*nums, int arrSize) | Adds an event parameter of the int8_t array type to the parameter list. |
90| [ParamList](#paramlist) [OH_HiAppEvent_AddInt16Param](#oh_hiappevent_addint16param) ([ParamList](#paramlist) list, const char \*name, int16_t num) | Adds an event parameter of the int16_t type to the parameter list. |
91| [ParamList](#paramlist) [OH_HiAppEvent_AddInt16ArrayParam](#oh_hiappevent_addint16arrayparam) ([ParamList](#paramlist) list, const char \*name, const int16_t \*nums, int arrSize) | Adds an event parameter of the int16_t array type to the parameter list. |
92| [ParamList](#paramlist) [OH_HiAppEvent_AddInt32Param](#oh_hiappevent_addint32param) ([ParamList](#paramlist) list, const char \*name, int32_t num) | Adds an event parameter of the int32_t type to the parameter list. |
93| [ParamList](#paramlist) [OH_HiAppEvent_AddInt32ArrayParam](#oh_hiappevent_addint32arrayparam) ([ParamList](#paramlist) list, const char \*name, const int32_t \*nums, int arrSize) | Adds an event parameter of the int32_t array type to the parameter list. |
94| [ParamList](#paramlist) [OH_HiAppEvent_AddInt64Param](#oh_hiappevent_addint64param) ([ParamList](#paramlist) list, const char \*name, int64_t num) | Adds an event parameter of the int64_t type to the parameter list. |
95| [ParamList](#paramlist) [OH_HiAppEvent_AddInt64ArrayParam](#oh_hiappevent_addint64arrayparam) ([ParamList](#paramlist) list, const char \*name, const int64_t \*nums, int arrSize) | Adds an event parameter of the int64_t array type to the parameter list. |
96| [ParamList](#paramlist) [OH_HiAppEvent_AddFloatParam](#oh_hiappevent_addfloatparam) ([ParamList](#paramlist) list, const char \*name, float num) | Adds an event parameter of the float type to the parameter list. |
97| [ParamList](#paramlist) [OH_HiAppEvent_AddFloatArrayParam](#oh_hiappevent_addfloatarrayparam) ([ParamList](#paramlist) list, const char \*name, const float \*nums, int arrSize) | Adds an event parameter of the float array type to the parameter list. |
98| [ParamList](#paramlist) [OH_HiAppEvent_AddDoubleParam](#oh_hiappevent_adddoubleparam) ([ParamList](#paramlist) list, const char \*name, double num) | Adds an event parameter of the Double type to the parameter list. |
99| [ParamList](#paramlist) [OH_HiAppEvent_AddDoubleArrayParam](#oh_hiappevent_adddoublearrayparam) ([ParamList](#paramlist) list, const char \*name, const double \*nums, int arrSize) | Adds an event parameter of the double array type to the parameter list. |
100| [ParamList](#paramlist) [OH_HiAppEvent_AddStringParam](#oh_hiappevent_addstringparam) ([ParamList](#paramlist) list, const char \*name, const char \*str) | Adds a parameter of the string type to the parameter list. |
101| [ParamList](#paramlist) [OH_HiAppEvent_AddStringArrayParam](#oh_hiappevent_addstringarrayparam) ([ParamList](#paramlist) list, const char \*name, const char \*const \*strs, int arrSize) | Adds a parameter of the string array type to the parameter list. |
102| int [OH_HiAppEvent_Write](#oh_hiappevent_write) (const char \*domain, const char \*name, enum [EventType](#eventtype) type, const [ParamList](#paramlist) list) | Logs application events whose parameters are of the list type. |
103| bool [OH_HiAppEvent_Configure](#oh_hiappevent_configure) (const char \*name, const char \*value) | Configures the application event logging function. |
104| [HiAppEvent_Watcher](#hiappevent_watcher) \* [OH_HiAppEvent_CreateWatcher](#oh_hiappevent_createwatcher) (const char \*name) | Creates a watcher for application events. |
105| void [OH_HiAppEvent_DestroyWatcher](#oh_hiappevent_destroywatcher) ([HiAppEvent_Watcher](#hiappevent_watcher) \*watcher) | Destroys a created watcher. |
106| int [OH_HiAppEvent_SetTriggerCondition](#oh_hiappevent_settriggercondition) ([HiAppEvent_Watcher](#hiappevent_watcher) \*watcher, int row, int size, int timeOut) | Sets the trigger conditions of the **OH_HiAppEvent_OnTrigger** callback, including the number and size of newly received events and the timeout interval for triggering **onTrigger**. Ensure that at least one of the trigger conditions is set on the caller side. |
107| int [OH_HiAppEvent_SetAppEventFilter](#oh_hiappevent_setappeventfilter) ([HiAppEvent_Watcher](#hiappevent_watcher) \*watcher, const char \*domain, uint8_t eventTypes, const char \*const \*names, int namesLen) | Sets the type of events to listen for. |
108| int [OH_HiAppEvent_SetWatcherOnTrigger](#oh_hiappevent_setwatcherontrigger) ([HiAppEvent_Watcher](#hiappevent_watcher) \*watcher, [OH_HiAppEvent_OnTrigger](#oh_hiappevent_ontrigger) onTrigger) | Sets the **onTrigger** callback. |
109| int [OH_HiAppEvent_SetWatcherOnReceive](#oh_hiappevent_setwatcheronreceive) ([HiAppEvent_Watcher](#hiappevent_watcher) \*watcher, [OH_HiAppEvent_OnReceive](#oh_hiappevent_onreceive) onReceive) | Sets the **onReceive** callback. When the listener detects the corresponding event, the onReceive callback is called. |
110| int [OH_HiAppEvent_TakeWatcherData](#oh_hiappevent_takewatcherdata) ([HiAppEvent_Watcher](#hiappevent_watcher) \*watcher, uint32_t eventNum, [OH_HiAppEvent_OnTake](#oh_hiappevent_ontake) onTake) | Obtains the event saved by the watcher. |
111| int [OH_HiAppEvent_AddWatcher](#oh_hiappevent_addwatcher) ([HiAppEvent_Watcher](#hiappevent_watcher) \*watcher) | Adds a watcher. Once a watcher is added, it starts to listen for system messages. |
112| int [OH_HiAppEvent_RemoveWatcher](#oh_hiappevent_removewatcher) ([HiAppEvent_Watcher](#hiappevent_watcher) \*watcher) | Removes a watcher. Once a watcher is removed, it stops listening for system messages. |
113| void [OH_HiAppEvent_ClearData](#oh_hiappevent_cleardata) (void) | Clears the events saved by all watchers. |
114| [HiAppEvent_Config](#hiappevent_config) \* [OH_HiAppEvent_CreateConfig](#oh_hiappevent_createconfig) (void) | Creates a pointer to the configuration object that sets the conditions for triggering system events. |
115| void [OH_HiAppEvent_DestroyConfig](#oh_hiappevent_destroyconfig) ([HiAppEvent_Config](#hiappevent_config) \*config) | Destroys a configuration object. |
116| int [OH_HiAppEvent_SetConfigItem](#oh_hiappevent_setconfigitem) ([HiAppEvent_Config](#hiappevent_config) \*config, const char \*itemName, const char \*itemValue) | Sets the items in the configuration object. |
117| int [OH_HiAppEvent_SetEventConfig](#oh_hiappevent_seteventconfig) (const char \*name, [HiAppEvent_Config](#hiappevent_config) \*config) | Sets the conditions for triggering system event subscription. |
118
119
120## Macro Description
121
122
123### DISABLE
124
125```
126#define DISABLE   "disable"
127```
128**Description**
129Whether to disable event logging. The default value is **false**. The value **true** means to disable the event logging function, and the value **false** means the opposite.
130
131**Since**: 8
132
133
134### DOMAIN_OS
135
136```
137#define DOMAIN_OS   "OS"
138```
139**Description**
140OS scope.
141
142**Since**: 12
143
144
145### EVENT_APP_CRASH
146
147```
148#define EVENT_APP_CRASH   "APP_CRASH"
149```
150**Description**
151Defines an application crash event.
152
153**Since**: 12
154
155
156### EVENT_APP_FREEZE
157
158```
159#define EVENT_APP_FREEZE   "APP_FREEZE"
160```
161**Description**
162Defines an application freeze event.
163
164**Since**: 12
165
166
167### EVENT_APP_LAUNCH
168
169```
170#define EVENT_APP_LAUNCH   "APP_LAUNCH"
171```
172**Description**
173Defines an application loading event.
174
175**Since**: 12
176
177
178### EVENT_BATTERY_USAGE
179
180```
181#define EVENT_BATTERY_USAGE   "BATTERY_USAGE"
182```
183**Description**
184Defines an application power usage event.
185
186**Since**: 12
187
188
189### EVENT_CPU_USAGE_HIGH
190
191```
192#define EVENT_CPU_USAGE_HIGH   "CPU_USAGE_HIGH"
193```
194**Description**
195Defines an event indicating high CPU usage of an application.
196
197**Since**: 12
198
199
200### EVENT_DISTRIBUTED_SERVICE_START
201
202```
203#define EVENT_DISTRIBUTED_SERVICE_START   "hiappevent.distributed_service_start"
204```
205**Description**
206Distributed service event.
207
208**Since**: 8
209
210
211### EVENT_RESOURCE_OVERLIMIT
212
213```
214#define EVENT_RESOURCE_OVERLIMIT   "RESOURCE_OVERLIMIT"
215```
216**Description**
217Defines an application resource threshold-crossing event.
218
219**Since**: 12
220
221
222### EVENT_SCROLL_JANK
223
224```
225#define EVENT_SCROLL_JANK   "SCROLL_JANK"
226```
227**Description**
228Defines an event indicating application freeze during swiping.
229
230**Since**: 12
231
232
233### EVENT_USER_LOGIN
234
235```
236#define EVENT_USER_LOGIN   "hiappevent.user_login"
237```
238**Description**
239User login event.
240
241**Since**: 8
242
243
244### EVENT_USER_LOGOUT
245
246```
247#define EVENT_USER_LOGOUT   "hiappevent.user_logout"
248```
249**Description**
250User logout event.
251
252**Since**: 8
253
254
255### MAX_STORAGE
256
257```
258#define MAX_STORAGE   "max_storage"
259```
260**Description**
261Storage quota of the event file directory. The default value is **10M**.
262
263**Since**: 8
264
265
266### PARAM_DISTRIBUTED_SERVICE_INSTANCE_ID
267
268```
269#define PARAM_DISTRIBUTED_SERVICE_INSTANCE_ID   "ds_instance_id"
270```
271**Description**
272Distributed service instance ID.
273
274**Since**: 8
275
276
277### PARAM_DISTRIBUTED_SERVICE_NAME
278
279```
280#define PARAM_DISTRIBUTED_SERVICE_NAME   "ds_name"
281```
282**Description**
283Distributed service name.
284
285**Since**: 8
286
287
288### PARAM_USER_ID
289
290```
291#define PARAM_USER_ID   "user_id"
292```
293**Description**
294User ID.
295
296**Since**: 8
297
298
299## Type Description
300
301
302### HiAppEvent_AppEventGroup
303
304```
305typedef struct HiAppEvent_AppEventGroupHiAppEvent_AppEventGroup
306```
307**Description**
308Defines an event array with the same event name.
309
310**System capability**: SystemCapability.HiviewDFX.HiAppEvent
311
312**Since**: 12
313
314
315### HiAppEvent_AppEventInfo
316
317```
318typedef struct HiAppEvent_AppEventInfoHiAppEvent_AppEventInfo
319```
320**Description**
321Defines a struct for the information about a single event, including the event domain, event name, event type, and custom parameter list in JSON string format.
322
323**System capability**: SystemCapability.HiviewDFX.HiAppEvent
324
325**Since**: 12
326
327
328### HiAppEvent_Config
329
330```
331typedef struct HiAppEvent_ConfigHiAppEvent_Config
332```
333**Description**
334Defines a struct for the configuration object used to set the conditions for triggering system events.
335
336**System capability**: SystemCapability.HiviewDFX.HiAppEvent
337
338**Since**: 15
339
340
341### HiAppEvent_Watcher
342
343```
344typedef struct HiAppEvent_WatcherHiAppEvent_Watcher
345```
346**Description**
347Defines the watcher for application events.
348
349**System capability**: SystemCapability.HiviewDFX.HiAppEvent
350
351**Since**: 12
352
353
354### OH_HiAppEvent_OnReceive
355
356```
357typedef void(* OH_HiAppEvent_OnReceive) (const char *domain, const struct HiAppEvent_AppEventGroup *appEventGroups, uint32_t groupLen)
358```
359**Description**
360Defines a callback invoked to pass event content to the caller.
361
362Note: The lifecycle of the object pointed by the pointer in the callback is limited to the callback function. Do not use the pointer outside of the callback function. If the information needs to be cached, perform a deep copy of the content pointed by the pointer.
363
364**System capability**: SystemCapability.HiviewDFX.HiAppEvent
365
366**Since**: 12
367
368**Parameters**
369
370| Name| Description|
371| -------- | -------- |
372| domain | Domain of the received application event. |
373| appEventGroups | Event group array. |
374| groupLen | Length of the event group array. |
375
376
377### OH_HiAppEvent_OnTake
378
379```
380typedef void(* OH_HiAppEvent_OnTake) (const char *const *events, uint32_t eventLen)
381```
382**Description**
383Defines a callback invoked to pass the events received by the watcher to the caller when OH_HiAppEvent_TakeWatcherData is used to obtain the events.
384
385Note: The lifecycle of the object pointed by the pointer in the callback is limited to the callback function. Do not use the pointer outside of the callback function. If the information needs to be cached, perform a deep copy of the content pointed by the pointer.
386
387**System capability**: SystemCapability.HiviewDFX.HiAppEvent
388
389**Since**: 12
390
391**Parameters**
392
393| Name| Description|
394| -------- | -------- |
395| events | Event array in JSON string format. |
396| eventLen | Size of the event array. |
397
398
399### OH_HiAppEvent_OnTrigger
400
401```
402typedef void(* OH_HiAppEvent_OnTrigger) (int row, int size)
403```
404**Description**
405Defines a callback invoked if the event received by the watcher meets the conditions specified by **OH_HiAppEvent_SetTriggerCondition**. When the **OH_HiAppEvent_OnReceive** callback is not set in the watcher, the event received by the watcher will be saved.  After the callback is complete, if a newly saved event meets the specified condition, the callback is invoked again.
406
407**System capability**: SystemCapability.HiviewDFX.HiAppEvent
408
409**Since**: 12
410
411**Parameters**
412
413| Name| Description|
414| -------- | -------- |
415| row | Number of events newly received by the watcher. |
416| size | Total size of events newly received by the watcher. The size of a single event is the length of the JSON string converted from the event. |
417
418
419### ParamList
420
421```
422typedef struct ParamListNode* ParamList
423```
424**Description**
425Event parameter list node.
426
427**Since**: 8
428
429
430## Enum Description
431
432
433### EventType
434
435```
436enum EventType
437```
438**Description**
439Enumerates the event types.
440
441You are advised to select different event types based on application scenarios.
442
443**Since**: 8
444
445| Value| Description|
446| -------- | -------- |
447| FAULT  | Fault event.&nbsp;&nbsp; |
448| STATISTIC  | Statistics event.&nbsp;&nbsp; |
449| SECURITY  | Security event.&nbsp;&nbsp; |
450| BEHAVIOR  | Behavior event.&nbsp;&nbsp; |
451
452
453### HiAppEvent_ErrorCode
454
455```
456enum HiAppEvent_ErrorCode
457```
458**Description**
459Enumerates the error codes used in the HiAppEvent module.
460
461**Since**: 15
462
463| Value| Description|
464| -------- | -------- |
465| HIAPPEVENT_SUCCESS  | The operation is successful.&nbsp;&nbsp; |
466| HIAPPEVENT_INVALID_PARAM_VALUE_LENGTH  | The parameter value length is invalid.&nbsp;&nbsp; |
467| HIAPPEVENT_PROCESSOR_IS_NULL  | The processor is null.&nbsp;&nbsp; |
468| HIAPPEVENT_PROCESSOR_NOT_FOUND  | The processor is not found.&nbsp;&nbsp; |
469| HIAPPEVENT_INVALID_PARAM_VALUE  | The parameter value is invalid.&nbsp;&nbsp; |
470| HIAPPEVENT_EVENT_CONFIG_IS_NULL  | The event configuration is null.&nbsp;&nbsp; |
471| HIAPPEVENT_OPERATE_FAILED  | The operation failed.&nbsp;&nbsp; |
472| HIAPPEVENT_INVALID_UID  | The user ID is invalid.&nbsp;&nbsp; |
473
474
475## Function Description
476
477
478### OH_HiAppEvent_AddBoolArrayParam()
479
480```
481ParamList OH_HiAppEvent_AddBoolArrayParam (ParamList list, const char * name, const bool * booleans, int arrSize )
482```
483**Description**
484Adds an event parameter of the Boolean array type to the parameter list.
485
486**Since**: 8
487
488**Parameters**
489
490| Name| Description|
491| -------- | -------- |
492| list | Pointer to the parameter list to which parameters need to be added. |
493| name | Name of the parameter to be added. |
494| booleans | Value of the parameter to be added. |
495| arrSize | Size of the parameter array to be added. |
496
497**Returns**
498
499Pointer to the parameter list that contains the parameters added.
500
501
502### OH_HiAppEvent_AddBoolParam()
503
504```
505ParamList OH_HiAppEvent_AddBoolParam (ParamList list, const char * name, bool boolean )
506```
507**Description**
508Adds an event parameter of the Boolean type to the parameter list.
509
510**Since**: 8
511
512**Parameters**
513
514| Name| Description|
515| -------- | -------- |
516| list | Pointer to the parameter list to which parameters need to be added. |
517| name | Name of the parameter to be added. |
518| boolean | Value of the parameter to be added. |
519
520**Returns**
521
522Pointer to the parameter list that contains the parameters added.
523
524
525### OH_HiAppEvent_AddDoubleArrayParam()
526
527```
528ParamList OH_HiAppEvent_AddDoubleArrayParam (ParamList list, const char * name, const double * nums, int arrSize )
529```
530**Description**
531Adds an event parameter of the double array type to the parameter list.
532
533**Since**: 8
534
535**Parameters**
536
537| Name| Description|
538| -------- | -------- |
539| list | Pointer to the parameter list to which parameters need to be added. |
540| name | Name of the parameter to be added. |
541| nums | Value of the parameter to be added. |
542| arrSize | Size of the parameter array to be added. |
543
544**Returns**
545
546Pointer to the parameter list that contains the parameters added.
547
548
549### OH_HiAppEvent_AddDoubleParam()
550
551```
552ParamList OH_HiAppEvent_AddDoubleParam (ParamList list, const char * name, double num )
553```
554**Description**
555Adds an event parameter of the Double type to the parameter list.
556
557**Since**: 8
558
559**Parameters**
560
561| Name| Description|
562| -------- | -------- |
563| list | Pointer to the parameter list to which parameters need to be added. |
564| name | Name of the parameter to be added. |
565| num | Value of the parameter to be added. |
566
567**Returns**
568
569Pointer to the parameter list that contains the parameters added.
570
571
572### OH_HiAppEvent_AddFloatArrayParam()
573
574```
575ParamList OH_HiAppEvent_AddFloatArrayParam (ParamList list, const char * name, const float * nums, int arrSize )
576```
577**Description**
578Adds an event parameter of the float array type to the parameter list.
579
580**Since**: 8
581
582**Parameters**
583
584| Name| Description|
585| -------- | -------- |
586| list | Pointer to the parameter list to which parameters need to be added. |
587| name | Name of the parameter to be added. |
588| nums | Value of the parameter to be added. |
589| arrSize | Size of the parameter array to be added. |
590
591**Returns**
592
593Pointer to the parameter list that contains the parameters added.
594
595
596### OH_HiAppEvent_AddFloatParam()
597
598```
599ParamList OH_HiAppEvent_AddFloatParam (ParamList list, const char * name, float num )
600```
601**Description**
602Adds an event parameter of the float type to the parameter list.
603
604**Since**: 8
605
606**Parameters**
607
608| Name| Description|
609| -------- | -------- |
610| list | Pointer to the parameter list to which parameters need to be added. |
611| name | Name of the parameter to be added. |
612| num | Value of the parameter to be added. |
613
614**Returns**
615
616Pointer to the parameter list that contains the parameters added.
617
618
619### OH_HiAppEvent_AddInt16ArrayParam()
620
621```
622ParamList OH_HiAppEvent_AddInt16ArrayParam (ParamList list, const char * name, const int16_t * nums, int arrSize )
623```
624**Description**
625Adds an event parameter of the int16_t array type to the parameter list.
626
627**Since**: 8
628
629**Parameters**
630
631| Name| Description|
632| -------- | -------- |
633| list | Pointer to the parameter list to which parameters need to be added. |
634| name | Name of the parameter to be added. |
635| nums | Value of the parameter to be added. |
636| arrSize | Size of the parameter array to be added. |
637
638**Returns**
639
640Pointer to the parameter list that contains the parameters added.
641
642
643### OH_HiAppEvent_AddInt16Param()
644
645```
646ParamList OH_HiAppEvent_AddInt16Param (ParamList list, const char * name, int16_t num )
647```
648**Description**
649Adds an event parameter of the int16_t type to the parameter list.
650
651**Since**: 8
652
653**Parameters**
654
655| Name| Description|
656| -------- | -------- |
657| list | Pointer to the parameter list to which parameters need to be added. |
658| name | Name of the parameter to be added. |
659| num | Value of the parameter to be added. |
660
661**Returns**
662
663Pointer to the parameter list that contains the parameters added.
664
665
666### OH_HiAppEvent_AddInt32ArrayParam()
667
668```
669ParamList OH_HiAppEvent_AddInt32ArrayParam (ParamList list, const char * name, const int32_t * nums, int arrSize )
670```
671**Description**
672Adds an event parameter of the int32_t array type to the parameter list.
673
674**Since**: 8
675
676**Parameters**
677
678| Name| Description|
679| -------- | -------- |
680| list | Pointer to the parameter list to which parameters need to be added. |
681| name | Name of the parameter to be added. |
682| nums | Value of the parameter to be added. |
683| arrSize | Size of the parameter array to be added. |
684
685**Returns**
686
687Pointer to the parameter list that contains the parameters added.
688
689
690### OH_HiAppEvent_AddInt32Param()
691
692```
693ParamList OH_HiAppEvent_AddInt32Param (ParamList list, const char * name, int32_t num )
694```
695**Description**
696Adds an event parameter of the int32_t type to the parameter list.
697
698**Since**: 8
699
700**Parameters**
701
702| Name| Description|
703| -------- | -------- |
704| list | Pointer to the parameter list to which parameters need to be added. |
705| name | Name of the parameter to be added. |
706| num | Value of the parameter to be added. |
707
708**Returns**
709
710Pointer to the parameter list that contains the parameters added.
711
712
713### OH_HiAppEvent_AddInt64ArrayParam()
714
715```
716ParamList OH_HiAppEvent_AddInt64ArrayParam (ParamList list, const char * name, const int64_t * nums, int arrSize )
717```
718**Description**
719Adds an event parameter of the int64_t array type to the parameter list.
720
721**Since**: 8
722
723**Parameters**
724
725| Name| Description|
726| -------- | -------- |
727| list | Pointer to the parameter list to which parameters need to be added. |
728| name | Name of the parameter to be added. |
729| nums | Value of the parameter to be added. |
730| arrSize | Size of the parameter array to be added. |
731
732**Returns**
733
734Pointer to the parameter list that contains the parameters added.
735
736
737### OH_HiAppEvent_AddInt64Param()
738
739```
740ParamList OH_HiAppEvent_AddInt64Param (ParamList list, const char * name, int64_t num )
741```
742**Description**
743Adds an event parameter of the int64_t type to the parameter list.
744
745**Since**: 8
746
747**Parameters**
748
749| Name| Description|
750| -------- | -------- |
751| list | Pointer to the parameter list to which parameters need to be added. |
752| name | Name of the parameter to be added. |
753| num | Value of the parameter to be added. |
754
755**Returns**
756
757Pointer to the parameter list that contains the parameters added.
758
759
760### OH_HiAppEvent_AddInt8ArrayParam()
761
762```
763ParamList OH_HiAppEvent_AddInt8ArrayParam (ParamList list, const char * name, const int8_t * nums, int arrSize )
764```
765**Description**
766Adds an event parameter of the int8_t array type to the parameter list.
767
768**Since**: 8
769
770**Parameters**
771
772| Name| Description|
773| -------- | -------- |
774| list | Pointer to the parameter list to which parameters need to be added. |
775| name | Name of the parameter to be added. |
776| nums | Value of the parameter to be added. |
777| arrSize | Size of the parameter array to be added. |
778
779**Returns**
780
781Pointer to the parameter list that contains the parameters added.
782
783
784### OH_HiAppEvent_AddInt8Param()
785
786```
787ParamList OH_HiAppEvent_AddInt8Param (ParamList list, const char * name, int8_t num )
788```
789**Description**
790Adds an event parameter of the int8_t type to the parameter list.
791
792**Since**: 8
793
794**Parameters**
795
796| Name| Description|
797| -------- | -------- |
798| list | Pointer to the parameter list to which parameters need to be added. |
799| name | Name of the parameter to be added. |
800| num | Value of the parameter to be added. |
801
802**Returns**
803
804Pointer to the parameter list that contains the parameters added.
805
806
807### OH_HiAppEvent_AddStringArrayParam()
808
809```
810ParamList OH_HiAppEvent_AddStringArrayParam (ParamList list, const char * name, const char *const * strs, int arrSize )
811```
812**Description**
813Adds a parameter of the string array type to the parameter list.
814
815**Since**: 8
816
817**Parameters**
818
819| Name| Description|
820| -------- | -------- |
821| list | Pointer to the parameter list to which parameters need to be added. |
822| name | Name of the parameter to be added. |
823| strs | Value of the parameter to be added. |
824| arrSize | Size of the parameter array to be added. |
825
826**Returns**
827
828Pointer to the parameter list that contains the parameters added.
829
830
831### OH_HiAppEvent_AddStringParam()
832
833```
834ParamList OH_HiAppEvent_AddStringParam (ParamList list, const char * name, const char * str )
835```
836**Description**
837Adds a parameter of the string type to the parameter list.
838
839**Since**: 8
840
841**Parameters**
842
843| Name| Description|
844| -------- | -------- |
845| list | Pointer to the parameter list to which parameters need to be added. |
846| name | Name of the parameter to be added. |
847| str | Value of the parameter to be added. |
848
849**Returns**
850
851Pointer to the parameter list that contains the parameters added.
852
853
854### OH_HiAppEvent_AddWatcher()
855
856```
857int OH_HiAppEvent_AddWatcher (HiAppEvent_Watcher * watcher)
858```
859**Description**
860Adds a watcher. Once a watcher is added, it starts to listen for system messages.
861
862**System capability**: SystemCapability.HiviewDFX.HiAppEvent
863
864**Since**: 12
865
866**Parameters**
867
868| Name| Description|
869| -------- | -------- |
870| watcher | Pointer to the watcher (that is, the pointer returned by OH_HiAppEvent_CreateWatcher). |
871
872**Returns**
873
874**0** if the API is called successfully; **-5** if the pointer of an input parameter is null.
875
876
877### OH_HiAppEvent_ClearData()
878
879```
880void OH_HiAppEvent_ClearData (void )
881```
882**Description**
883Clears the events saved by all watchers.
884
885**System capability**: SystemCapability.HiviewDFX.HiAppEvent
886
887**Since**: 12
888
889
890### OH_HiAppEvent_Configure()
891
892```
893bool OH_HiAppEvent_Configure (const char * name, const char * value )
894```
895**Description**
896Configures the application event logging function.
897
898This function is used to configure the event logging function and the storage quota of the event file directory.
899
900**Since**: 8
901
902**Parameters**
903
904| Name| Description|
905| -------- | -------- |
906| name | Configuration item name. The value can be set to [DISABLE](#disable) or [MAX_STORAGE](#max_storage). |
907| value | Configuration item value. If the configuration item name is [DISABLE](#disable), the value can be **true** or **false**. If the configuration item name is [MAX_STORAGE](#max_storage), the quota value can contain only digits and a unit, which can be one of [b\|k\|kb\|m\|mb\|g\|gb\|t\|tb] and is case insensitive. The quota value string must start with a digit and can end with or without a unit. If no unit is specified, byte is used by default. |
908
909**Returns**
910
911Configuration result. The value **true** indicates that the configuration is successful, and the value **false** indicates the opposite.
912
913
914### OH_HiAppEvent_CreateConfig()
915
916```
917HiAppEvent_Config* OH_HiAppEvent_CreateConfig (void )
918```
919**Description**
920Creates a pointer to the configuration object that sets the conditions for triggering system events.
921
922**System capability**: SystemCapability.HiviewDFX.HiAppEvent
923
924**Since**: 15
925
926**Returns**
927
928Pointer to the configuration object that sets the conditions for triggering system events.
929
930
931### OH_HiAppEvent_CreateParamList()
932
933```
934ParamList OH_HiAppEvent_CreateParamList (void )
935```
936**Description**
937Creates a pointer to a parameter list object.
938
939**Since**: 8
940
941**Returns**
942
943Pointer to the parameter list object.
944
945
946### OH_HiAppEvent_CreateWatcher()
947
948```
949HiAppEvent_Watcher* OH_HiAppEvent_CreateWatcher (const char * name)
950```
951**Description**
952Creates a watcher for application events.
953
954Note: If a created watcher is no longer used, you are required to destroy it by calling OH_HiAppEvent_DestroyWatcher.
955
956**System capability**: SystemCapability.HiviewDFX.HiAppEvent
957
958**Since**: 12
959
960**Parameters**
961
962| Name| Description|
963| -------- | -------- |
964| name | Watcher name. |
965
966**Returns**
967
968Pointer to the new watcher if the API is called successfully; **nullptr** if the **name** parameter is invalid.
969
970
971### OH_HiAppEvent_DestroyConfig()
972
973```
974void OH_HiAppEvent_DestroyConfig (HiAppEvent_Config * config)
975```
976**Description**
977Destroys a configuration object.
978
979Note: If a configuration object is no longer used, destroy it to release memory to prevent memory leaks. After the object is destroyed, set its pointer to null.
980
981**System capability**: SystemCapability.HiviewDFX.HiAppEvent
982
983**Since**: 15
984
985**Parameters**
986
987| Name| Description|
988| -------- | -------- |
989| config | Pointer to the configuration object, that is, the pointer returned by the **OH_HiAppEvent_CreateConfig** API. |
990
991
992### OH_HiAppEvent_DestroyParamList()
993
994```
995void OH_HiAppEvent_DestroyParamList (ParamList list)
996```
997**Description**
998Destroys a pointer to a parameter list object and releases its allocated memory.
999
1000**Since**: 8
1001
1002**Parameters**
1003
1004| Name| Description|
1005| -------- | -------- |
1006| list | Pointer to the parameter list object. |
1007
1008
1009### OH_HiAppEvent_DestroyWatcher()
1010
1011```
1012void OH_HiAppEvent_DestroyWatcher (HiAppEvent_Watcher * watcher)
1013```
1014**Description**
1015Destroys a created watcher.
1016
1017Note: If a created watcher is no longer used, destroy it to release memory to prevent memory leaks. After the watcher is destroyed, set its pointer to null.
1018
1019**System capability**: SystemCapability.HiviewDFX.HiAppEvent
1020
1021**Since**: 12
1022
1023**Parameters**
1024
1025| Name| Description|
1026| -------- | -------- |
1027| watcher | Pointer to the watcher (that is, the pointer returned by OH_HiAppEvent_CreateWatcher). || Name| Description|
1028
1029
1030### OH_HiAppEvent_RemoveWatcher()
1031
1032```
1033int OH_HiAppEvent_RemoveWatcher (HiAppEvent_Watcher * watcher)
1034```
1035**Description**
1036Removes a watcher. Once a watcher is removed, it stops listening for system messages.
1037
1038Note: This API only enables the watcher to stop listening for system messages. It does not destroy the watcher. The watcher still resides in the memory until the OH_HiAppEvent_DestroyWatcher API is called.
1039
1040**System capability**: SystemCapability.HiviewDFX.HiAppEvent
1041
1042**Since**: 12
1043
1044**Parameters**
1045
1046| Name| Description|
1047| -------- | -------- |
1048| watcher | Pointer to the watcher (that is, the pointer returned by OH_HiAppEvent_CreateWatcher). |
1049
1050**Returns**
1051
1052**0** if the API is called successfully; **-5** if the pointer of an input parameter is null; **-6** if **OH_HiAppEvent_AddWatcher** has not been called to add a watcher.
1053
1054
1055### OH_HiAppEvent_SetAppEventFilter()
1056
1057```
1058int OH_HiAppEvent_SetAppEventFilter (HiAppEvent_Watcher * watcher, const char * domain, uint8_t eventTypes, const char *const * names, int namesLen )
1059```
1060**Description**
1061Sets the type of events to listen for.
1062
1063This function can be called repeatedly. You can add multiple filtering conditions instead of replacing them. The watcher will receive notifications of events that meet any of the filtering conditions.
1064
1065**System capability**: SystemCapability.HiviewDFX.HiAppEvent
1066
1067**Since**: 12
1068
1069**Parameters**
1070
1071| Name| Description|
1072| -------- | -------- |
1073| watcher | Pointer to the watcher (that is, the pointer returned by OH_HiAppEvent_CreateWatcher). |
1074| domain | Domain of events to be listened for. |
1075| eventTypes | Types of events to be listened for. The bitwise AND matching mode is used. Multiple types of events can be listened for. If the first bit is 1 (the value is **1**), fault events can be listened for. If the second bit is 1 (the value is **2**), statistics events can be listened for.<br>If the third bit is 1 (the value is **4**), security events can be listened for, if the fourth digit is 1 (the value is **8**), behavior events can be listened for.<br>If the fourth digit is 1 (the value is **15**) or 0 (the value is **0**), events of all types can be listened for.|
1076| names | Array of the event names. |
1077| namesLen | Length of the event name array. |
1078
1079**Returns**
1080
1081**0** if the API is called successfully; **-1** if the **names** parameter is invalid; **-4** if the **domain** parameter is invalid; **-5** if the pointer of an input parameter is null.
1082
1083
1084### OH_HiAppEvent_SetConfigItem()
1085
1086```
1087int OH_HiAppEvent_SetConfigItem (HiAppEvent_Config * config, const char * itemName, const char * itemValue )
1088```
1089**Description**
1090Sets the items in the configuration object.
1091
1092**System capability**: SystemCapability.HiviewDFX.HiAppEvent
1093
1094**Since**: 15
1095
1096**Parameters**
1097
1098| Name| Description|
1099| -------- | -------- |
1100| config | Pointer to the configuration object, that is, the pointer returned by the **OH_HiAppEvent_CreateConfig** API. |
1101| itemName | Name of the configuration item. |
1102| itemValue | Value of the configuration item. |
1103
1104**Returns**
1105
1106**0** if the API is called successfully; **-9** if the configuration item is invalid; **-10** if the pointer to the configuration object is null.
1107
1108
1109### OH_HiAppEvent_SetEventConfig()
1110
1111```
1112int OH_HiAppEvent_SetEventConfig (const char * name, HiAppEvent_Config * config )
1113```
1114**Description**
1115Sets the conditions for triggering system event subscription.
1116
1117**System capability**: SystemCapability.HiviewDFX.HiAppEvent
1118
1119**Since**: 15
1120
1121**Parameters**
1122
1123| Name| Description|
1124| -------- | -------- |
1125| name | Name of the system event. |
1126| config | Pointer to the configuration object, that is, the pointer returned by the **OH_HiAppEvent_CreateConfig** API. |
1127
1128**Returns**
1129
1130**0** if the API is called successfully; **-9** if the parameter is invalid.
1131
1132
1133### OH_HiAppEvent_SetTriggerCondition()
1134
1135```
1136int OH_HiAppEvent_SetTriggerCondition (HiAppEvent_Watcher * watcher, int row, int size, int timeOut )
1137```
1138**Description**
1139Sets the trigger conditions of the **OH_HiAppEvent_OnTrigger** callback, including the number and size of newly received events and the timeout interval for triggering **onTrigger**. Ensure that at least one of the trigger conditions is set on the caller side.
1140
1141**System capability**: SystemCapability.HiviewDFX.HiAppEvent
1142
1143**Since**: 12
1144
1145**Parameters**
1146
1147| Name| Description|
1148| -------- | -------- |
1149| watcher | Pointer to the watcher (that is, the pointer returned by OH_HiAppEvent_CreateWatcher). |
1150| row | Row count. If the input value is greater than 0 and the number of newly received events is greater than or equal to the value of this parameter, the configured **onTrigger** callback is called. If the input value is less than or equal to 0, the number of received events is not used as the condition to trigger the **onTrigger** callback. |
1151| size | Size value. If the input value is greater than 0 and the size of the newly received event is greater than or equal to the value of this parameter, the configured **onTrigger** callback is called. The size of a single event is the length of the JSON string converted from the event. If the input value is less than or equal to 0, the size of received events is not used as the condition to trigger the **onTrigger** callback. |
1152| timeOut | Timeout value, in seconds. If the input value is greater than 0, the system checks the watcher for newly received events based on the timeout interval. If there are any newly received events, the configured onTrigger callback is triggered. After the callback is complete, the system checks the watcher for newly received events when the timeout value expires. If the input value is less than or equal to 0, the timeout interval is not used as the condition to trigger the onTrigger callback. |
1153
1154**Returns**
1155
1156**0** if the API is called successfully; **-5** if the pointer of an input parameter is null.
1157
1158
1159### OH_HiAppEvent_SetWatcherOnReceive()
1160
1161```
1162int OH_HiAppEvent_SetWatcherOnReceive (HiAppEvent_Watcher * watcher, OH_HiAppEvent_OnReceive onReceive )
1163```
1164**Description**
1165Sets the **onReceive** callback. When the listener detects the corresponding event, the onReceive callback is called.
1166
1167**System capability**: SystemCapability.HiviewDFX.HiAppEvent
1168
1169**Since**: 12
1170
1171**Parameters**
1172
1173| Name| Description|
1174| -------- | -------- |
1175| watcher | Pointer to the watcher (that is, the pointer returned by OH_HiAppEvent_CreateWatcher). |
1176| onReceive | Pointer to the callback function. |
1177
1178**Returns**
1179
1180**0** if the API is called successfully; **-5** if the pointer of an input parameter is null.
1181
1182
1183### OH_HiAppEvent_SetWatcherOnTrigger()
1184
1185```
1186int OH_HiAppEvent_SetWatcherOnTrigger (HiAppEvent_Watcher * watcher, OH_HiAppEvent_OnTrigger onTrigger )
1187```
1188**Description**
1189Sets the **onTrigger** callback.
1190
1191**System capability**: SystemCapability.HiviewDFX.HiAppEvent
1192
1193**Since**: 12
1194
1195**Parameters**
1196
1197| Name| Description|
1198| -------- | -------- |
1199| watcher | Pointer to the watcher (that is, the pointer returned by OH_HiAppEvent_CreateWatcher). |
1200| onTrigger | Callback to be set. |
1201
1202**Returns**
1203
1204**0** if the API is called successfully; **-5** if the pointer of an input parameter is null.
1205
1206
1207### OH_HiAppEvent_TakeWatcherData()
1208
1209```
1210int OH_HiAppEvent_TakeWatcherData (HiAppEvent_Watcher * watcher, uint32_t eventNum, OH_HiAppEvent_OnTake onTake )
1211```
1212**Description**
1213Obtains the event saved by the watcher.
1214
1215**System capability**: SystemCapability.HiviewDFX.HiAppEvent
1216
1217**Since**: 12
1218
1219**Parameters**
1220
1221| Name| Description|
1222| -------- | -------- |
1223| watcher | Pointer to the watcher (that is, the pointer returned by OH_HiAppEvent_CreateWatcher). |
1224| eventNum | If the input value is less than or equal to **0**, all saved events are obtained. If the input value is greater than **0**, events are sorted by time in descending order and a specified number of saved events are obtained. |
1225| onTake | Pointer to the callback. The event information is returned through this callback. |
1226
1227**Returns**
1228
1229**0** if the API is called successfully; **-5** if the pointer of an input parameter is null; **-6** if **OH_HiAppEvent_AddWatcher** has not been called to add a watcher.
1230
1231
1232### OH_HiAppEvent_Write()
1233
1234```
1235int OH_HiAppEvent_Write (const char * domain, const char * name, enum EventType type, const ParamList list )
1236```
1237**Description**
1238Logs application events whose parameters are of the list type.
1239
1240Before application event logging, use this API to verify parameters of the events. If the verification is successful, the API writes the events to the event file.
1241
1242**Since**: 8
1243
1244**Parameters**
1245
1246| Name| Description|
1247| -------- | -------- |
1248| domain | Event domain. You can customize event domains as required. The value is a string that contains a maximum of 32 characters, including digits (0 to 9), letters (a to z), and underscore (\_). It must start with a letter and cannot end with an underscore (\_). |
1249| name | Event name. You can customize event names as required. The value is a string that contains a maximum of 48 characters, including digits (0 to 9), letters (a to z), underscore (\_), and dollar sign (`$`). It must start with a letter or dollar sign (`$`) and end with a digit or letter. |
1250| type | Event type, which is defined in [EventType](#eventtype). |
1251| list | List of event parameters, each of which consists of a parameter name and a parameter value. The specifications are as follows:<br>1. A parameter name is a string that contains a maximum of 32 characters, including digits (0 to 9), letters (a to z), underscore (\_), and dollar sign (`$`). It must start with a letter or dollar sign (`$`) and end with a digit or letter.<br>2. The parameter value can be string, number, Boolean, or array. The length of a parameter of the string type must be less than 8 × 1024 characters. If this limit is exceeded, the parameter will be discarded. The element type of an array parameter can only be string, number, or Boolean, and the number of elements must be less than 100. If this limit is exceeded, excess elements will be discarded.<br>3. The maximum number of parameters is 32. If this limit is exceeded, excess parameters will be discarded. |
1252
1253**Returns**
1254
1255The value **0** indicates that the event parameter is valid, and the event will be written to the event file asynchronously. A value greater than **0** indicates that invalid parameters are present in the event, and the event will be written to the event file asynchronously after the invalid parameters are ignored. A value smaller than **0** indicates that the event parameter verification fails, and the event will not be written to the event file.
12560 The event parameter is valid. -1 The event name is invalid. -4 The event domain name is invalid. -99 The application event logging is disabled. 1 The event parameter name is invalid. 4 The length of the event parameter string is invalid. 5 The number of event parameters is invalid. 6 The length of the event parameter array is invalid. 8 The event parameter name is duplicate.
1257