diff --git a/src/main/java/org/prebid/server/analytics/reporter/agma/AgmaAnalyticsReporter.java b/src/main/java/org/prebid/server/analytics/reporter/agma/AgmaAnalyticsReporter.java index b9f0551f808..832d1e67bae 100644 --- a/src/main/java/org/prebid/server/analytics/reporter/agma/AgmaAnalyticsReporter.java +++ b/src/main/java/org/prebid/server/analytics/reporter/agma/AgmaAnalyticsReporter.java @@ -16,6 +16,7 @@ import io.vertx.core.Vertx; import io.vertx.core.http.HttpHeaders; import io.vertx.core.http.HttpMethod; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; import org.prebid.server.analytics.AnalyticsReporter; import org.prebid.server.analytics.model.AmpEvent; @@ -195,17 +196,19 @@ private static String getPublisherId(BidRequest bidRequest) { final String publisherId = Optional.ofNullable(site).map(Site::getPublisher).map(Publisher::getId) .or(() -> Optional.ofNullable(app).map(App::getPublisher).map(Publisher::getId)) - .orElse(""); + .orElse(null); final String appSiteId = Optional.ofNullable(site).map(Site::getId) .or(() -> Optional.ofNullable(app).map(App::getId)) .or(() -> Optional.ofNullable(app).map(App::getBundle)) .orElse(null); - if (publisherId.equals("") && appSiteId == null) { + if (publisherId == null && appSiteId == null) { return null; } - return appSiteId != null ? publisherId + "_" + appSiteId : publisherId; + return appSiteId != null + ? String.format("%s_%s", StringUtils.defaultString(publisherId, ""), appSiteId) + : publisherId; } private void sendEvents(List events) { diff --git a/src/main/java/org/prebid/server/spring/config/AnalyticsConfiguration.java b/src/main/java/org/prebid/server/spring/config/AnalyticsConfiguration.java index 5d4a9fa800a..87c5482ac15 100644 --- a/src/main/java/org/prebid/server/spring/config/AnalyticsConfiguration.java +++ b/src/main/java/org/prebid/server/spring/config/AnalyticsConfiguration.java @@ -5,6 +5,7 @@ import lombok.NoArgsConstructor; import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.BooleanUtils; +import org.apache.commons.lang3.StringUtils; import org.prebid.server.analytics.AnalyticsReporter; import org.prebid.server.analytics.reporter.AnalyticsReporterDelegator; import org.prebid.server.analytics.reporter.agma.AgmaAnalyticsReporter; @@ -114,8 +115,8 @@ public AgmaAnalyticsProperties toComponentProperties() { account -> { final String publisherId = account.getPublisherId(); final String siteAppId = account.getSiteAppId(); - return (siteAppId != null && !siteAppId.isEmpty()) - ? publisherId + "_" + siteAppId + return StringUtils.isNotBlank(siteAppId) + ? String.format("%s_%s", publisherId, siteAppId) : publisherId; }, AgmaAnalyticsAccountProperties::getCode