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