• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022-2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit PerformanceAnalysisKit
19 */
20
21import type { AsyncCallback } from './@ohos.base';
22
23/**
24 * Provides the event logging function for applications to log the fault, statistical, security,
25 * and user behavior events reported during running. Based on event information,
26 * you will be able to analyze the running status of applications.
27 *
28 * @namespace hiAppEvent
29 * @syscap SystemCapability.HiviewDFX.HiAppEvent
30 * @since 9
31 */
32/**
33 * Provides the event logging function for applications to log the fault, statistical, security,
34 * and user behavior events reported during running. Based on event information,
35 * you will be able to analyze the running status of applications.
36 *
37 * @namespace hiAppEvent
38 * @syscap SystemCapability.HiviewDFX.HiAppEvent
39 * @atomicservice
40 * @since 11
41 */
42declare namespace hiAppEvent {
43  /**
44   * Enumerate application event types.
45   *
46   * @enum { number }
47   * @syscap SystemCapability.HiviewDFX.HiAppEvent
48   * @since 9
49   */
50  /**
51   * Enumerate application event types.
52   *
53   * @enum { number }
54   * @syscap SystemCapability.HiviewDFX.HiAppEvent
55   * @atomicservice
56   * @since 11
57   */
58  enum EventType {
59    /**
60     * Fault event.
61     *
62     * @syscap SystemCapability.HiviewDFX.HiAppEvent
63     * @since 9
64     */
65    /**
66     * Fault event.
67     *
68     * @syscap SystemCapability.HiviewDFX.HiAppEvent
69     * @atomicservice
70     * @since 11
71     */
72    FAULT = 1,
73
74    /**
75     * Statistic event.
76     *
77     * @syscap SystemCapability.HiviewDFX.HiAppEvent
78     * @since 9
79     */
80    /**
81     * Statistic event.
82     *
83     * @syscap SystemCapability.HiviewDFX.HiAppEvent
84     * @atomicservice
85     * @since 11
86     */
87    STATISTIC = 2,
88
89    /**
90     * Security event.
91     *
92     * @syscap SystemCapability.HiviewDFX.HiAppEvent
93     * @since 9
94     */
95    /**
96     * Security event.
97     *
98     * @syscap SystemCapability.HiviewDFX.HiAppEvent
99     * @atomicservice
100     * @since 11
101     */
102    SECURITY = 3,
103
104    /**
105     * User behavior event.
106     *
107     * @syscap SystemCapability.HiviewDFX.HiAppEvent
108     * @since 9
109     */
110    /**
111     * User behavior event.
112     *
113     * @syscap SystemCapability.HiviewDFX.HiAppEvent
114     * @atomicservice
115     * @since 11
116     */
117    BEHAVIOR = 4
118  }
119
120  /**
121   * Preset domain.
122   *
123   * @namespace domain
124   * @syscap SystemCapability.HiviewDFX.HiAppEvent
125   * @atomicservice
126   * @since 11
127   */
128  namespace domain {
129    /**
130     * the domain of operating system.
131     *
132     * @syscap SystemCapability.HiviewDFX.HiAppEvent
133     * @atomicservice
134     * @since 11
135     */
136    const OS: string;
137  }
138
139  /**
140   * Preset event.
141   *
142   * @namespace event
143   * @syscap SystemCapability.HiviewDFX.HiAppEvent
144   * @since 9
145   */
146  /**
147   * Preset event.
148   *
149   * @namespace event
150   * @syscap SystemCapability.HiviewDFX.HiAppEvent
151   * @atomicservice
152   * @since 11
153   */
154  namespace event {
155    /**
156     * User login event.
157     *
158     * @syscap SystemCapability.HiviewDFX.HiAppEvent
159     * @since 9
160     */
161    /**
162     * User login event.
163     *
164     * @syscap SystemCapability.HiviewDFX.HiAppEvent
165     * @atomicservice
166     * @since 11
167     */
168    const USER_LOGIN: string;
169
170    /**
171     * User logout event.
172     *
173     * @syscap SystemCapability.HiviewDFX.HiAppEvent
174     * @since 9
175     */
176    /**
177     * User logout event.
178     *
179     * @syscap SystemCapability.HiviewDFX.HiAppEvent
180     * @atomicservice
181     * @since 11
182     */
183    const USER_LOGOUT: string;
184
185    /**
186     * Distributed service event.
187     *
188     * @syscap SystemCapability.HiviewDFX.HiAppEvent
189     * @since 9
190     */
191    /**
192     * Distributed service event.
193     *
194     * @syscap SystemCapability.HiviewDFX.HiAppEvent
195     * @atomicservice
196     * @since 11
197     */
198    const DISTRIBUTED_SERVICE_START: string;
199
200    /**
201     * crash event.
202     *
203     * @syscap SystemCapability.HiviewDFX.HiAppEvent
204     * @atomicservice
205     * @since 11
206     */
207    const APP_CRASH: string;
208
209    /**
210     * freeze event.
211     *
212     * @syscap SystemCapability.HiviewDFX.HiAppEvent
213     * @atomicservice
214     * @since 11
215     */
216    const APP_FREEZE: string;
217
218    /**
219     * launch event.
220     *
221     * @syscap SystemCapability.HiviewDFX.HiAppEvent
222     * @atomicservice
223     * @since 12
224     */
225    const APP_LAUNCH: string;
226
227    /**
228     * scroll jank event.
229     *
230     * @syscap SystemCapability.HiviewDFX.HiAppEvent
231     * @atomicservice
232     * @since 12
233     */
234    const SCROLL_JANK: string;
235
236    /**
237     * cpu usage high event.
238     *
239     * @syscap SystemCapability.HiviewDFX.HiAppEvent
240     * @atomicservice
241     * @since 12
242     */
243    const CPU_USAGE_HIGH: string;
244
245    /**
246     * battery usage event.
247     *
248     * @syscap SystemCapability.HiviewDFX.HiAppEvent
249     * @atomicservice
250     * @since 12
251     */
252    const BATTERY_USAGE: string;
253
254    /**
255     * resource overlimit event.
256     *
257     * @syscap SystemCapability.HiviewDFX.HiAppEvent
258     * @atomicservice
259     * @since 12
260     */
261    const RESOURCE_OVERLIMIT: string;
262
263    /**
264     * address sanitizer event.
265     *
266     * @syscap SystemCapability.HiviewDFX.HiAppEvent
267     * @atomicservice
268     * @since 12
269     */
270    const ADDRESS_SANITIZER: string;
271
272    /**
273     * main thread jank event.
274     *
275     * @syscap SystemCapability.HiviewDFX.HiAppEvent
276     * @atomicservice
277     * @since 12
278     */
279    const MAIN_THREAD_JANK: string;
280  }
281
282  /**
283   * Preset param.
284   *
285   * @namespace param
286   * @syscap SystemCapability.HiviewDFX.HiAppEvent
287   * @since 9
288   */
289  /**
290   * Preset param.
291   *
292   * @namespace param
293   * @syscap SystemCapability.HiviewDFX.HiAppEvent
294   * @atomicservice
295   * @since 11
296   */
297  namespace param {
298    /**
299     * User id.
300     *
301     * @syscap SystemCapability.HiviewDFX.HiAppEvent
302     * @since 9
303     */
304    /**
305     * User id.
306     *
307     * @syscap SystemCapability.HiviewDFX.HiAppEvent
308     * @atomicservice
309     * @since 11
310     */
311    const USER_ID: string;
312
313    /**
314     * Distributed service name.
315     *
316     * @syscap SystemCapability.HiviewDFX.HiAppEvent
317     * @since 9
318     */
319    /**
320     * Distributed service name.
321     *
322     * @syscap SystemCapability.HiviewDFX.HiAppEvent
323     * @atomicservice
324     * @since 11
325     */
326    const DISTRIBUTED_SERVICE_NAME: string;
327
328    /**
329     * Distributed service instance id.
330     *
331     * @syscap SystemCapability.HiviewDFX.HiAppEvent
332     * @since 9
333     */
334    /**
335     * Distributed service instance id.
336     *
337     * @syscap SystemCapability.HiviewDFX.HiAppEvent
338     * @atomicservice
339     * @since 11
340     */
341    const DISTRIBUTED_SERVICE_INSTANCE_ID: string;
342  }
343
344  /**
345   * Application event logging configuration interface.
346   *
347   * @param { ConfigOption } config Application event logging configuration item object.
348   * @throws { BusinessError } 401 - Parameter error.
349   * @throws { BusinessError } 11103001 - Invalid max storage quota value.
350   * @static
351   * @syscap SystemCapability.HiviewDFX.HiAppEvent
352   * @since 9
353   */
354  /**
355   * Application event logging configuration interface.
356   *
357   * @param { ConfigOption } config Application event logging configuration item object.
358   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
359   * <br>2. Incorrect parameter types.
360   * @throws { BusinessError } 11103001 - Invalid max storage quota value.
361   * @static
362   * @syscap SystemCapability.HiviewDFX.HiAppEvent
363   * @atomicservice
364   * @since 11
365   */
366  function configure(config: ConfigOption): void;
367
368  /**
369   * Describe the options for the configuration.
370   *
371   * @interface ConfigOption
372   * @syscap SystemCapability.HiviewDFX.HiAppEvent
373   * @since 9
374   */
375  /**
376   * Describe the options for the configuration.
377   *
378   * @interface ConfigOption
379   * @syscap SystemCapability.HiviewDFX.HiAppEvent
380   * @atomicservice
381   * @since 11
382   */
383  interface ConfigOption {
384    /**
385     * Configuration item: application event logging switch.
386     *
387     * @type { ?boolean }
388     * @syscap SystemCapability.HiviewDFX.HiAppEvent
389     * @since 9
390     */
391    /**
392     * Configuration item: application event logging switch.
393     *
394     * @type { ?boolean }
395     * @syscap SystemCapability.HiviewDFX.HiAppEvent
396     * @atomicservice
397     * @since 11
398     */
399    disable?: boolean;
400
401    /**
402     * Configuration item: event file directory storage quota size.
403     *
404     * @type { ?string }
405     * @syscap SystemCapability.HiviewDFX.HiAppEvent
406     * @since 9
407     */
408    /**
409     * Configuration item: event file directory storage quota size.
410     *
411     * @type { ?string }
412     * @syscap SystemCapability.HiviewDFX.HiAppEvent
413     * @atomicservice
414     * @since 11
415     */
416    maxStorage?: string;
417  }
418
419  /**
420   * Definition of written application event information.
421   *
422   * @interface AppEventInfo
423   * @syscap SystemCapability.HiviewDFX.HiAppEvent
424   * @since 9
425   */
426  /**
427   * Definition of written application event information.
428   *
429   * @interface AppEventInfo
430   * @syscap SystemCapability.HiviewDFX.HiAppEvent
431   * @atomicservice
432   * @since 11
433   */
434  interface AppEventInfo {
435    /**
436     * The domain of the event.
437     *
438     * @type { string }
439     * @syscap SystemCapability.HiviewDFX.HiAppEvent
440     * @since 9
441     */
442    /**
443     * The domain of the event.
444     *
445     * @type { string }
446     * @syscap SystemCapability.HiviewDFX.HiAppEvent
447     * @atomicservice
448     * @since 11
449     */
450    domain: string;
451
452    /**
453     * The name of the event.
454     *
455     * @type { string }
456     * @syscap SystemCapability.HiviewDFX.HiAppEvent
457     * @since 9
458     */
459    /**
460     * The name of the event.
461     *
462     * @type { string }
463     * @syscap SystemCapability.HiviewDFX.HiAppEvent
464     * @atomicservice
465     * @since 11
466     */
467    name: string;
468
469    /**
470     * The type of the event.
471     *
472     * @type { EventType }
473     * @syscap SystemCapability.HiviewDFX.HiAppEvent
474     * @since 9
475     */
476    /**
477     * The type of the event.
478     *
479     * @type { EventType }
480     * @syscap SystemCapability.HiviewDFX.HiAppEvent
481     * @atomicservice
482     * @since 11
483     */
484    eventType: EventType;
485
486    /**
487     * The params of the event.
488     *
489     * @type { object }
490     * @syscap SystemCapability.HiviewDFX.HiAppEvent
491     * @since 9
492     */
493    /**
494     * The params of the event.
495     *
496     * @type { object }
497     * @syscap SystemCapability.HiviewDFX.HiAppEvent
498     * @atomicservice
499     * @since 11
500     */
501    params: object;
502  }
503
504  /**
505   * Write application event.
506   *
507   * @param { AppEventInfo } info Application event information to be written.
508   * @returns { Promise<void> } Return Promise.
509   * @throws { BusinessError } 401 - Parameter error.
510   * @throws { BusinessError } 11100001 - Function disabled.
511   * @throws { BusinessError } 11101001 - Invalid event domain.
512   * @throws { BusinessError } 11101002 - Invalid event name.
513   * @throws { BusinessError } 11101003 - Invalid number of event parameters.
514   * @throws { BusinessError } 11101004 - Invalid string length of the event parameter.
515   * @throws { BusinessError } 11101005 - Invalid event parameter name.
516   * @throws { BusinessError } 11101006 - Invalid array length of the event parameter.
517   * @static
518   * @syscap SystemCapability.HiviewDFX.HiAppEvent
519   * @since 9
520   */
521  /**
522   * Write application event.
523   *
524   * @param { AppEventInfo } info Application event information to be written.
525   * @returns { Promise<void> } Return Promise.
526   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
527   * <br>2. Incorrect parameter types.
528   * @throws { BusinessError } 11100001 - Function disabled.
529   * @throws { BusinessError } 11101001 - Invalid event domain.
530   * @throws { BusinessError } 11101002 - Invalid event name.
531   * @throws { BusinessError } 11101003 - Invalid number of event parameters.
532   * @throws { BusinessError } 11101004 - Invalid string length of the event parameter.
533   * @throws { BusinessError } 11101005 - Invalid event parameter name.
534   * @throws { BusinessError } 11101006 - Invalid array length of the event parameter.
535   * @static
536   * @syscap SystemCapability.HiviewDFX.HiAppEvent
537   * @atomicservice
538   * @since 11
539   */
540  function write(info: AppEventInfo): Promise<void>;
541
542  /**
543   * Write application event.
544   *
545   * @param { AppEventInfo } info Application event information to be written.
546   * @param { AsyncCallback<void> } callback Callback function.
547   * @throws { BusinessError } 401 - Parameter error.
548   * @throws { BusinessError } 11100001 - Function disabled.
549   * @throws { BusinessError } 11101001 - Invalid event domain.
550   * @throws { BusinessError } 11101002 - Invalid event name.
551   * @throws { BusinessError } 11101003 - Invalid number of event parameters.
552   * @throws { BusinessError } 11101004 - Invalid string length of the event parameter.
553   * @throws { BusinessError } 11101005 - Invalid event parameter name.
554   * @throws { BusinessError } 11101006 - Invalid array length of the event parameter.
555   * @static
556   * @syscap SystemCapability.HiviewDFX.HiAppEvent
557   * @since 9
558   */
559  /**
560   * Write application event.
561   *
562   * @param { AppEventInfo } info Application event information to be written.
563   * @param { AsyncCallback<void> } callback Callback function.
564   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
565   * <br>2. Incorrect parameter types.
566   * @throws { BusinessError } 11100001 - Function disabled.
567   * @throws { BusinessError } 11101001 - Invalid event domain.
568   * @throws { BusinessError } 11101002 - Invalid event name.
569   * @throws { BusinessError } 11101003 - Invalid number of event parameters.
570   * @throws { BusinessError } 11101004 - Invalid string length of the event parameter.
571   * @throws { BusinessError } 11101005 - Invalid event parameter name.
572   * @throws { BusinessError } 11101006 - Invalid array length of the event parameter.
573   * @static
574   * @syscap SystemCapability.HiviewDFX.HiAppEvent
575   * @atomicservice
576   * @since 11
577   */
578  function write(info: AppEventInfo, callback: AsyncCallback<void>): void;
579
580  /**
581   * Indicates possible parameter types.
582   *
583   * @typedef {number | string | boolean | Array<string>}
584   * @syscap SystemCapability.HiviewDFX.HiAppEvent
585   * @atomicservice
586   * @since 12
587   */
588  type ParamType = number | string | boolean | Array<string>;
589
590  /**
591   * It is used to set custom parameters for events, including both system-subscribed events and custom events.
592   * Existing parameter will be overwritten, and non-existing parameter will be created.
593   *
594   * @param { Record<string, ParamType> } params The parameters of the event.
595   * @param { string } domain The domain of the event.
596   * @param { string } name The name of the event.
597   * @returns { Promise<void> } Return Promise.
598   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
599   * <br>2. Incorrect parameter types.
600   * @throws { BusinessError } 11101007 - The number of parameter keys exceeds the limit.
601   * @static
602   * @syscap SystemCapability.HiviewDFX.HiAppEvent
603   * @atomicservice
604   * @since 12
605   */
606  function setEventParam(params: Record<string, ParamType>, domain: string, name?: string): Promise<void>;
607
608  /**
609   * Set the config for the os event.
610   *
611   * @param { string } name The name of the os event.
612   * @param { Record<string, ParamType> } config The config info of the os event.
613   * @returns { Promise<void> } Return Promise.
614   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
615   * <br>2. Incorrect parameter types; 3.Parameter verification failed.
616   * @static
617   * @syscap SystemCapability.HiviewDFX.HiAppEvent
618   * @atomicservice
619   * @since 15
620   */
621  function setEventConfig(name: string, config: Record<string, ParamType>): Promise<void>;
622
623  /**
624   * Definition of the read event package.
625   *
626   * @interface AppEventPackage
627   * @syscap SystemCapability.HiviewDFX.HiAppEvent
628   * @since 9
629   */
630  /**
631   * Definition of the read event package.
632   *
633   * @interface AppEventPackage
634   * @syscap SystemCapability.HiviewDFX.HiAppEvent
635   * @atomicservice
636   * @since 11
637   */
638  interface AppEventPackage {
639    /**
640     * The id of the package.
641     *
642     * @type { number }
643     * @syscap SystemCapability.HiviewDFX.HiAppEvent
644     * @since 9
645     */
646    /**
647     * The id of the package.
648     *
649     * @type { number }
650     * @syscap SystemCapability.HiviewDFX.HiAppEvent
651     * @atomicservice
652     * @since 11
653     */
654    packageId: number;
655
656    /**
657     * The number of events contained in the package.
658     *
659     * @type { number }
660     * @syscap SystemCapability.HiviewDFX.HiAppEvent
661     * @since 9
662     */
663    /**
664     * The number of events contained in the package.
665     *
666     * @type { number }
667     * @syscap SystemCapability.HiviewDFX.HiAppEvent
668     * @atomicservice
669     * @since 11
670     */
671    row: number;
672
673    /**
674     * The total size of events contained in the package.
675     *
676     * @type { number }
677     * @syscap SystemCapability.HiviewDFX.HiAppEvent
678     * @since 9
679     */
680    /**
681     * The total size of events contained in the package.
682     *
683     * @type { number }
684     * @syscap SystemCapability.HiviewDFX.HiAppEvent
685     * @atomicservice
686     * @since 11
687     */
688    size: number;
689
690    /**
691     * The events data contained in the package.
692     *
693     * @type { string[] }
694     * @syscap SystemCapability.HiviewDFX.HiAppEvent
695     * @since 9
696     */
697    /**
698     * The events data contained in the package.
699     *
700     * @type { string[] }
701     * @syscap SystemCapability.HiviewDFX.HiAppEvent
702     * @atomicservice
703     * @since 11
704     */
705    data: string[];
706
707    /**
708     * The event json format data contained in the package.
709     *
710     * @type { Array<AppEventInfo> }
711     * @syscap SystemCapability.HiviewDFX.HiAppEvent
712     * @atomicservice
713     * @since 12
714     */
715    appEventInfos: Array<AppEventInfo>;
716  }
717
718  /**
719   * Definition of event holder object, which is used to read the event data monitored by the watcher.
720   *
721   * @syscap SystemCapability.HiviewDFX.HiAppEvent
722   * @since 9
723   */
724  /**
725   * Definition of event holder object, which is used to read the event data monitored by the watcher.
726   *
727   * @syscap SystemCapability.HiviewDFX.HiAppEvent
728   * @atomicservice
729   * @since 11
730   */
731  class AppEventPackageHolder {
732    /**
733     * Constructor for AppEventPackageHolder.
734     *
735     * @param { string } watcherName Name of the watcher to read.
736     * @syscap SystemCapability.HiviewDFX.HiAppEvent
737     * @since 9
738     */
739    /**
740     * Constructor for AppEventPackageHolder.
741     *
742     * @param { string } watcherName Name of the watcher to read.
743     * @syscap SystemCapability.HiviewDFX.HiAppEvent
744     * @atomicservice
745     * @since 11
746     */
747    constructor(watcherName: string);
748
749    /**
750     * Set the threshold size per read.
751     *
752     * @param { number } size Threshold size.
753     * @throws { BusinessError } 401 - Parameter error.
754     * @throws { BusinessError } 11104001 - Invalid size value.
755     * @syscap SystemCapability.HiviewDFX.HiAppEvent
756     * @since 9
757     */
758    /**
759     * Set the threshold size per read.
760     *
761     * @param { number } size Threshold size.
762     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
763     * <br>2. Incorrect parameter types.
764     * @throws { BusinessError } 11104001 - Invalid size value.
765     * @syscap SystemCapability.HiviewDFX.HiAppEvent
766     * @atomicservice
767     * @since 11
768     */
769    setSize(size: number): void;
770
771    /**
772     * Set the number of rows per read.
773     *
774     * @param { number } size Row size.
775     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
776     * <br>2. Incorrect parameter types.
777     * @throws { BusinessError } 11104001 - Invalid size value.
778     * @syscap SystemCapability.HiviewDFX.HiAppEvent
779     * @atomicservice
780     * @since 12
781     */
782    setRow(size: number): void;
783
784    /**
785     * Read the event data monitored by the watcher.
786     *
787     * @returns { AppEventPackage } The read event package.
788     * @syscap SystemCapability.HiviewDFX.HiAppEvent
789     * @since 9
790     */
791    /**
792     * Read the event data monitored by the watcher.
793     *
794     * @returns { AppEventPackage } The read event package.
795     * @syscap SystemCapability.HiviewDFX.HiAppEvent
796     * @atomicservice
797     * @since 11
798     */
799    takeNext(): AppEventPackage;
800  }
801
802  /**
803   * Definition of the condition for triggering callback when the watcher monitors event data.
804   *
805   * @interface TriggerCondition
806   * @syscap SystemCapability.HiviewDFX.HiAppEvent
807   * @since 9
808   */
809  /**
810   * Definition of the condition for triggering callback when the watcher monitors event data.
811   *
812   * @interface TriggerCondition
813   * @syscap SystemCapability.HiviewDFX.HiAppEvent
814   * @atomicservice
815   * @since 11
816   */
817  interface TriggerCondition {
818    /**
819     * The number of write events that trigger callback.
820     *
821     * @type { ?number }
822     * @syscap SystemCapability.HiviewDFX.HiAppEvent
823     * @since 9
824     */
825    /**
826     * The number of write events that trigger callback.
827     *
828     * @type { ?number }
829     * @syscap SystemCapability.HiviewDFX.HiAppEvent
830     * @atomicservice
831     * @since 11
832     */
833    row?: number;
834
835    /**
836     * The size of write events that trigger callback.
837     *
838     * @type { ?number }
839     * @syscap SystemCapability.HiviewDFX.HiAppEvent
840     * @since 9
841     */
842    /**
843     * The size of write events that trigger callback.
844     *
845     * @type { ?number }
846     * @syscap SystemCapability.HiviewDFX.HiAppEvent
847     * @atomicservice
848     * @since 11
849     */
850    size?: number;
851
852    /**
853     * The interval for triggering callback.
854     *
855     * @type { ?number }
856     * @syscap SystemCapability.HiviewDFX.HiAppEvent
857     * @since 9
858     */
859    /**
860     * The interval for triggering callback.
861     *
862     * @type { ?number }
863     * @syscap SystemCapability.HiviewDFX.HiAppEvent
864     * @atomicservice
865     * @since 11
866     */
867    timeOut?: number;
868  }
869
870  /**
871   * Definition of event filter object, which is used to filter events monitored by the watcher.
872   *
873   * @interface AppEventFilter
874   * @syscap SystemCapability.HiviewDFX.HiAppEvent
875   * @since 9
876   */
877  /**
878   * Definition of event filter object, which is used to filter events monitored by the watcher.
879   *
880   * @interface AppEventFilter
881   * @syscap SystemCapability.HiviewDFX.HiAppEvent
882   * @atomicservice
883   * @since 11
884   */
885  interface AppEventFilter {
886    /**
887     * The name of the event domain to be monitored by the watcher.
888     *
889     * @type { string }
890     * @syscap SystemCapability.HiviewDFX.HiAppEvent
891     * @since 9
892     */
893    /**
894     * The name of the event domain to be monitored by the watcher.
895     *
896     * @type { string }
897     * @syscap SystemCapability.HiviewDFX.HiAppEvent
898     * @atomicservice
899     * @since 11
900     */
901    domain: string;
902
903    /**
904     * The types of the events to be monitored by the watcher.
905     *
906     * @type { ?EventType[] }
907     * @syscap SystemCapability.HiviewDFX.HiAppEvent
908     * @since 9
909     */
910    /**
911     * The types of the events to be monitored by the watcher.
912     *
913     * @type { ?EventType[] }
914     * @syscap SystemCapability.HiviewDFX.HiAppEvent
915     * @atomicservice
916     * @since 11
917     */
918    eventTypes?: EventType[];
919
920    /**
921     * The names of the events to be monitored by the watcher.
922     *
923     * @type { ?string[] }
924     * @syscap SystemCapability.HiviewDFX.HiAppEvent
925     * @atomicservice
926     * @since 11
927     */
928    names?: string[];
929  }
930
931  /**
932   * Definition of event group.
933   *
934   * @interface AppEventGroup
935   * @syscap SystemCapability.HiviewDFX.HiAppEvent
936   * @atomicservice
937   * @since 11
938   */
939  interface AppEventGroup {
940    /**
941     * The name of the event.
942     *
943     * @type { string }
944     * @syscap SystemCapability.HiviewDFX.HiAppEvent
945     * @atomicservice
946     * @since 11
947     */
948    name: string;
949
950    /**
951     * The event array which is group by the name.
952     *
953     * @type { Array<AppEventInfo> }
954     * @syscap SystemCapability.HiviewDFX.HiAppEvent
955     * @atomicservice
956     * @since 11
957     */
958    appEventInfos: Array<AppEventInfo>;
959  }
960
961  /**
962   * Definition of event watcher object, which is used to monitor written event data.
963   *
964   * @interface Watcher
965   * @syscap SystemCapability.HiviewDFX.HiAppEvent
966   * @since 9
967   */
968  /**
969   * Definition of event watcher object, which is used to monitor written event data.
970   *
971   * @interface Watcher
972   * @syscap SystemCapability.HiviewDFX.HiAppEvent
973   * @atomicservice
974   * @since 11
975   */
976  interface Watcher {
977    /**
978     * The name of watcher.
979     *
980     * @type { string }
981     * @syscap SystemCapability.HiviewDFX.HiAppEvent
982     * @since 9
983     */
984    /**
985     * The name of watcher.
986     *
987     * @type { string }
988     * @syscap SystemCapability.HiviewDFX.HiAppEvent
989     * @atomicservice
990     * @since 11
991     */
992    name: string;
993
994    /**
995     * The condition for triggering callback.
996     *
997     * @type { ?TriggerCondition }
998     * @syscap SystemCapability.HiviewDFX.HiAppEvent
999     * @since 9
1000     */
1001    /**
1002     * The condition for triggering callback.
1003     *
1004     * @type { ?TriggerCondition }
1005     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1006     * @atomicservice
1007     * @since 11
1008     */
1009    triggerCondition?: TriggerCondition;
1010
1011    /**
1012     * The event filters for monitoring events.
1013     *
1014     * @type { ?AppEventFilter[] }
1015     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1016     * @since 9
1017     */
1018    /**
1019     * The event filters for monitoring events.
1020     *
1021     * @type { ?AppEventFilter[] }
1022     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1023     * @atomicservice
1024     * @since 11
1025     */
1026    appEventFilters?: AppEventFilter[];
1027
1028    /**
1029     * The callback function of watcher.
1030     *
1031     * @type { ?function }
1032     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1033     * @since 9
1034     */
1035    /**
1036     * The callback function of watcher.
1037     *
1038     * @type { ?function }
1039     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1040     * @atomicservice
1041     * @since 11
1042     */
1043    onTrigger?: (curRow: number, curSize: number, holder: AppEventPackageHolder) => void;
1044
1045    /**
1046     * The callback function, when watcher receive the event.
1047     *
1048     * @type { ?function }
1049     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1050     * @atomicservice
1051     * @since 11
1052     */
1053    onReceive?: (domain: string, appEventGroups: Array<AppEventGroup>) => void;
1054  }
1055
1056  /**
1057   * Add event watcher.
1058   *
1059   * @param { Watcher } watcher Watcher object for monitoring events.
1060   * @returns { AppEventPackageHolder } Holder object, which is used to read the monitoring data of the watcher.
1061   * @throws { BusinessError } 401 - Parameter error.
1062   * @throws { BusinessError } 11102001 - Invalid watcher name.
1063   * @throws { BusinessError } 11102002 - Invalid filtering event domain.
1064   * @throws { BusinessError } 11102003 - Invalid row value.
1065   * @throws { BusinessError } 11102004 - Invalid size value.
1066   * @throws { BusinessError } 11102005 - Invalid timeout value.
1067   * @static
1068   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1069   * @since 9
1070   */
1071  /**
1072   * Add event watcher.
1073   *
1074   * @param { Watcher } watcher Watcher object for monitoring events.
1075   * @returns { AppEventPackageHolder } Holder object, which is used to read the monitoring data of the watcher.
1076   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1077   * <br>2. Incorrect parameter types.
1078   * @throws { BusinessError } 11102001 - Invalid watcher name.
1079   * @throws { BusinessError } 11102002 - Invalid filtering event domain.
1080   * @throws { BusinessError } 11102003 - Invalid row value.
1081   * @throws { BusinessError } 11102004 - Invalid size value.
1082   * @throws { BusinessError } 11102005 - Invalid timeout value.
1083   * @static
1084   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1085   * @atomicservice
1086   * @since 11
1087   */
1088  function addWatcher(watcher: Watcher): AppEventPackageHolder;
1089
1090  /**
1091   * Remove event watcher.
1092   *
1093   * @param { Watcher } watcher Watcher object for monitoring events.
1094   * @throws { BusinessError } 401 - Parameter error.
1095   * @throws { BusinessError } 11102001 - Invalid watcher name.
1096   * @static
1097   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1098   * @since 9
1099   */
1100  /**
1101   * Remove event watcher.
1102   *
1103   * @param { Watcher } watcher Watcher object for monitoring events.
1104   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1105   * <br>2. Incorrect parameter types.
1106   * @throws { BusinessError } 11102001 - Invalid watcher name.
1107   * @static
1108   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1109   * @atomicservice
1110   * @since 11
1111   */
1112  function removeWatcher(watcher: Watcher): void;
1113
1114  /**
1115   * Clear all local logging data of the application.
1116   *
1117   * @static
1118   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1119   * @since 9
1120   */
1121  /**
1122   * Clear all local logging data of the application.
1123   *
1124   * @static
1125   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1126   * @atomicservice
1127   * @since 11
1128   */
1129  function clearData(): void;
1130
1131  /**
1132   * Set user ID.
1133   *
1134   * @param { string } name The key of the user ID.
1135   * @param { string } value The value of the user ID.
1136   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1137   * <br>2. Incorrect parameter types.
1138   * @static
1139   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1140   * @atomicservice
1141   * @since 11
1142   */
1143  function setUserId(name: string, value: string): void;
1144
1145  /**
1146   * Get user ID.
1147   *
1148   * @param { string } name The key of the user ID.
1149   * @returns { string } the user ID value.
1150   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1151   * <br>2. Incorrect parameter types.
1152   * @static
1153   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1154   * @atomicservice
1155   * @since 11
1156   */
1157  function getUserId(name: string): string;
1158
1159  /**
1160   * Set user property.
1161   *
1162   * @param { string } name The key of the user property.
1163   * @param { string } value The value of the user property.
1164   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1165   * <br>2. Incorrect parameter types.
1166   * @static
1167   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1168   * @atomicservice
1169   * @since 11
1170   */
1171  function setUserProperty(name: string, value: string): void;
1172
1173  /**
1174   * Get user property.
1175   *
1176   * @param { string } name The key of the user property.
1177   * @returns { string } the user property value.
1178   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1179   * <br>2. Incorrect parameter types.
1180   * @static
1181   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1182   * @atomicservice
1183   * @since 11
1184   */
1185  function getUserProperty(name: string): string;
1186
1187  /**
1188   * Describe the event config to be reported by processor.
1189   *
1190   * @interface AppEventReportConfig
1191   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1192   * @atomicservice
1193   * @since 11
1194   */
1195  interface AppEventReportConfig {
1196    /**
1197     * The domain of the event.
1198     *
1199     * @type { ?string }
1200     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1201     * @atomicservice
1202     * @since 11
1203     */
1204    domain?: string;
1205
1206    /**
1207     * The name of the event.
1208     *
1209     * @type { ?string }
1210     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1211     * @atomicservice
1212     * @since 11
1213     */
1214    name?: string;
1215
1216    /**
1217     * The realtime report event.
1218     *
1219     * @type { ?boolean }
1220     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1221     * @atomicservice
1222     * @since 11
1223     */
1224    isRealTime?: boolean;
1225  }
1226
1227  /**
1228   * Definition of the processor.
1229   *
1230   * @interface Processor
1231   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1232   * @atomicservice
1233   * @since 11
1234   */
1235  interface Processor {
1236    /**
1237     * The name of the processor.
1238     *
1239     * @type { string }
1240     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1241     * @atomicservice
1242     * @since 11
1243     */
1244    name: string;
1245
1246    /**
1247     * The processor enable the developer to debug.
1248     *
1249     * @type { ?boolean }
1250     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1251     * @atomicservice
1252     * @since 11
1253     */
1254    debugMode?: boolean;
1255
1256    /**
1257     * The server location which used for the processor to receive the data, defined by the processor.
1258     *
1259     * @type { ?string }
1260     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1261     * @atomicservice
1262     * @since 11
1263     */
1264    routeInfo?: string;
1265
1266    /**
1267     * The app ID is provided by the processor.
1268     *
1269     * @type { ?string }
1270     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1271     * @atomicservice
1272     * @since 11
1273     */
1274    appId?: string;
1275
1276    /**
1277     * The processor report the event when start.
1278     *
1279     * @type { ?boolean }
1280     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1281     * @atomicservice
1282     * @since 11
1283     */
1284    onStartReport?: boolean;
1285
1286    /**
1287     * The processor report the event when the application onBackground.
1288     *
1289     * @type { ?boolean }
1290     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1291     * @atomicservice
1292     * @since 11
1293     */
1294    onBackgroundReport?: boolean;
1295
1296    /**
1297     * The processor report the event according to the period.
1298     *
1299     * @type { ?number }
1300     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1301     * @atomicservice
1302     * @since 11
1303     */
1304    periodReport?: number;
1305
1306    /**
1307     * The processor report the event according to the batch size.
1308     *
1309     * @type { ?number }
1310     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1311     * @atomicservice
1312     * @since 11
1313     */
1314    batchReport?: number;
1315
1316    /**
1317     * The user ID names which the processor can report.
1318     *
1319     * @type { ?string[] }
1320     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1321     * @atomicservice
1322     * @since 11
1323     */
1324    userIds?: string[];
1325
1326    /**
1327     * The user property names which the processor can report.
1328     *
1329     * @type { ?string[] }
1330     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1331     * @atomicservice
1332     * @since 11
1333     */
1334    userProperties?: string[];
1335
1336    /**
1337     * The events which the processor can report.
1338     *
1339     * @type { ?AppEventReportConfig[] }
1340     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1341     * @atomicservice
1342     * @since 11
1343     */
1344    eventConfigs?: AppEventReportConfig[];
1345
1346    /**
1347     * The processor config id.
1348     *
1349     * @type { ?number }
1350     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1351     * @atomicservice
1352     * @since 12
1353     */
1354    configId?: number;
1355
1356    /**
1357     * The processor set custom config data.
1358     *
1359     * @type { ?Record<string, string> }
1360     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1361     * @atomicservice
1362     * @since 12
1363     */
1364    customConfigs?: Record<string, string>;
1365  }
1366
1367  /**
1368   * Add the processor, who can report the event.
1369   *
1370   * @param { Processor } processor The instance which report the event
1371   * @returns { number }  The processor unique ID.
1372   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1373   * <br>2. Incorrect parameter types.
1374   * @static
1375   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1376   * @atomicservice
1377   * @since 11
1378   */
1379  function addProcessor(processor: Processor): number;
1380
1381  /**
1382   * Remove the processor.
1383   *
1384   * @param { number } id The processor unique ID.
1385   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1386   * <br>2. Incorrect parameter types.
1387   * @static
1388   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1389   * @atomicservice
1390   * @since 11
1391   */
1392  function removeProcessor(id: number): void;
1393}
1394
1395export default hiAppEvent;
1396