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 * @devices phone, tablet, tv, wearable 25 */ 26declare namespace hiAppEvent { 27 /** 28 * Enumerate application event types. 29 */ 30 enum EventType { 31 /** 32 * Fault event. 33 */ 34 FAULT = 1, 35 36 /** 37 * Statistic event. 38 */ 39 STATISTIC = 2, 40 41 /** 42 * Security event. 43 */ 44 SECURITY = 3, 45 46 /** 47 * User behavior event. 48 */ 49 BEHAVIOR = 4 50 } 51 52 /** 53 * Preset event. 54 */ 55 namespace Event { 56 /** 57 * user login event. 58 */ 59 const USER_LOGIN: string; 60 61 /** 62 * user logout event. 63 */ 64 const USER_LOGOUT: string; 65 66 /** 67 * distributed service event. 68 */ 69 const DISTRIBUTED_SERVICE_START: string; 70 } 71 72 /** 73 * Preset param. 74 */ 75 namespace Param { 76 /** 77 * user id. 78 */ 79 const USER_ID: string; 80 81 /** 82 * distributed service name. 83 */ 84 const DISTRIBUTED_SERVICE_NAME: string; 85 86 /** 87 * distributed service instance id. 88 */ 89 const DISTRIBUTED_SERVICE_INSTANCE_ID: string; 90 } 91 92 /** 93 * write application event. 94 * 95 * @static 96 * @param {string} eventName application event name. 97 * @param {EventType} eventType application event type. 98 * @param {object} keyValues application event key-value pair params. 99 * @param {AsyncCallback} [callback] callback function. 100 * @return {void | Promise<void>} no callback return Promise otherwise return void. 101 */ 102 function write(eventName: string, eventType: EventType, keyValues: object): Promise<void>; 103 function write(eventName: string, eventType: EventType, keyValues: object, callback: AsyncCallback<void>): void; 104 105 /** 106 * application event logging configuration interface. 107 * 108 * @static 109 * @param {ConfigOption} config application event logging configuration item object. 110 * @return {boolean} configuration result. 111 */ 112 function configure(config: ConfigOption): boolean; 113 114 interface ConfigOption { 115 /** 116 * configuration item: application event logging switch. 117 */ 118 disable?: boolean; 119 120 /** 121 * configuration item: event file directory storage quota size. 122 */ 123 maxStorage?: string; 124 } 125} 126 127export default hiAppEvent;