diff --git a/services/ans/src/common/notification_analytics_util.cpp b/services/ans/src/common/notification_analytics_util.cpp index 304641e75730a209f41e0afb1c0c68db02550339..2f97108a616661512a1490e6dfa9e987a6e77140 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;