1# Event Subscription Overview 2 3<!--Kit: Performance Analysis Kit--> 4<!--Subsystem: HiviewDFX--> 5<!--Owner: @liujiaxing2024--> 6<!--Designer: @junjie_shi--> 7<!--Tester: @gcw_KuLfPSbe--> 8<!--Adviser: @foryourself--> 9 10## Event Description 11 12The HiAppEvent module can be used to subscribe to application events and system events. 13 14### Application Events 15 16Application events are defined by developers. For example, a button click event. The fields contained in the event parameter object **params** of an application event are customized using the **write()** API. You can determine the field meanings as required. 17 18### System Events 19 20System events occur during application running, such as performance, power consumption, and stability issues. The fields contained in the event parameter object **params** of a system event are defined by the system service. In addition, the crash event and application freeze event of system events allow you to add custom parameters to **params** through the **setEventParam()** API. 21 22For details about the supported system events, detection principles, and fields in **params**, see the related topics. 23 24[Crash Event Overview](hiappevent-watcher-crash-events.md) 25 26[Application Freeze Event Overview](hiappevent-watcher-freeze-events.md) 27 28[Resource Leak Event Overview](hiappevent-watcher-resourceleak-events.md) 29 30[Address Sanitizer Event Overview](hiappevent-watcher-address-sanitizer-events.md) 31 32[Main Thread Jank Event Overview](hiappevent-watcher-mainthreadjank-events.md) 33 34[Task Execution Timeout Event Overview](hiappevent-watcher-apphicollie-events.md) 35 36[Application Killed Event Overview](hiappevent-watcher-app-killed-events.md) 37 38<!--RP1--> 39<!--RP1End--> 40 41## Event Subscription Methods 42 43HiAppEvent provides the **addWatcher()** API for subscribing to system events in any of the following methods: 44 45Method 1: Set **triggerCondition** to implement the **onTrigger()** callback. When the callback conditions are met, the system automatically triggers the callback. 46 47Method 2: If the **triggerCondition** parameter is not set, use the **holder** object returned by the event subscription to obtain the subscribed event. 48 49> **NOTE** 50> 51> If the event is not generated or the log information is not captured, the query result may be empty. In this case, you are advised to call the query interface for multiple times. 52 53Method 3: Implement the **onReceive()** callback, which is triggered in real time when the subscribed event occurs. 54 55For details about ArkTS APIs, see [hiAppEvent.addWatcher](../reference/apis-performance-analysis-kit/js-apis-hiviewdfx-hiappevent.md#hiappeventaddwatcher). For details about C/C++ APIs, see [OH_HiAppEvent_AddWatcher()](../reference/apis-performance-analysis-kit/capi-hiappevent-h.md#oh_hiappevent_addwatcher). 56