@Test public void extractAnalyticsEventNames_addsEventsWhenMultipleCampaignsHasMultipleTriggers() { String event2 = "event2"; String event3 = "event3"; String event4 = "event4"; TriggeringCondition.Builder onAnalyticsEvent2 = TriggeringCondition.newBuilder().setEvent(Event.newBuilder().setName(event2)); TriggeringCondition.Builder onAnalyticsEvent3 = TriggeringCondition.newBuilder().setEvent(Event.newBuilder().setName(event3)); TriggeringCondition.Builder onAnalyticsEvent4 = TriggeringCondition.newBuilder().setEvent(Event.newBuilder().setName(event4)); ThickContent.Builder event1ContentBuilder = ThickContent.newBuilder() .setPriority(PRIORITY_TWO) .addTriggeringConditions(onAnalyticsEvent) .addTriggeringConditions(onAnalyticsEvent2) .addTriggeringConditions(onAnalyticsEvent3) .setVanillaPayload(vanillaCampaign1) .setContent(Content.getDefaultInstance()); ThickContent.Builder event2ContentBuilder = ThickContent.newBuilder() .setPriority(PRIORITY_TWO) .addTriggeringConditions(onAnalyticsEvent3) .addTriggeringConditions(onAnalyticsEvent4) .setVanillaPayload(vanillaCampaign2) .setContent(Content.getDefaultInstance()); FetchEligibleCampaignsResponse campaignsResponse = FetchEligibleCampaignsResponse.newBuilder() .setExpirationEpochTimestampMillis(FUTURE) .addMessages(event1ContentBuilder) .addMessages(event2ContentBuilder) .build(); Set<String> eventNames = AnalyticsEventsManager.extractAnalyticsEventNames(campaignsResponse); assertThat(eventNames).containsExactly(ANALYTICS_EVENT_1, event2, event3, event4); }
@VisibleForTesting static Set<String> extractAnalyticsEventNames(FetchEligibleCampaignsResponse response) { Set<String> analyticsEvents = new HashSet<>(); for (CampaignProto.ThickContent content : response.getMessagesList()) { for (CommonTypesProto.TriggeringCondition condition : content.getTriggeringConditionsList()) { if (!TextUtils.isEmpty(condition.getEvent().getName())) { analyticsEvents.add(condition.getEvent().getName()); } } } if (analyticsEvents.size() > AnalyticsConstants.MAX_REGISTERED_EVENTS) { Logging.logi(TOO_MANY_CONTEXTUAL_TRIGGERS_ERROR); } return analyticsEvents; }
AnalyticsEventsManager { @VisibleForTesting static Set<String> extractAnalyticsEventNames(FetchEligibleCampaignsResponse response) { Set<String> analyticsEvents = new HashSet<>(); for (CampaignProto.ThickContent content : response.getMessagesList()) { for (CommonTypesProto.TriggeringCondition condition : content.getTriggeringConditionsList()) { if (!TextUtils.isEmpty(condition.getEvent().getName())) { analyticsEvents.add(condition.getEvent().getName()); } } } if (analyticsEvents.size() > AnalyticsConstants.MAX_REGISTERED_EVENTS) { Logging.logi(TOO_MANY_CONTEXTUAL_TRIGGERS_ERROR); } return analyticsEvents; } }
AnalyticsEventsManager { @VisibleForTesting static Set<String> extractAnalyticsEventNames(FetchEligibleCampaignsResponse response) { Set<String> analyticsEvents = new HashSet<>(); for (CampaignProto.ThickContent content : response.getMessagesList()) { for (CommonTypesProto.TriggeringCondition condition : content.getTriggeringConditionsList()) { if (!TextUtils.isEmpty(condition.getEvent().getName())) { analyticsEvents.add(condition.getEvent().getName()); } } } if (analyticsEvents.size() > AnalyticsConstants.MAX_REGISTERED_EVENTS) { Logging.logi(TOO_MANY_CONTEXTUAL_TRIGGERS_ERROR); } return analyticsEvents; } AnalyticsEventsManager(AnalyticsConnector analyticsConnector); }
AnalyticsEventsManager { @VisibleForTesting static Set<String> extractAnalyticsEventNames(FetchEligibleCampaignsResponse response) { Set<String> analyticsEvents = new HashSet<>(); for (CampaignProto.ThickContent content : response.getMessagesList()) { for (CommonTypesProto.TriggeringCondition condition : content.getTriggeringConditionsList()) { if (!TextUtils.isEmpty(condition.getEvent().getName())) { analyticsEvents.add(condition.getEvent().getName()); } } } if (analyticsEvents.size() > AnalyticsConstants.MAX_REGISTERED_EVENTS) { Logging.logi(TOO_MANY_CONTEXTUAL_TRIGGERS_ERROR); } return analyticsEvents; } AnalyticsEventsManager(AnalyticsConnector analyticsConnector); @Nullable AnalyticsConnectorHandle getHandle(); ConnectableFlowable<String> getAnalyticsEventsFlowable(); void updateContextualTriggers(FetchEligibleCampaignsResponse serviceResponse); }
AnalyticsEventsManager { @VisibleForTesting static Set<String> extractAnalyticsEventNames(FetchEligibleCampaignsResponse response) { Set<String> analyticsEvents = new HashSet<>(); for (CampaignProto.ThickContent content : response.getMessagesList()) { for (CommonTypesProto.TriggeringCondition condition : content.getTriggeringConditionsList()) { if (!TextUtils.isEmpty(condition.getEvent().getName())) { analyticsEvents.add(condition.getEvent().getName()); } } } if (analyticsEvents.size() > AnalyticsConstants.MAX_REGISTERED_EVENTS) { Logging.logi(TOO_MANY_CONTEXTUAL_TRIGGERS_ERROR); } return analyticsEvents; } AnalyticsEventsManager(AnalyticsConnector analyticsConnector); @Nullable AnalyticsConnectorHandle getHandle(); ConnectableFlowable<String> getAnalyticsEventsFlowable(); void updateContextualTriggers(FetchEligibleCampaignsResponse serviceResponse);  }