1 /*
2  * Copyright (c) 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 #ifndef KV_RADAR_REPORTER_H
17 #define KV_RADAR_REPORTER_H
18 
19 #include "hisysevent.h"
20 
21 namespace OHOS::DistributedKv {
22 enum BizScene {
23     ONLINE_DEVICE_SYNC = 1,
24     BROADCAST_DEVICE_SYNC = 2,
25     STANDARD_DEVICE_SYNC = 3,
26 };
27 
28 enum StandardStage {
29     ADD_SYNC_TASK = 1,
30     CHECK_DEVICE_ONLINE = 2,
31     STANDARD_META_SYNC = 3,
32     OPEN_STORE = 4,
33     START_SYNC = 5,
34     FINISH_SYNC = 6,
35 };
36 
37 enum BroadcastStage {
38     SEND_BROADCAST = 1,
39 };
40 
41 enum OnlineStage {
42     ONLINE_META_SYNC = 1,
43     ONLINE_META_COMPLETE = 2,
44 };
45 
46 enum StageRes {
47     RADAR_START = 0,
48     RADAR_SUCCESS = 1,
49     RADAR_FAILED = 2,
50     RADAR_CANCEL = 3,
51 };
52 
53 enum BizState {
54     START = 1,
55     END = 2,
56 };
57 
58 enum SyncType {
59     SYNC = 1,
60     AUTOSYNC,
61     REUSE_SOCKET_AUTO_SYNC
62 };
63 
64 constexpr char DOMAIN[] = "DISTDATAMGR";
65 constexpr const char* EVENT_NAME = "DISTRIBUTED_KV_STORE_BEHAVIOR";
66 constexpr HiviewDFX::HiSysEvent::EventType TYPE = HiviewDFX::HiSysEvent::EventType::BEHAVIOR;
67 constexpr const char* ORG_PKG = "distributeddata";
68 constexpr const char* ERROR_CODE = "ERROR_CODE";
69 constexpr const char* BIZ_STATE = "BIZ_STATE";
70 constexpr const char* CONCURRENT_ID = "CONCURRENT_ID";
71 constexpr const char* SYNC_STORE_ID = "SYNC_STORE_ID";
72 constexpr const char* SYNC_APP_ID = "SYNC_APP_ID";
73 constexpr const char* OS_TYPE = "OS_TYPE";
74 constexpr const char* SYNC_TYPE = "SYNC_TYPE";
75 constexpr const char* DATA_TYPE = "DATA_TYPE";
76 constexpr const char* WATER_VERSION = "WATER_VERSION";
77 constexpr const char* SCREEN_STATUS = "SCREEN_STATUS";
78 
79 #define RADAR_REPORT(bizScene, bizStage, stageRes, ...)                                            \
80 ({                                                                                                 \
81     HiSysEventWrite(DistributedKv::DOMAIN, DistributedKv::EVENT_NAME, DistributedKv::TYPE,         \
82         "ORG_PKG", DistributedKv::ORG_PKG, "FUNC", __FUNCTION__,                                   \
83         "BIZ_SCENE", bizScene, "BIZ_STAGE", bizStage, "STAGE_RES", stageRes, ##__VA_ARGS__);       \
84 })
85 } // namespace OHOS::DistributedKv
86 #endif // KV_RADAR_REPORTER_H