From d3302a2db14e997760106fd78b47170617d75828 Mon Sep 17 00:00:00 2001 From: freddyDOTCMS Date: Thu, 9 Jan 2025 09:23:12 -0600 Subject: [PATCH] #31022 Setting host Id in Url Map events --- .../dotcms/analytics/track/collectors/PageDetailCollector.java | 1 + .../analytics/track/collectors/PageDetailCollectorTest.java | 1 + .../test/java/com/dotcms/analytics/track/collectors/Util.java | 3 +++ 3 files changed, 5 insertions(+) diff --git a/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/PageDetailCollector.java b/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/PageDetailCollector.java index f2da25166452..fe2cda67faf6 100644 --- a/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/PageDetailCollector.java +++ b/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/PageDetailCollector.java @@ -95,6 +95,7 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa if (Objects.nonNull(site)) { collectorPayloadBean.put(SITE_NAME, site.getHostname()); + collectorPayloadBean.put(SITE_ID, site.getIdentifier()); } return collectorPayloadBean; } diff --git a/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/PageDetailCollectorTest.java b/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/PageDetailCollectorTest.java index e532d5855c27..513923cd8c14 100644 --- a/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/PageDetailCollectorTest.java +++ b/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/PageDetailCollectorTest.java @@ -103,6 +103,7 @@ public void testPageDetailCollector() throws DotDataException, UnknownHostExcept final Map expectedDataMap = Map.of( Collector.EVENT_TYPE, EventType.PAGE_REQUEST.getType(), Collector.SITE_NAME, testSite.getHostname(), + Collector.SITE_ID, testSite.getIdentifier(), Collector.LANGUAGE, language.getIsoCode(), Collector.URL, TEST_URL_MAP_DETAIL_PAGE_URL, Collector.OBJECT, Map.of( diff --git a/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/Util.java b/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/Util.java index ace3b4430674..dbf0d0102c28 100644 --- a/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/Util.java +++ b/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/Util.java @@ -37,6 +37,7 @@ import com.dotmarketing.util.UtilMethods; import com.dotmarketing.util.WebKeys; import com.liferay.portal.model.User; +import graphql.AssertException; import io.vavr.control.Try; import javax.servlet.http.HttpServletRequest; @@ -325,6 +326,8 @@ public static void validateExpectedEntries(final Map expectedDat assertEquals("Collected value must be equal to expected value for key: " + key, expectedValue, collectedValue); } + } else { + throw new AssertException("Expected key in the Collected value: " + key); } } }