ResetOAID添加打点事件

Signed-off-by: lipan <lipan111@huawei.com>
This commit is contained in:
lipan 2024-06-11 15:42:38 +08:00
parent 62d962051f
commit 0343e96f3e
3 changed files with 30 additions and 11 deletions

View File

@ -35,7 +35,7 @@
"napi",
"safwk",
"samgr",
"hianalytics_service"
"hiappevent"
],
"third_party": [
"libuv",

View File

@ -46,7 +46,7 @@ ohos_shared_library("oaid_client") {
"ipc:ipc_single",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
"hianalytics_service:ha_client",
"hiappevent:hiappevent_innerapi",
]
version_script = "liboaidclient.versionscript"
subsystem_name = "advertising"

View File

@ -18,18 +18,21 @@
#include "oaid_common.h"
#include "oaid_service_interface.h"
#include "oaid_service_ipc_interface_code.h"
#include "ha_inner_api.h"
#include "app_event_processor_mgr.h"
#include "app_event.h"
namespace OHOS {
namespace Cloud {
using namespace OHOS::HiviewDFX;
OAIDServiceProxy::OAIDServiceProxy(const sptr<IRemoteObject>& object) : IRemoteProxy<IOAIDService>(object) {}
OAIDServiceProxy::OAIDServiceProxy(const sptr<IRemoteObject> &object) : IRemoteProxy<IOAIDService>(object)
{}
std::string OAIDServiceProxy::GetOAID()
{
OAID_HILOGI(OAID_MODULE_CLIENT, "GetOAID Begin.");
MessageParcel data, reply;
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
@ -50,7 +53,8 @@ std::string OAIDServiceProxy::GetOAID()
int32_t OAIDServiceProxy::ResetOAID()
{
OAID_HILOGI(OAID_MODULE_CLIENT, "Reset OAID Begin.");
MessageParcel data, reply;
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
@ -62,13 +66,28 @@ int32_t OAIDServiceProxy::ResetOAID()
OAID_HILOGE(OAID_MODULE_CLIENT, "Reset OAID failed, error code is: %{public}d", result);
}
OAID_HILOGI(OAID_MODULE_CLIENT, "Reset OAID End.");
if (result == ERR_OK) {
auto oaid = GetOAID();
std::string eventId = "ADS_ID_REFRESH";
std::unordered_map<std::string, std::string> someKv({{"type", "oaid"}, {"id", oaid.c_str()}});
int32_t onEventRet =
HaCloud::HaInnerApi::OnEvent("$CommonEvent", HaCloud::EventType::operation, eventId, someKv);
OAID_HILOGI(OAID_MODULE_CLIENT, "Reset OAID onEventRet: %{public}d", onEventRet);
HiviewDFX::HiAppEvent::ReportConfig config;
config.name = "ha_app_event";
config.routeInfo = "AUTO";
config.eventConfigs.clear();
HiviewDFX::HiAppEvent::EventConfig eventConfig;
eventConfig.domain = "CommonEvent";
eventConfig.name = "ADS_ID_REFRESH";
eventConfig.isRealTime = true;
config.eventConfigs.push_back(eventConfig);
HiviewDFX::HiAppEvent::AppEventProcessorMgr::AddProcessor(config);
// 写事件
HiviewDFX::HiAppEvent::Event event("CommonEvent", "ADS_ID_REFRESH", HiviewDFX::HiAppEvent::BEHAVIOR);
std::string oaidKey = "oaid";
event.AddParam("type", oaidKey);
event.AddParam("id", oaid);
HiviewDFX::HiAppEvent::Write(event);
OAID_HILOGI(OAID_MODULE_CLIENT, "Reset OAID WriteEvent success!");
}
int32_t errorCode = reply.ReadInt32();
OAID_HILOGI(OAID_MODULE_CLIENT, "Reset OAID End.errorCode = %{public}d", errorCode);