diff --git a/api/@ohos.hiAppEvent.d.ts b/api/@ohos.hiAppEvent.d.ts index 2d694a38b52c27b95ccb2bd50d2edbf8755eeac5..b62cf6f34a704d8c3b7c20fd499b689e8306bfdf 100644 --- a/api/@ohos.hiAppEvent.d.ts +++ b/api/@ohos.hiAppEvent.d.ts @@ -22,6 +22,8 @@ import { AsyncCallback } from './basic'; * * @since 7 * @syscap SystemCapability.HiviewDFX.HiAppEvent + * @deprecated since 9 + * @useinstead ohos.hiviewdfx.hiAppEvent */ declare namespace hiAppEvent { /** @@ -72,7 +74,7 @@ declare namespace hiAppEvent { */ namespace Event { /** - * user login event. + * User login event. * * @since 7 * @syscap SystemCapability.HiviewDFX.HiAppEvent @@ -80,7 +82,7 @@ declare namespace hiAppEvent { const USER_LOGIN: string; /** - * user logout event. + * User logout event. * * @since 7 * @syscap SystemCapability.HiviewDFX.HiAppEvent @@ -88,7 +90,7 @@ declare namespace hiAppEvent { const USER_LOGOUT: string; /** - * distributed service event. + * Distributed service event. * * @since 7 * @syscap SystemCapability.HiviewDFX.HiAppEvent @@ -104,7 +106,7 @@ declare namespace hiAppEvent { */ namespace Param { /** - * user id. + * User id. * * @since 7 * @syscap SystemCapability.HiviewDFX.HiAppEvent @@ -112,7 +114,7 @@ declare namespace hiAppEvent { const USER_ID: string; /** - * distributed service name. + * Distributed service name. * * @since 7 * @syscap SystemCapability.HiviewDFX.HiAppEvent @@ -120,7 +122,7 @@ declare namespace hiAppEvent { const DISTRIBUTED_SERVICE_NAME: string; /** - * distributed service instance id. + * Distributed service instance id. * * @since 7 * @syscap SystemCapability.HiviewDFX.HiAppEvent @@ -129,29 +131,28 @@ declare namespace hiAppEvent { } /** - * write application event. + * Write application event. * * @since 7 - * @deprecated since 9 * @syscap SystemCapability.HiviewDFX.HiAppEvent * @static - * @param {string} eventName application event name. - * @param {EventType} eventType application event type. - * @param {object} keyValues application event key-value pair params. - * @param {AsyncCallback} [callback] callback function. - * @return {void | Promise} no callback return Promise otherwise return void. + * @param {string} eventName Application event name. + * @param {EventType} eventType Application event type. + * @param {object} keyValues Application event key-value pair params. + * @param {AsyncCallback} [callback] Callback function. + * @return {void | Promise} No callback return Promise otherwise return void. */ function write(eventName: string, eventType: EventType, keyValues: object): Promise; function write(eventName: string, eventType: EventType, keyValues: object, callback: AsyncCallback): void; /** - * application event logging configuration interface. + * Application event logging configuration interface. * * @since 7 * @syscap SystemCapability.HiviewDFX.HiAppEvent * @static - * @param {ConfigOption} config application event logging configuration item object. - * @return {boolean} configuration result. + * @param {ConfigOption} config Application event logging configuration item object. + * @return {boolean} Configuration result. */ function configure(config: ConfigOption): boolean; @@ -163,7 +164,7 @@ declare namespace hiAppEvent { */ interface ConfigOption { /** - * configuration item: application event logging switch. + * Configuration item: application event logging switch. * * @since 7 * @syscap SystemCapability.HiviewDFX.HiAppEvent @@ -171,216 +172,13 @@ declare namespace hiAppEvent { disable?: boolean; /** - * configuration item: event file directory storage quota size. + * Configuration item: event file directory storage quota size. * * @since 7 * @syscap SystemCapability.HiviewDFX.HiAppEvent */ maxStorage?: string; } - - /** - * Definition of written application event information. - * - * @since 9 - * @syscap SystemCapability.HiviewDFX.HiAppEvent - */ - interface AppEventInfo { - /** - * The domain of the event. - */ - domain: string; - - /** - * The name of the event. - */ - name: string; - - /** - * The type of the event. - */ - eventType: EventType; - - /** - * The params of the event. - */ - params: object; - } - - /** - * write application event. - * - * @since 9 - * @syscap SystemCapability.HiviewDFX.HiAppEvent - * @static - * @param {AppEventInfo} info application event information to be written. - * @param {AsyncCallback} [callback] callback function. - * @return {void | Promise} no callback return Promise otherwise return void. - */ - function write(info: AppEventInfo): Promise; - function write(info: AppEventInfo, callback: AsyncCallback): void; - - /** - * Definition of the read event package. - * - * @since 9 - * @syscap SystemCapability.HiviewDFX.HiAppEvent - */ - interface AppEventPackage { - /** - * The id of the package. - */ - packageId: number; - - /** - * The number of events contained in the package. - */ - row: number; - - /** - * The total size of events contained in the package. - */ - size: number; - - /** - * The events data contained in the package. - */ - data: string[]; - } - - /** - * Definition of event holder object, which is used to read the event data monitored by the watcher. - * - * @since 9 - * @syscap SystemCapability.HiviewDFX.HiAppEvent - */ - class AppEventPackageHolder { - /** - * Constructor for AppEventPackageHolder. - * - * @since 9 - * @syscap SystemCapability.HiviewDFX.HiAppEvent - * @param {string} watcherName name of the watcher to read. - */ - constructor(watcherName: string); - - /** - * Set the threshold size per read. - * - * @since 9 - * @syscap SystemCapability.HiviewDFX.HiAppEvent - * @param {number} size threshold size. - */ - setSize(size: number): void; - - /** - * Read the event data monitored by the watcher. - * - * @since 9 - * @syscap SystemCapability.HiviewDFX.HiAppEvent - * @return {AppEventPackage} the read event package. - */ - takeNext(): AppEventPackage; - } - - /** - * Definition of the condition for triggering callback when the watcher monitors event data. - * - * @since 9 - * @syscap SystemCapability.HiviewDFX.HiAppEvent - */ - interface TriggerCondition { - /** - * The number of write events that trigger callback. - */ - row?: number; - - /** - * The size of write events that trigger callback. - */ - size?: number; - - /** - * The interval for triggering callback. - */ - timeOut?: number; - } - - /** - * Definition of event filter object, which is used to filter events monitored by the watcher. - * - * @since 9 - * @syscap SystemCapability.HiviewDFX.HiAppEvent - */ - interface AppEventFilter { - /** - * The name of the event domain to be monitored by the watcher. - */ - domain: string; - - /** - * The types of the events to be monitored by the watcher. - */ - eventTypes?: EventType[]; - } - - /** - * Definition of event watcher object, which is used to monitor written event data. - * - * @since 9 - * @syscap SystemCapability.HiviewDFX.HiAppEvent - */ - interface Watcher { - /** - * The name of watcher. - */ - name: string; - - /** - * The condition for triggering callback. - */ - triggerCondition?: TriggerCondition; - - /** - * The event filters for monitoring events. - */ - appEventFilters?: AppEventFilter[]; - - /** - * The callback function of watcher. - */ - onTrigger?: (curRow: number, curSize:number, holder:AppEventPackageHolder) => void; - } - - /** - * Add event watcher. - * - * @since 9 - * @syscap SystemCapability.HiviewDFX.HiAppEvent - * @static - * @param {Watcher} watcher watcher object for monitoring events. - * @return {AppEventPackageHolder} holder object, which is used to read the monitoring data of the watcher. - */ - function addWatcher(watcher: Watcher): AppEventPackageHolder; - - /** - * Remove event watcher. - * - * @since 9 - * @syscap SystemCapability.HiviewDFX.HiAppEvent - * @static - * @param {Watcher} watcher watcher object for monitoring events. - */ - function removeWatcher(watcher: Watcher): void; - - /** - * Clear all local logging data of the application. - * - * @since 9 - * @syscap SystemCapability.HiviewDFX.HiAppEvent - * @static - */ - function clearData(): void; } export default hiAppEvent; \ No newline at end of file diff --git a/api/@ohos.hiviewdfx.hiAppEvent.d.ts b/api/@ohos.hiviewdfx.hiAppEvent.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f76dd174730a95503f988ca232b4c089a129512 --- /dev/null +++ b/api/@ohos.hiviewdfx.hiAppEvent.d.ts @@ -0,0 +1,388 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AsyncCallback } from './basic'; + +/** + * Provides the event logging function for applications to log the fault, statistical, security, + * and user behavior events reported during running. Based on event information, + * you will be able to analyze the running status of applications. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ +declare namespace hiAppEvent { + /** + * Enumerate application event types. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + enum EventType { + /** + * Fault event. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + FAULT = 1, + + /** + * Statistic event. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + STATISTIC = 2, + + /** + * Security event. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + SECURITY = 3, + + /** + * User behavior event. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + BEHAVIOR = 4 + } + + /** + * Preset event. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + namespace Event { + /** + * User login event. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + const USER_LOGIN: string; + + /** + * User logout event. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + const USER_LOGOUT: string; + + /** + * Distributed service event. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + const DISTRIBUTED_SERVICE_START: string; + } + + /** + * Preset param. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + namespace Param { + /** + * User id. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + const USER_ID: string; + + /** + * Distributed service name. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + const DISTRIBUTED_SERVICE_NAME: string; + + /** + * Distributed service instance id. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + const DISTRIBUTED_SERVICE_INSTANCE_ID: string; + } + + /** + * Application event logging configuration interface. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + * @static + * @param {ConfigOption} config Application event logging configuration item object. + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 11103001 - Invalid max storage quota value. + */ + function configure(config: ConfigOption): void; + + /** + * Describe the options for the configuration. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + interface ConfigOption { + /** + * Configuration item: application event logging switch. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + disable?: boolean; + + /** + * Configuration item: event file directory storage quota size. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + maxStorage?: string; + } + + /** + * Definition of written application event information. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + interface AppEventInfo { + /** + * The domain of the event. + */ + domain: string; + + /** + * The name of the event. + */ + name: string; + + /** + * The type of the event. + */ + eventType: EventType; + + /** + * The params of the event. + */ + params: object; + } + + /** + * Write application event. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + * @static + * @param {AppEventInfo} info Application event information to be written. + * @param {AsyncCallback} [callback] Callback function. + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 11100001 - Function is disable. + * @throws {BusinessError} 11101001 - Invalid event domain. + * @throws {BusinessError} 11101002 - Invalid event name. + * @throws {BusinessError} 11101003 - Invalid param num. + * @throws {BusinessError} 11101004 - Invalid string length. + * @throws {BusinessError} 11101005 - Invalid param name. + * @throws {BusinessError} 11101006 - Invalid array length. + */ + function write(info: AppEventInfo): Promise; + function write(info: AppEventInfo, callback: AsyncCallback): void; + + /** + * Definition of the read event package. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + interface AppEventPackage { + /** + * The id of the package. + */ + packageId: number; + + /** + * The number of events contained in the package. + */ + row: number; + + /** + * The total size of events contained in the package. + */ + size: number; + + /** + * The events data contained in the package. + */ + data: string[]; + } + + /** + * Definition of event holder object, which is used to read the event data monitored by the watcher. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + class AppEventPackageHolder { + /** + * Constructor for AppEventPackageHolder. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + * @param {string} watcherName Name of the watcher to read. + */ + constructor(watcherName: string); + + /** + * Set the threshold size per read. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + * @param {number} size Threshold size. + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 11104001 - Size must be a positive integer. + */ + setSize(size: number): void; + + /** + * Read the event data monitored by the watcher. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + * @return {AppEventPackage} The read event package. + */ + takeNext(): AppEventPackage; + } + + /** + * Definition of the condition for triggering callback when the watcher monitors event data. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + interface TriggerCondition { + /** + * The number of write events that trigger callback. + */ + row?: number; + + /** + * The size of write events that trigger callback. + */ + size?: number; + + /** + * The interval for triggering callback. + */ + timeOut?: number; + } + + /** + * Definition of event filter object, which is used to filter events monitored by the watcher. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + interface AppEventFilter { + /** + * The name of the event domain to be monitored by the watcher. + */ + domain: string; + + /** + * The types of the events to be monitored by the watcher. + */ + eventTypes?: EventType[]; + } + + /** + * Definition of event watcher object, which is used to monitor written event data. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + interface Watcher { + /** + * The name of watcher. + */ + name: string; + + /** + * The condition for triggering callback. + */ + triggerCondition?: TriggerCondition; + + /** + * The event filters for monitoring events. + */ + appEventFilters?: AppEventFilter[]; + + /** + * The callback function of watcher. + */ + onTrigger?: (curRow: number, curSize:number, holder:AppEventPackageHolder) => void; + } + + /** + * Add event watcher. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + * @static + * @param {Watcher} watcher Watcher object for monitoring events. + * @return {AppEventPackageHolder} Holder object, which is used to read the monitoring data of the watcher. + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 11102001 - Invalid watcher name. + * @throws {BusinessError} 11102002 - Invalid filter domain. + * @throws {BusinessError} 11102003 - Row must be a positive integer. + * @throws {BusinessError} 11102004 - Size must be a positive integer. + * @throws {BusinessError} 11102005 - Timeout must be a positive integer. + */ + function addWatcher(watcher: Watcher): AppEventPackageHolder; + + /** + * Remove event watcher. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + * @static + * @param {Watcher} watcher Watcher object for monitoring events. + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 11102001 - Invalid watcher name. + */ + function removeWatcher(watcher: Watcher): void; + + /** + * Clear all local logging data of the application. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + * @static + */ + function clearData(): void; +} + +export default hiAppEvent; \ No newline at end of file