• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 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
16import { AsyncCallback } from './basic';
17
18/**
19 * Provides the event logging function for applications to log the fault, statistical, security,
20 * and user behavior events reported during running. Based on event information,
21 * you will be able to analyze the running status of applications.
22 *
23 * @since 7
24 * @syscap SystemCapability.HiviewDFX.HiAppEvent
25 * @deprecated since 9
26 * @useinstead ohos.hiviewdfx.hiAppEvent
27 */
28declare namespace hiAppEvent {
29    /**
30     * Enumerate application event types.
31     *
32     * @since 7
33     * @syscap SystemCapability.HiviewDFX.HiAppEvent
34     */
35    enum EventType {
36        /**
37         * Fault event.
38         *
39         * @since 7
40         * @syscap SystemCapability.HiviewDFX.HiAppEvent
41         */
42        FAULT = 1,
43
44        /**
45         * Statistic event.
46         *
47         * @since 7
48         * @syscap SystemCapability.HiviewDFX.HiAppEvent
49         */
50        STATISTIC = 2,
51
52        /**
53         * Security event.
54         *
55         * @since 7
56         * @syscap SystemCapability.HiviewDFX.HiAppEvent
57         */
58        SECURITY = 3,
59
60        /**
61         * User behavior event.
62         *
63         * @since 7
64         * @syscap SystemCapability.HiviewDFX.HiAppEvent
65         */
66        BEHAVIOR = 4
67    }
68
69    /**
70     * Preset event.
71     *
72     * @since 7
73     * @syscap SystemCapability.HiviewDFX.HiAppEvent
74     */
75    namespace Event {
76        /**
77         * User login event.
78         *
79         * @since 7
80         * @syscap SystemCapability.HiviewDFX.HiAppEvent
81         */
82        const USER_LOGIN: string;
83
84        /**
85         * User logout event.
86         *
87         * @since 7
88         * @syscap SystemCapability.HiviewDFX.HiAppEvent
89         */
90        const USER_LOGOUT: string;
91
92        /**
93         * Distributed service event.
94         *
95         * @since 7
96         * @syscap SystemCapability.HiviewDFX.HiAppEvent
97         */
98        const DISTRIBUTED_SERVICE_START: string;
99    }
100
101    /**
102     * Preset param.
103     *
104     * @since 7
105     * @syscap SystemCapability.HiviewDFX.HiAppEvent
106     */
107    namespace Param {
108        /**
109         * User id.
110         *
111         * @since 7
112         * @syscap SystemCapability.HiviewDFX.HiAppEvent
113         */
114        const USER_ID: string;
115
116        /**
117         * Distributed service name.
118         *
119         * @since 7
120         * @syscap SystemCapability.HiviewDFX.HiAppEvent
121         */
122        const DISTRIBUTED_SERVICE_NAME: string;
123
124        /**
125         * Distributed service instance id.
126         *
127         * @since 7
128         * @syscap SystemCapability.HiviewDFX.HiAppEvent
129         */
130        const DISTRIBUTED_SERVICE_INSTANCE_ID: string;
131    }
132
133    /**
134     * Write application event.
135     *
136     * @since 7
137     * @syscap SystemCapability.HiviewDFX.HiAppEvent
138     * @static
139     * @param {string} eventName Application event name.
140     * @param {EventType} eventType Application event type.
141     * @param {object} keyValues Application event key-value pair params.
142     * @param {AsyncCallback} [callback] Callback function.
143     * @returns {void | Promise<void>} No callback return Promise otherwise return void.
144     */
145    function write(eventName: string, eventType: EventType, keyValues: object): Promise<void>;
146    function write(eventName: string, eventType: EventType, keyValues: object, callback: AsyncCallback<void>): void;
147
148    /**
149     * Application event logging configuration interface.
150     *
151     * @since 7
152     * @syscap SystemCapability.HiviewDFX.HiAppEvent
153     * @static
154     * @param {ConfigOption} config Application event logging configuration item object.
155     * @returns {boolean} Configuration result.
156     */
157    function configure(config: ConfigOption): boolean;
158
159    /**
160     * Describe the options for the configuration.
161     *
162     * @since 7
163     * @syscap SystemCapability.HiviewDFX.HiAppEvent
164     */
165    interface ConfigOption {
166        /**
167         * Configuration item: application event logging switch.
168         *
169         * @since 7
170         * @syscap SystemCapability.HiviewDFX.HiAppEvent
171         */
172        disable?: boolean;
173
174        /**
175         * Configuration item: event file directory storage quota size.
176         *
177         * @since 7
178         * @syscap SystemCapability.HiviewDFX.HiAppEvent
179         */
180        maxStorage?: string;
181    }
182}
183
184export default hiAppEvent;
185