• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022-2024 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   * Definition of the read event package.
610   *
611   * @interface AppEventPackage
612   * @syscap SystemCapability.HiviewDFX.HiAppEvent
613   * @since 9
614   */
615  /**
616   * Definition of the read event package.
617   *
618   * @interface AppEventPackage
619   * @syscap SystemCapability.HiviewDFX.HiAppEvent
620   * @atomicservice
621   * @since 11
622   */
623  interface AppEventPackage {
624    /**
625     * The id of the package.
626     *
627     * @type { number }
628     * @syscap SystemCapability.HiviewDFX.HiAppEvent
629     * @since 9
630     */
631    /**
632     * The id of the package.
633     *
634     * @type { number }
635     * @syscap SystemCapability.HiviewDFX.HiAppEvent
636     * @atomicservice
637     * @since 11
638     */
639    packageId: number;
640
641    /**
642     * The number of events contained in the package.
643     *
644     * @type { number }
645     * @syscap SystemCapability.HiviewDFX.HiAppEvent
646     * @since 9
647     */
648    /**
649     * The number of events contained in the package.
650     *
651     * @type { number }
652     * @syscap SystemCapability.HiviewDFX.HiAppEvent
653     * @atomicservice
654     * @since 11
655     */
656    row: number;
657
658    /**
659     * The total size of events contained in the package.
660     *
661     * @type { number }
662     * @syscap SystemCapability.HiviewDFX.HiAppEvent
663     * @since 9
664     */
665    /**
666     * The total size of events contained in the package.
667     *
668     * @type { number }
669     * @syscap SystemCapability.HiviewDFX.HiAppEvent
670     * @atomicservice
671     * @since 11
672     */
673    size: number;
674
675    /**
676     * The events data contained in the package.
677     *
678     * @type { string[] }
679     * @syscap SystemCapability.HiviewDFX.HiAppEvent
680     * @since 9
681     */
682    /**
683     * The events data contained in the package.
684     *
685     * @type { string[] }
686     * @syscap SystemCapability.HiviewDFX.HiAppEvent
687     * @atomicservice
688     * @since 11
689     */
690    data: string[];
691
692    /**
693     * The event json format data contained in the package.
694     *
695     * @type { Array<AppEventInfo> }
696     * @syscap SystemCapability.HiviewDFX.HiAppEvent
697     * @atomicservice
698     * @since 12
699     */
700    appEventInfos: Array<AppEventInfo>;
701  }
702
703  /**
704   * Definition of event holder object, which is used to read the event data monitored by the watcher.
705   *
706   * @syscap SystemCapability.HiviewDFX.HiAppEvent
707   * @since 9
708   */
709  /**
710   * Definition of event holder object, which is used to read the event data monitored by the watcher.
711   *
712   * @syscap SystemCapability.HiviewDFX.HiAppEvent
713   * @atomicservice
714   * @since 11
715   */
716  class AppEventPackageHolder {
717    /**
718     * Constructor for AppEventPackageHolder.
719     *
720     * @param { string } watcherName Name of the watcher to read.
721     * @syscap SystemCapability.HiviewDFX.HiAppEvent
722     * @since 9
723     */
724    /**
725     * Constructor for AppEventPackageHolder.
726     *
727     * @param { string } watcherName Name of the watcher to read.
728     * @syscap SystemCapability.HiviewDFX.HiAppEvent
729     * @atomicservice
730     * @since 11
731     */
732    constructor(watcherName: string);
733
734    /**
735     * Set the threshold size per read.
736     *
737     * @param { number } size Threshold size.
738     * @throws { BusinessError } 401 - Parameter error.
739     * @throws { BusinessError } 11104001 - Invalid size value.
740     * @syscap SystemCapability.HiviewDFX.HiAppEvent
741     * @since 9
742     */
743    /**
744     * Set the threshold size per read.
745     *
746     * @param { number } size Threshold size.
747     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
748     * <br>2. Incorrect parameter types.
749     * @throws { BusinessError } 11104001 - Invalid size value.
750     * @syscap SystemCapability.HiviewDFX.HiAppEvent
751     * @atomicservice
752     * @since 11
753     */
754    setSize(size: number): void;
755
756    /**
757     * Set the number of rows per read.
758     *
759     * @param { number } size Row size.
760     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
761     * <br>2. Incorrect parameter types.
762     * @throws { BusinessError } 11104001 - Invalid size value.
763     * @syscap SystemCapability.HiviewDFX.HiAppEvent
764     * @atomicservice
765     * @since 12
766     */
767    setRow(size: number): void;
768
769    /**
770     * Read the event data monitored by the watcher.
771     *
772     * @returns { AppEventPackage } The read event package.
773     * @syscap SystemCapability.HiviewDFX.HiAppEvent
774     * @since 9
775     */
776    /**
777     * Read the event data monitored by the watcher.
778     *
779     * @returns { AppEventPackage } The read event package.
780     * @syscap SystemCapability.HiviewDFX.HiAppEvent
781     * @atomicservice
782     * @since 11
783     */
784    takeNext(): AppEventPackage;
785  }
786
787  /**
788   * Definition of the condition for triggering callback when the watcher monitors event data.
789   *
790   * @interface TriggerCondition
791   * @syscap SystemCapability.HiviewDFX.HiAppEvent
792   * @since 9
793   */
794  /**
795   * Definition of the condition for triggering callback when the watcher monitors event data.
796   *
797   * @interface TriggerCondition
798   * @syscap SystemCapability.HiviewDFX.HiAppEvent
799   * @atomicservice
800   * @since 11
801   */
802  interface TriggerCondition {
803    /**
804     * The number of write events that trigger callback.
805     *
806     * @type { ?number }
807     * @syscap SystemCapability.HiviewDFX.HiAppEvent
808     * @since 9
809     */
810    /**
811     * The number of write events that trigger callback.
812     *
813     * @type { ?number }
814     * @syscap SystemCapability.HiviewDFX.HiAppEvent
815     * @atomicservice
816     * @since 11
817     */
818    row?: number;
819
820    /**
821     * The size of write events that trigger callback.
822     *
823     * @type { ?number }
824     * @syscap SystemCapability.HiviewDFX.HiAppEvent
825     * @since 9
826     */
827    /**
828     * The size of write events that trigger callback.
829     *
830     * @type { ?number }
831     * @syscap SystemCapability.HiviewDFX.HiAppEvent
832     * @atomicservice
833     * @since 11
834     */
835    size?: number;
836
837    /**
838     * The interval for triggering callback.
839     *
840     * @type { ?number }
841     * @syscap SystemCapability.HiviewDFX.HiAppEvent
842     * @since 9
843     */
844    /**
845     * The interval for triggering callback.
846     *
847     * @type { ?number }
848     * @syscap SystemCapability.HiviewDFX.HiAppEvent
849     * @atomicservice
850     * @since 11
851     */
852    timeOut?: number;
853  }
854
855  /**
856   * Definition of event filter object, which is used to filter events monitored by the watcher.
857   *
858   * @interface AppEventFilter
859   * @syscap SystemCapability.HiviewDFX.HiAppEvent
860   * @since 9
861   */
862  /**
863   * Definition of event filter object, which is used to filter events monitored by the watcher.
864   *
865   * @interface AppEventFilter
866   * @syscap SystemCapability.HiviewDFX.HiAppEvent
867   * @atomicservice
868   * @since 11
869   */
870  interface AppEventFilter {
871    /**
872     * The name of the event domain to be monitored by the watcher.
873     *
874     * @type { string }
875     * @syscap SystemCapability.HiviewDFX.HiAppEvent
876     * @since 9
877     */
878    /**
879     * The name of the event domain to be monitored by the watcher.
880     *
881     * @type { string }
882     * @syscap SystemCapability.HiviewDFX.HiAppEvent
883     * @atomicservice
884     * @since 11
885     */
886    domain: string;
887
888    /**
889     * The types of the events to be monitored by the watcher.
890     *
891     * @type { ?EventType[] }
892     * @syscap SystemCapability.HiviewDFX.HiAppEvent
893     * @since 9
894     */
895    /**
896     * The types of the events to be monitored by the watcher.
897     *
898     * @type { ?EventType[] }
899     * @syscap SystemCapability.HiviewDFX.HiAppEvent
900     * @atomicservice
901     * @since 11
902     */
903    eventTypes?: EventType[];
904
905    /**
906     * The names of the events to be monitored by the watcher.
907     *
908     * @type { ?string[] }
909     * @syscap SystemCapability.HiviewDFX.HiAppEvent
910     * @atomicservice
911     * @since 11
912     */
913    names?: string[];
914  }
915
916  /**
917   * Definition of event group.
918   *
919   * @interface AppEventGroup
920   * @syscap SystemCapability.HiviewDFX.HiAppEvent
921   * @atomicservice
922   * @since 11
923   */
924  interface AppEventGroup {
925    /**
926     * The name of the event.
927     *
928     * @type { string }
929     * @syscap SystemCapability.HiviewDFX.HiAppEvent
930     * @atomicservice
931     * @since 11
932     */
933    name: string;
934
935    /**
936     * The event array which is group by the name.
937     *
938     * @type { Array<AppEventInfo> }
939     * @syscap SystemCapability.HiviewDFX.HiAppEvent
940     * @atomicservice
941     * @since 11
942     */
943    appEventInfos: Array<AppEventInfo>;
944  }
945
946  /**
947   * Definition of event watcher object, which is used to monitor written event data.
948   *
949   * @interface Watcher
950   * @syscap SystemCapability.HiviewDFX.HiAppEvent
951   * @since 9
952   */
953  /**
954   * Definition of event watcher object, which is used to monitor written event data.
955   *
956   * @interface Watcher
957   * @syscap SystemCapability.HiviewDFX.HiAppEvent
958   * @atomicservice
959   * @since 11
960   */
961  interface Watcher {
962    /**
963     * The name of watcher.
964     *
965     * @type { string }
966     * @syscap SystemCapability.HiviewDFX.HiAppEvent
967     * @since 9
968     */
969    /**
970     * The name of watcher.
971     *
972     * @type { string }
973     * @syscap SystemCapability.HiviewDFX.HiAppEvent
974     * @atomicservice
975     * @since 11
976     */
977    name: string;
978
979    /**
980     * The condition for triggering callback.
981     *
982     * @type { ?TriggerCondition }
983     * @syscap SystemCapability.HiviewDFX.HiAppEvent
984     * @since 9
985     */
986    /**
987     * The condition for triggering callback.
988     *
989     * @type { ?TriggerCondition }
990     * @syscap SystemCapability.HiviewDFX.HiAppEvent
991     * @atomicservice
992     * @since 11
993     */
994    triggerCondition?: TriggerCondition;
995
996    /**
997     * The event filters for monitoring events.
998     *
999     * @type { ?AppEventFilter[] }
1000     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1001     * @since 9
1002     */
1003    /**
1004     * The event filters for monitoring events.
1005     *
1006     * @type { ?AppEventFilter[] }
1007     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1008     * @atomicservice
1009     * @since 11
1010     */
1011    appEventFilters?: AppEventFilter[];
1012
1013    /**
1014     * The callback function of watcher.
1015     *
1016     * @type { ?function }
1017     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1018     * @since 9
1019     */
1020    /**
1021     * The callback function of watcher.
1022     *
1023     * @type { ?function }
1024     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1025     * @atomicservice
1026     * @since 11
1027     */
1028    onTrigger?: (curRow: number, curSize: number, holder: AppEventPackageHolder) => void;
1029
1030    /**
1031     * The callback function, when watcher receive the event.
1032     *
1033     * @type { ?function }
1034     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1035     * @atomicservice
1036     * @since 11
1037     */
1038    onReceive?: (domain: string, appEventGroups: Array<AppEventGroup>) => void;
1039  }
1040
1041  /**
1042   * Add event watcher.
1043   *
1044   * @param { Watcher } watcher Watcher object for monitoring events.
1045   * @returns { AppEventPackageHolder } Holder object, which is used to read the monitoring data of the watcher.
1046   * @throws { BusinessError } 401 - Parameter error.
1047   * @throws { BusinessError } 11102001 - Invalid watcher name.
1048   * @throws { BusinessError } 11102002 - Invalid filtering event domain.
1049   * @throws { BusinessError } 11102003 - Invalid row value.
1050   * @throws { BusinessError } 11102004 - Invalid size value.
1051   * @throws { BusinessError } 11102005 - Invalid timeout value.
1052   * @static
1053   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1054   * @since 9
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. Possible causes: 1. Mandatory parameters are left unspecified;
1062   * <br>2. Incorrect parameter types.
1063   * @throws { BusinessError } 11102001 - Invalid watcher name.
1064   * @throws { BusinessError } 11102002 - Invalid filtering event domain.
1065   * @throws { BusinessError } 11102003 - Invalid row value.
1066   * @throws { BusinessError } 11102004 - Invalid size value.
1067   * @throws { BusinessError } 11102005 - Invalid timeout value.
1068   * @static
1069   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1070   * @atomicservice
1071   * @since 11
1072   */
1073  function addWatcher(watcher: Watcher): AppEventPackageHolder;
1074
1075  /**
1076   * Remove event watcher.
1077   *
1078   * @param { Watcher } watcher Watcher object for monitoring events.
1079   * @throws { BusinessError } 401 - Parameter error.
1080   * @throws { BusinessError } 11102001 - Invalid watcher name.
1081   * @static
1082   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1083   * @since 9
1084   */
1085  /**
1086   * Remove event watcher.
1087   *
1088   * @param { Watcher } watcher Watcher object for monitoring events.
1089   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1090   * <br>2. Incorrect parameter types.
1091   * @throws { BusinessError } 11102001 - Invalid watcher name.
1092   * @static
1093   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1094   * @atomicservice
1095   * @since 11
1096   */
1097  function removeWatcher(watcher: Watcher): void;
1098
1099  /**
1100   * Clear all local logging data of the application.
1101   *
1102   * @static
1103   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1104   * @since 9
1105   */
1106  /**
1107   * Clear all local logging data of the application.
1108   *
1109   * @static
1110   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1111   * @atomicservice
1112   * @since 11
1113   */
1114  function clearData(): void;
1115
1116  /**
1117   * Set user ID.
1118   *
1119   * @param { string } name The key of the user ID.
1120   * @param { string } value The value of the user ID.
1121   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1122   * <br>2. Incorrect parameter types.
1123   * @static
1124   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1125   * @atomicservice
1126   * @since 11
1127   */
1128  function setUserId(name: string, value: string): void;
1129
1130  /**
1131   * Get user ID.
1132   *
1133   * @param { string } name The key of the user ID.
1134   * @returns { string } the user ID value.
1135   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1136   * <br>2. Incorrect parameter types.
1137   * @static
1138   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1139   * @atomicservice
1140   * @since 11
1141   */
1142  function getUserId(name: string): string;
1143
1144  /**
1145   * Set user property.
1146   *
1147   * @param { string } name The key of the user property.
1148   * @param { string } value The value of the user property.
1149   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1150   * <br>2. Incorrect parameter types.
1151   * @static
1152   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1153   * @atomicservice
1154   * @since 11
1155   */
1156  function setUserProperty(name: string, value: string): void;
1157
1158  /**
1159   * Get user property.
1160   *
1161   * @param { string } name The key of the user property.
1162   * @returns { string } the user property value.
1163   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1164   * <br>2. Incorrect parameter types.
1165   * @static
1166   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1167   * @atomicservice
1168   * @since 11
1169   */
1170  function getUserProperty(name: string): string;
1171
1172  /**
1173   * Describe the event config to be reported by processor.
1174   *
1175   * @interface AppEventReportConfig
1176   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1177   * @atomicservice
1178   * @since 11
1179   */
1180  interface AppEventReportConfig {
1181    /**
1182     * The domain of the event.
1183     *
1184     * @type { ?string }
1185     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1186     * @atomicservice
1187     * @since 11
1188     */
1189    domain?: string;
1190
1191    /**
1192     * The name of the event.
1193     *
1194     * @type { ?string }
1195     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1196     * @atomicservice
1197     * @since 11
1198     */
1199    name?: string;
1200
1201    /**
1202     * The realtime report event.
1203     *
1204     * @type { ?boolean }
1205     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1206     * @atomicservice
1207     * @since 11
1208     */
1209    isRealTime?: boolean;
1210  }
1211
1212  /**
1213   * Definition of the processor.
1214   *
1215   * @interface Processor
1216   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1217   * @atomicservice
1218   * @since 11
1219   */
1220  interface Processor {
1221    /**
1222     * The name of the processor.
1223     *
1224     * @type { string }
1225     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1226     * @atomicservice
1227     * @since 11
1228     */
1229    name: string;
1230
1231    /**
1232     * The processor enable the developer to debug.
1233     *
1234     * @type { ?boolean }
1235     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1236     * @atomicservice
1237     * @since 11
1238     */
1239    debugMode?: boolean;
1240
1241    /**
1242     * The server location which used for the processor to receive the data, defined by the processor.
1243     *
1244     * @type { ?string }
1245     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1246     * @atomicservice
1247     * @since 11
1248     */
1249    routeInfo?: string;
1250
1251    /**
1252     * The app ID is provided by the processor.
1253     *
1254     * @type { ?string }
1255     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1256     * @atomicservice
1257     * @since 11
1258     */
1259    appId?: string;
1260
1261    /**
1262     * The processor report the event when start.
1263     *
1264     * @type { ?boolean }
1265     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1266     * @atomicservice
1267     * @since 11
1268     */
1269    onStartReport?: boolean;
1270
1271    /**
1272     * The processor report the event when the application onBackground.
1273     *
1274     * @type { ?boolean }
1275     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1276     * @atomicservice
1277     * @since 11
1278     */
1279    onBackgroundReport?: boolean;
1280
1281    /**
1282     * The processor report the event according to the period.
1283     *
1284     * @type { ?number }
1285     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1286     * @atomicservice
1287     * @since 11
1288     */
1289    periodReport?: number;
1290
1291    /**
1292     * The processor report the event according to the batch size.
1293     *
1294     * @type { ?number }
1295     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1296     * @atomicservice
1297     * @since 11
1298     */
1299    batchReport?: number;
1300
1301    /**
1302     * The user ID names which the processor can report.
1303     *
1304     * @type { ?string[] }
1305     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1306     * @atomicservice
1307     * @since 11
1308     */
1309    userIds?: string[];
1310
1311    /**
1312     * The user property names which the processor can report.
1313     *
1314     * @type { ?string[] }
1315     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1316     * @atomicservice
1317     * @since 11
1318     */
1319    userProperties?: string[];
1320
1321    /**
1322     * The events which the processor can report.
1323     *
1324     * @type { ?AppEventReportConfig[] }
1325     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1326     * @atomicservice
1327     * @since 11
1328     */
1329    eventConfigs?: AppEventReportConfig[];
1330
1331    /**
1332     * The processor config id.
1333     *
1334     * @type { ?number }
1335     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1336     * @atomicservice
1337     * @since 12
1338     */
1339    configId?: number;
1340
1341    /**
1342     * The processor set custom config data.
1343     *
1344     * @type { ?Record<string, string> }
1345     * @syscap SystemCapability.HiviewDFX.HiAppEvent
1346     * @atomicservice
1347     * @since 12
1348     */
1349    customConfigs?: Record<string, string>;
1350  }
1351
1352  /**
1353   * Add the processor, who can report the event.
1354   *
1355   * @param { Processor } processor The instance which report the event
1356   * @returns { number }  The processor unique ID.
1357   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1358   * <br>2. Incorrect parameter types.
1359   * @static
1360   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1361   * @atomicservice
1362   * @since 11
1363   */
1364  function addProcessor(processor: Processor): number;
1365
1366  /**
1367   * Remove the processor.
1368   *
1369   * @param { number } id The processor unique ID.
1370   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1371   * <br>2. Incorrect parameter types.
1372   * @static
1373   * @syscap SystemCapability.HiviewDFX.HiAppEvent
1374   * @atomicservice
1375   * @since 11
1376   */
1377  function removeProcessor(id: number): void;
1378}
1379
1380export default hiAppEvent;
1381