From fa556d0a7fedf72554d3dc016b82dfe3c3878db3 Mon Sep 17 00:00:00 2001 From: Serhii Nahornyi Date: Mon, 26 Apr 2021 10:55:16 +0300 Subject: [PATCH] Change adapter -> name in analytics reporter --- .../prebid/server/analytics/AnalyticsReporter.java | 4 ++-- .../analytics/AnalyticsReporterDelegator.java | 14 ++++++++------ .../server/analytics/LogAnalyticsReporter.java | 4 ++-- .../analytics/AnalyticsReporterDelegatorTest.java | 4 ++-- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/prebid/server/analytics/AnalyticsReporter.java b/src/main/java/org/prebid/server/analytics/AnalyticsReporter.java index 293c625179f..5e4a2f8aa58 100644 --- a/src/main/java/org/prebid/server/analytics/AnalyticsReporter.java +++ b/src/main/java/org/prebid/server/analytics/AnalyticsReporter.java @@ -19,7 +19,7 @@ public interface AnalyticsReporter { int vendorId(); /** - * Method for defining adapter which is related to analytics reporter. + * Method for defining name of the related to this analytic adapter. */ - String adapter(); + String name(); } diff --git a/src/main/java/org/prebid/server/analytics/AnalyticsReporterDelegator.java b/src/main/java/org/prebid/server/analytics/AnalyticsReporterDelegator.java index 767b5f87684..3a9f928b410 100644 --- a/src/main/java/org/prebid/server/analytics/AnalyticsReporterDelegator.java +++ b/src/main/java/org/prebid/server/analytics/AnalyticsReporterDelegator.java @@ -15,6 +15,8 @@ import org.prebid.server.proto.openrtb.ext.request.ExtRequestPrebid; import org.prebid.server.proto.openrtb.ext.request.ExtRequestPrebidAnalytic; +import java.util.Arrays; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; @@ -27,14 +29,14 @@ public class AnalyticsReporterDelegator { private static final Logger logger = LoggerFactory.getLogger(AnalyticsReporterDelegator.class); - private static final String RELATED_TO_ALL_ADAPTERS = "*"; + private static final Set ADAPTERS_PERMITTED_FOR_FULL_DATA = new HashSet<>(Arrays.asList("logAnalytics")); private final List delegates; private final Vertx vertx; private final PrivacyEnforcementService privacyEnforcementService; private final Set reporterVendorIds; - private final Set reporterAdapters; + private final Set reporterNames; public AnalyticsReporterDelegator(List delegates, Vertx vertx, @@ -44,7 +46,7 @@ public AnalyticsReporterDelegator(List delegates, this.privacyEnforcementService = Objects.requireNonNull(privacyEnforcementService); reporterVendorIds = delegates.stream().map(AnalyticsReporter::vendorId).collect(Collectors.toSet()); - reporterAdapters = delegates.stream().map(AnalyticsReporter::adapter).collect(Collectors.toSet()); + reporterNames = delegates.stream().map(AnalyticsReporter::name).collect(Collectors.toSet()); } public void processEvent(T event) { @@ -66,7 +68,7 @@ private void delegateEvent(T event, privacyEnforcementMapResult.result(); validateEvent(event); for (AnalyticsReporter analyticsReporter : delegates) { - final T preparedEvent = prepareEvent(event, analyticsReporter.adapter()); + final T preparedEvent = prepareEvent(event, analyticsReporter.name()); final int reporterVendorId = analyticsReporter.vendorId(); // resultForVendorIds is guaranteed returning for each provided value except null, // but to be sure lets use getOrDefault @@ -97,7 +99,7 @@ private void validateExtPrebidAnalytics(AuctionEvent auctionEvent) { final List analytics = extPrebid != null ? extPrebid.getAnalytics() : null; final List unknownAnalyticsAdapters = CollectionUtils.emptyIfNull(analytics).stream() .map(ExtRequestPrebidAnalytic::getAdapter) - .filter(s -> !reporterAdapters.contains(s)) + .filter(s -> !reporterNames.contains(s)) .collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(unknownAnalyticsAdapters)) { @@ -107,7 +109,7 @@ private void validateExtPrebidAnalytics(AuctionEvent auctionEvent) { } private T prepareEvent(T event, String delegatorAdapter) { - if (!RELATED_TO_ALL_ADAPTERS.equals(delegatorAdapter) && event instanceof AuctionEvent) { + if (!ADAPTERS_PERMITTED_FOR_FULL_DATA.contains(delegatorAdapter) && event instanceof AuctionEvent) { final AuctionEvent auctionEvent = (AuctionEvent) event; final AuctionContext updatedAuctionContext = updateAuctionContextForDelegator(auctionEvent.getAuctionContext(), delegatorAdapter); diff --git a/src/main/java/org/prebid/server/analytics/LogAnalyticsReporter.java b/src/main/java/org/prebid/server/analytics/LogAnalyticsReporter.java index 2f991bda6ff..d42221fd6f1 100644 --- a/src/main/java/org/prebid/server/analytics/LogAnalyticsReporter.java +++ b/src/main/java/org/prebid/server/analytics/LogAnalyticsReporter.java @@ -57,8 +57,8 @@ public int vendorId() { } @Override - public String adapter() { - return "*"; + public String name() { + return "logAnalytics"; } @AllArgsConstructor diff --git a/src/test/java/org/prebid/server/analytics/AnalyticsReporterDelegatorTest.java b/src/test/java/org/prebid/server/analytics/AnalyticsReporterDelegatorTest.java index d68e010c2cd..255cc3e3229 100644 --- a/src/test/java/org/prebid/server/analytics/AnalyticsReporterDelegatorTest.java +++ b/src/test/java/org/prebid/server/analytics/AnalyticsReporterDelegatorTest.java @@ -60,11 +60,11 @@ public class AnalyticsReporterDelegatorTest { public void setUp() { firstReporter = mock(AnalyticsReporter.class); given(firstReporter.vendorId()).willReturn(FIRST_REPORTER_ID); - given(firstReporter.adapter()).willReturn("*"); + given(firstReporter.name()).willReturn("logAnalytics"); secondReporter = mock(AnalyticsReporter.class); given(secondReporter.vendorId()).willReturn(SECOND_REPORTER_ID); - given(secondReporter.adapter()).willReturn("adapter"); + given(secondReporter.name()).willReturn("adapter"); target = new AnalyticsReporterDelegator(asList(firstReporter, secondReporter), vertx, privacyEnforcementService);