From 25fafdf88bc1c13049bfcab9f30916d5a7f68b68 Mon Sep 17 00:00:00 2001 From: baozeyu Date: Sat, 14 Sep 2024 14:26:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83=E5=92=8C=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=89=93=E7=82=B9=E9=99=90=E6=B5=81-=E5=95=86=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: baozeyu Change-Id: I81393c42666eb834f625d2cd1b94ed1205545a07 --- .../common/notification_analytics_util.cpp | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/services/ans/src/common/notification_analytics_util.cpp b/services/ans/src/common/notification_analytics_util.cpp index 304641e75..2f97108a6 100644 --- a/services/ans/src/common/notification_analytics_util.cpp +++ b/services/ans/src/common/notification_analytics_util.cpp @@ -31,10 +31,16 @@ constexpr const int32_t DELETE_ERROR_EVENT_CODE = 5; constexpr const int32_t MODIFY_ERROR_EVENT_CODE = 6; constexpr const int32_t DEFAULT_ERROR_EVENT_COUNT = 6; constexpr const int32_t DEFAULT_ERROR_EVENT_TIME = 60; +constexpr const int32_t PUBLISH_ERROR_EVENT_COUNT = 3; +constexpr const int32_t PUBLISH_ERROR_EVENT_TIME = 60; +constexpr const int32_t DELETE_ERROR_EVENT_COUNT = 3; +constexpr const int32_t DELETE_ERROR_EVENT_TIME = 60; const static std::string NOTIFICATION_EVENT_PUSH_AGENT = "notification.event.PUSH_AGENT"; static std::mutex reportFlowControlMutex_; static std::map> flowControlTimestampMap_ = { {MODIFY_ERROR_EVENT_CODE, {}}, + {PUBLISH_ERROR_EVENT_CODE, {}}, + {DELETE_ERROR_EVENT_CODE, {}}, }; HaMetaMessage::HaMetaMessage(uint32_t sceneId, uint32_t branchId) @@ -155,8 +161,14 @@ void NotificationAnalyticsUtil::CommonNotificationEvent(const sptr(request->GetSlotType()), slotType); want.SetParam("id", request->GetNotificationId()); + want.SetParam("uid", request->GetOwnerUid()); want.SetParam("slotType", static_cast(slotType)); want.SetParam("contentType", std::to_string(static_cast(contentType))); want.SetParam("extraInfo", extraContent); if (!request->GetCreatorBundleName().empty()) { - want.SetBundle(request->GetCreatorBundleName()); + want.SetParam("agentBundleName", request->GetCreatorBundleName()); } if (!request->GetOwnerBundleName().empty()) { - want.SetParam("agentBundleName", request->GetOwnerBundleName()); + want.SetBundle(request->GetOwnerBundleName()); } want.SetAction(NOTIFICATION_EVENT_PUSH_AGENT); EventFwk::CommonEventPublishInfo publishInfo; @@ -225,6 +238,10 @@ void NotificationAnalyticsUtil::ReportModifyEvent(const HaMetaMessage& message) void NotificationAnalyticsUtil::ReportDeleteFailedEvent(const HaMetaMessage& message) { + if (!ReportFlowControl(DELETE_ERROR_EVENT_CODE)) { + ANS_LOGI("Publish event failed, reason:%{public}s", message.Build().c_str()); + return; + } std::shared_ptr extraInfo = std::make_shared(); std::string reason = message.Build(); extraInfo->SetParam("reason", AAFwk::String::Box(reason)); @@ -295,6 +312,14 @@ FlowControllerOption NotificationAnalyticsUtil::GetFlowOptionByType(const int32_ option.count = DEFAULT_ERROR_EVENT_COUNT; option.time = DEFAULT_ERROR_EVENT_TIME; break; + case PUBLISH_ERROR_EVENT_CODE: + option.count = PUBLISH_ERROR_EVENT_COUNT; + option.time = PUBLISH_ERROR_EVENT_TIME; + break; + case DELETE_ERROR_EVENT_CODE: + option.count = DELETE_ERROR_EVENT_COUNT; + option.time = DELETE_ERROR_EVENT_TIME; + break; default: option.count = DEFAULT_ERROR_EVENT_COUNT; option.time = DEFAULT_ERROR_EVENT_TIME; -- Gitee