diff --git a/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/AsyncVanitiesCollector.java b/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/AsyncVanitiesCollector.java index 0b35afaa977d..822b95d4da6d 100644 --- a/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/AsyncVanitiesCollector.java +++ b/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/AsyncVanitiesCollector.java @@ -63,7 +63,7 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa if (UtilMethods.isSet(whoIAM)) { final CollectorContextMap innerCollectorContextMap = new WrapperCollectorContextMap(collectorContextMap, - Map.of("uri", cachedVanityUrl.forwardTo)); + Map.of(CollectorContextMap.URI, cachedVanityUrl.forwardTo)); match.get(whoIAM).collect(innerCollectorContextMap, collectorPayloadBean); } diff --git a/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/BasicProfileCollector.java b/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/BasicProfileCollector.java index 84723f0c5bb8..8d5d5c4e53a4 100644 --- a/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/BasicProfileCollector.java +++ b/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/BasicProfileCollector.java @@ -6,6 +6,7 @@ import com.dotmarketing.business.web.WebAPILocator; import com.dotmarketing.util.PageMode; import com.dotmarketing.util.UtilMethods; +import com.liferay.portal.model.User; import com.liferay.util.StringPool; import javax.servlet.http.HttpServletRequest; @@ -13,6 +14,8 @@ import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; +import java.util.HashMap; +import java.util.Map; import java.util.Objects; /** @@ -66,8 +69,6 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa collectorPayloadBean.put(PERSONA, WebAPILocator.getPersonalizationWebAPI().getContainerPersonalization(request)); - collectorPayloadBean.put(RENDER_MODE, PageMode.get(request).toString().replace("_MODE", StringPool.BLANK)); - // Include default value for other boolean fields in the Clickhouse table collectorPayloadBean.put(COME_FROM_VANITY_URL, false); collectorPayloadBean.put(IS_EXPERIMENT_PAGE, false); @@ -78,9 +79,23 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa collectorPayloadBean.put(EVENT_SOURCE, EventSource.DOT_CMS.getName()); } + setUserInfo(request, collectorPayloadBean); + return collectorPayloadBean; } + private void setUserInfo(final HttpServletRequest request, final CollectorPayloadBean collectorPayloadBean) { + + final User user = WebAPILocator.getUserWebAPI().getUser(request); + if (Objects.nonNull(user)) { + + final HashMap userObject = new HashMap<>(); + userObject.put(ID, user.getUserId().toString()); + userObject.put(EMAIL, user.getEmailAddress()); + collectorPayloadBean.put(USER_OBJECT, userObject); + } + } + @Override public boolean isEventCreator(){ return false; diff --git a/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/Collector.java b/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/Collector.java index 879d8752f5df..f6437c0dee41 100644 --- a/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/Collector.java +++ b/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/Collector.java @@ -18,37 +18,51 @@ */ public interface Collector { - String CLUSTER = "cluster"; - String COME_FROM_VANITY_URL = "comeFromVanityURL"; - String CONTENT_TYPE_ID = "content_type_id"; - String CONTENT_TYPE_NAME = "content_type_name"; - String CONTENT_TYPE_VAR_NAME = "content_type_var_name"; - String DETAIL_PAGE_URL = "detail_page_url"; + String ID = "identifier"; + String TITLE = "title"; + String INODE = "inode"; // NOT USED YET BUT MAY BE DESIRED + String BASE_TYPE = "baseType"; + String PATH = "path"; // NOT USED YET BUT MAY BE DESIRED + String LIVE = "live"; // NOT USED YET BUT MAY BE DESIRED + String WORKING = "working"; // NOT USED YET BUT MAY BE DESIRED + String CONTENT_TYPE_VAR_NAME = "contentType"; + String CONTENT_TYPE_NAME = "contentTypeName"; + String CONTENT_TYPE_ID = "contentTypeId"; + String SITE_ID = "conHost"; + String SITE_NAME = "conHostName"; + String LANGUAGE_ID = "languageId"; + String LANGUAGE = "language"; + String EVENT_SOURCE = "event_source"; String EVENT_TYPE = "event_type"; - String HOST = "host"; - String ID = "id"; - String IS_EXPERIMENT_PAGE = "isexperimentpage"; - String IS_TARGET_PAGE = "istargetpage"; - String LANGUAGE = "language"; - String LANGUAGE_ID = "language_id"; + String CLUSTER = "cluster"; String OBJECT = "object"; String PERSONA = "persona"; String REFERER = "referer"; - String RENDER_MODE = "renderMode"; String REQUEST_ID = "request_id"; - String RESPONSE = "response"; - String RESPONSE_CODE = "response_code"; String SERVER = "server"; String SESSION_ID = "sessionId"; String SESSION_NEW = "sessionNew"; - String SITE = "site"; - String TITLE = "title"; String URL = "url"; String USER_AGENT = "userAgent"; String UTC_TIME = "utc_time"; + + + String RENDER_MODE = "renderMode"; + String RESPONSE = "response"; + String RESPONSE_CODE = "response_code"; + + + String COME_FROM_VANITY_URL = "comeFromVanityURL"; + String DETAIL_PAGE_URL = "detail_page_url"; + String IS_EXPERIMENT_PAGE = "isexperimentpage"; + String IS_TARGET_PAGE = "istargetpage"; String VANITY_QUERY_STRING = "vanity_query_string"; + String VANITY_URL_KEY = "vanity_url"; + String FORWARD_TO = "forwardTo"; + String EMAIL = "email"; + String USER_OBJECT = "user"; /** * Test if the collector should run * @param collectorContextMap diff --git a/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/CollectorContextMap.java b/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/CollectorContextMap.java index 57a932d0d927..6e0497e483e2 100644 --- a/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/CollectorContextMap.java +++ b/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/CollectorContextMap.java @@ -5,6 +5,7 @@ public interface CollectorContextMap { String REQUEST_ID = "requestId"; + String REQUEST = "request"; String TIME = "time"; String CLUSTER = "cluster"; String SERVER = "server"; diff --git a/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/CustomerEventCollector.java b/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/CustomerEventCollector.java index c4f503c9db3f..64628e4d464f 100644 --- a/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/CustomerEventCollector.java +++ b/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/CustomerEventCollector.java @@ -27,9 +27,9 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa final Host site = (Host) collectorContextMap.get(CollectorContextMap.CURRENT_HOST); final String language = (String)collectorContextMap.get(CollectorContextMap.LANG); collectorPayloadBean.put(URL, uri); - collectorPayloadBean.put(HOST, Objects.nonNull(site)?site.getHostname():host); + collectorPayloadBean.put(SITE_NAME, Objects.nonNull(site)?site.getHostname():host); collectorPayloadBean.put(LANGUAGE, language); - collectorPayloadBean.put(SITE, null != site?site.getIdentifier():StringPool.UNKNOWN); + collectorPayloadBean.put(SITE_ID, null != site?site.getIdentifier():StringPool.UNKNOWN); final String eventType = collectorContextMap.get(CollectorContextMap.EVENT_TYPE) == null? EventType.CUSTOM_USER_EVENT.getType():(String)collectorContextMap.get(CollectorContextMap.EVENT_TYPE); collectorPayloadBean.put(EVENT_TYPE, eventType); diff --git a/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/FilesCollector.java b/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/FilesCollector.java index 5dd95ee8257d..571be4f7d7ef 100644 --- a/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/FilesCollector.java +++ b/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/FilesCollector.java @@ -9,6 +9,7 @@ import com.dotmarketing.portlets.contentlet.model.Contentlet; import com.dotmarketing.portlets.fileassets.business.FileAssetAPI; import com.liferay.util.StringPool; +import io.vavr.control.Try; import java.util.HashMap; import java.util.Objects; @@ -57,14 +58,20 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa fileObject.put(ID, fileAsset.getIdentifier()); fileObject.put(TITLE, fileAsset.getTitle()); fileObject.put(URL, uri); + fileObject.put(CONTENT_TYPE_ID, fileAsset.getContentType().id()); + fileObject.put(CONTENT_TYPE_NAME, fileAsset.getContentType().name()); + fileObject.put(CONTENT_TYPE_VAR_NAME, fileAsset.getContentType().variable()); + fileObject.put(BASE_TYPE, fileAsset.getContentType().baseType().name()); + fileObject.put(LIVE, String.valueOf(Try.of(()->fileAsset.isLive()).getOrElse(false))); + fileObject.put(WORKING, String.valueOf(Try.of(()->fileAsset.isWorking()).getOrElse(false))); }); } collectorPayloadBean.put(OBJECT, fileObject); collectorPayloadBean.put(URL, uri); - collectorPayloadBean.put(HOST, Objects.nonNull(site)?site.getHostname():host); + collectorPayloadBean.put(SITE_NAME, Objects.nonNull(site)?site.getHostname():host); collectorPayloadBean.put(LANGUAGE, language); - collectorPayloadBean.put(SITE, null != site?site.getIdentifier():StringPool.UNKNOWN); + collectorPayloadBean.put(SITE_ID, null != site?site.getIdentifier():StringPool.UNKNOWN); collectorPayloadBean.put(EVENT_TYPE, EventType.FILE_REQUEST.getType()); return collectorPayloadBean; 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 2469f671d337..370aa5182821 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 @@ -78,6 +78,12 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa pageObject.put(ID, detailPageContent.getIdentifier()); pageObject.put(TITLE, detailPageContent.getTitle()); pageObject.put(URL, uri); + pageObject.put(CONTENT_TYPE_ID, urlMapContentlet.getContentType().id()); + pageObject.put(CONTENT_TYPE_NAME, urlMapContentlet.getContentType().name()); + pageObject.put(CONTENT_TYPE_VAR_NAME, urlMapContentlet.getContentType().variable()); + pageObject.put(BASE_TYPE, urlMapContentlet.getContentType().baseType().name()); + pageObject.put(LIVE, String.valueOf(Try.of(()->urlMapContentlet.isLive()).getOrElse(false))); + pageObject.put(WORKING, String.valueOf(Try.of(()->urlMapContentlet.isWorking()).getOrElse(false))); pageObject.put(DETAIL_PAGE_URL, Try.of(detailPageContent::getURI).getOrElse(StringPool.BLANK)); collectorPayloadBean.put(OBJECT, pageObject); } @@ -87,7 +93,7 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa collectorPayloadBean.put(LANGUAGE, language); if (Objects.nonNull(site)) { - collectorPayloadBean.put(HOST, site.getHostname()); + collectorPayloadBean.put(SITE_NAME, site.getHostname()); } return collectorPayloadBean; } diff --git a/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/PagesCollector.java b/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/PagesCollector.java index fc44962c605b..1266da3e3805 100644 --- a/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/PagesCollector.java +++ b/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/PagesCollector.java @@ -75,6 +75,9 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa pageObject.put(CONTENT_TYPE_ID, urlMapContentType.id()); pageObject.put(CONTENT_TYPE_NAME, urlMapContentType.name()); pageObject.put(CONTENT_TYPE_VAR_NAME, urlMapContentType.variable()); + pageObject.put(BASE_TYPE, urlMapContentType.baseType().name()); + pageObject.put(LIVE, String.valueOf(Try.of(()->urlMapContentlet.isLive()).getOrElse(false))); + pageObject.put(WORKING, String.valueOf(Try.of(()->urlMapContentlet.isWorking()).getOrElse(false))); collectorPayloadBean.put(EVENT_TYPE, EventType.URL_MAP.getType()); } } else { @@ -82,6 +85,13 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa this.pageAPI.getPageByPath(uri, site, languageId, true)).get(); pageObject.put(ID, page.getIdentifier()); pageObject.put(TITLE, page.getTitle()); + final Contentlet pageContentlet = (Contentlet) page; + pageObject.put(CONTENT_TYPE_ID, pageContentlet.getContentType().id()); + pageObject.put(CONTENT_TYPE_NAME, pageContentlet.getContentType().name()); + pageObject.put(CONTENT_TYPE_VAR_NAME, pageContentlet.getContentType().variable()); + pageObject.put(BASE_TYPE, pageContentlet.getContentType().baseType().name()); + pageObject.put(LIVE, String.valueOf(Try.of(()->page.isLive()).getOrElse(false))); + pageObject.put(WORKING, String.valueOf(Try.of(()->page.isWorking()).getOrElse(false))); collectorPayloadBean.put(EVENT_TYPE, EventType.PAGE_REQUEST.getType()); } pageObject.put(URL, uri); @@ -92,7 +102,7 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa collectorPayloadBean.put(LANGUAGE, language); if (Objects.nonNull(site)) { - collectorPayloadBean.put(HOST, site.getHostname()); + collectorPayloadBean.put(SITE_NAME, site.getHostname()); } return collectorPayloadBean; diff --git a/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/SyncVanitiesCollector.java b/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/SyncVanitiesCollector.java index 4f3e3dd1471a..42632afd3305 100644 --- a/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/SyncVanitiesCollector.java +++ b/dotCMS/src/main/java/com/dotcms/analytics/track/collectors/SyncVanitiesCollector.java @@ -17,8 +17,6 @@ */ public class SyncVanitiesCollector implements Collector { - public static final String VANITY_URL_KEY = "vanity_url"; - public static final String FORWARD_TO = "forward_to"; public SyncVanitiesCollector() { } @@ -32,9 +30,9 @@ public boolean test(CollectorContextMap collectorContextMap) { @Override public CollectorPayloadBean collect(final CollectorContextMap collectorContextMap, final CollectorPayloadBean collectorPayloadBean) { - if (null != collectorContextMap.get("request")) { + if (null != collectorContextMap.get(CollectorContextMap.REQUEST)) { - final HttpServletRequest request = (HttpServletRequest)collectorContextMap.get("request"); + final HttpServletRequest request = (HttpServletRequest)collectorContextMap.get(CollectorContextMap.REQUEST); final String vanityUrl = (String)request.getAttribute(Constants.CMS_FILTER_URI_OVERRIDE); final String vanityQueryString = (String)request.getAttribute(Constants.CMS_FILTER_QUERY_STRING_OVERRIDE); if (request instanceof VanityUrlRequestWrapper) { @@ -66,7 +64,7 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa collectorPayloadBean.put(URL, uri); collectorPayloadBean.put(LANGUAGE, language); collectorPayloadBean.put(LANGUAGE_ID, languageId); - collectorPayloadBean.put(SITE, site.getIdentifier()); + collectorPayloadBean.put(SITE_ID, site.getIdentifier()); collectorPayloadBean.put(EVENT_TYPE, EventType.VANITY_REQUEST.getType()); return collectorPayloadBean; diff --git a/dotCMS/src/test/java/com/dotcms/analytics/track/collectors/CustomerEventCollectorTest.java b/dotCMS/src/test/java/com/dotcms/analytics/track/collectors/CustomerEventCollectorTest.java index c75f71350086..89a210d38ba4 100644 --- a/dotCMS/src/test/java/com/dotcms/analytics/track/collectors/CustomerEventCollectorTest.java +++ b/dotCMS/src/test/java/com/dotcms/analytics/track/collectors/CustomerEventCollectorTest.java @@ -53,10 +53,10 @@ public RequestMatcher getRequestMatcher() { final CollectorPayloadBean collectorPayloadBean = new ConcurrentCollectorPayloadBean(); customerEventCollector.collect(collectorContextMap, collectorPayloadBean); - Assert.assertEquals("/test-path", collectorPayloadBean.get("url")); - Assert.assertEquals("www.dotcms.com", collectorPayloadBean.get("host")); - Assert.assertEquals("en", collectorPayloadBean.get("language")); - Assert.assertEquals("1", collectorPayloadBean.get("site")); - Assert.assertEquals(EventType.CUSTOM_USER_EVENT.getType(), collectorPayloadBean.get("event_type")); + Assert.assertEquals("/test-path", collectorPayloadBean.get(Collector.URL)); + Assert.assertEquals("www.dotcms.com", collectorPayloadBean.get(Collector.SITE_NAME)); + Assert.assertEquals("en", collectorPayloadBean.get(Collector.LANGUAGE)); + Assert.assertEquals("1", collectorPayloadBean.get(Collector.SITE_ID)); + Assert.assertEquals(EventType.CUSTOM_USER_EVENT.getType(), collectorPayloadBean.get(Collector.EVENT_TYPE)); } } diff --git a/dotCMS/src/test/java/com/dotcms/analytics/track/collectors/FilesCollectorTest.java b/dotCMS/src/test/java/com/dotcms/analytics/track/collectors/FilesCollectorTest.java index fa60f7b429f1..3769843b952c 100644 --- a/dotCMS/src/test/java/com/dotcms/analytics/track/collectors/FilesCollectorTest.java +++ b/dotCMS/src/test/java/com/dotcms/analytics/track/collectors/FilesCollectorTest.java @@ -2,6 +2,8 @@ import com.dotcms.UnitTestBase; import com.dotcms.analytics.track.matchers.RequestMatcher; +import com.dotcms.contenttype.model.type.BaseContentType; +import com.dotcms.contenttype.model.type.ContentType; import com.dotmarketing.beans.Host; import com.dotmarketing.portlets.contentlet.model.Contentlet; import org.junit.Assert; @@ -30,9 +32,24 @@ public void test_collect_easy_path() throws IOException { final FilesCollector filesCollector = new FilesCollector() { @Override protected Optional getFileAsset(String uri, Host host, Long languageId) { + final Contentlet contentlet = Mockito.mock(Contentlet.class); Mockito.when(contentlet.getIdentifier()).thenReturn("1"); Mockito.when(contentlet.getTitle()).thenReturn("Test"); + try { + Mockito.when(contentlet.isLive()).thenReturn(true); + Mockito.when(contentlet.isWorking()).thenReturn(true); + } catch (Exception e) { + + } + final ContentType contentType = Mockito.mock(ContentType.class); + Mockito.when(contentlet.getContentType()).thenReturn(contentType); + Mockito.when(contentType.id()).thenReturn("1"); + Mockito.when(contentType.name()).thenReturn("file"); + Mockito.when(contentType.variable()).thenReturn("file"); + final BaseContentType baseType = Mockito.mock(BaseContentType.class); + Mockito.when(contentType.baseType()).thenReturn(baseType); + Mockito.when(baseType.name()).thenReturn("file"); return Optional.ofNullable(contentlet); } }; @@ -70,13 +87,12 @@ public RequestMatcher getRequestMatcher() { final Map fileObject = (Map) collectorPayloadBean.get("object"); Assert.assertNotNull(fileObject); - Assert.assertEquals("1", fileObject.get("id")); - Assert.assertEquals("Test", fileObject.get("title")); - Assert.assertEquals("/test-path", fileObject.get("url")); - Assert.assertEquals("/test-path", collectorPayloadBean.get("url")); - Assert.assertEquals("www.dotcms.com", collectorPayloadBean.get("host")); - Assert.assertEquals("en", collectorPayloadBean.get("language")); - Assert.assertEquals("1", collectorPayloadBean.get("site")); - Assert.assertEquals(EventType.FILE_REQUEST.getType(), collectorPayloadBean.get("event_type")); + Assert.assertEquals("1", fileObject.get(Collector.ID)); + Assert.assertEquals("Test", fileObject.get(Collector.TITLE)); + Assert.assertEquals("/test-path", fileObject.get(Collector.URL)); + Assert.assertEquals("www.dotcms.com", collectorPayloadBean.get(Collector.SITE_NAME)); + Assert.assertEquals("en", collectorPayloadBean.get(Collector.LANGUAGE)); + Assert.assertEquals("1", collectorPayloadBean.get(Collector.SITE_ID)); + Assert.assertEquals(EventType.FILE_REQUEST.getType(), collectorPayloadBean.get(Collector.EVENT_TYPE)); } } diff --git a/dotCMS/src/test/java/com/dotcms/analytics/track/collectors/PagesCollectorTest.java b/dotCMS/src/test/java/com/dotcms/analytics/track/collectors/PagesCollectorTest.java index 7668e4a8b832..a5915a358e0a 100644 --- a/dotCMS/src/test/java/com/dotcms/analytics/track/collectors/PagesCollectorTest.java +++ b/dotCMS/src/test/java/com/dotcms/analytics/track/collectors/PagesCollectorTest.java @@ -3,15 +3,12 @@ import com.dotcms.analytics.track.matchers.RequestMatcher; import com.dotmarketing.beans.Host; import com.dotmarketing.cms.urlmap.URLMapAPIImpl; -import com.dotmarketing.portlets.contentlet.model.Contentlet; import com.dotmarketing.portlets.htmlpageasset.business.HTMLPageAssetAPI; import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; import java.io.IOException; -import java.util.Map; -import java.util.Optional; /** * Test for the {@link PagesCollector} class @@ -29,9 +26,9 @@ public class PagesCollectorTest { public void test_collect_easy_path() throws IOException { final PagesCollector pagesCollector = new PagesCollector(Mockito.mock(HTMLPageAssetAPI.class), Mockito.mock(URLMapAPIImpl.class)); - final Host host = new Host(); - host.setIdentifier("1"); - host.setHostname("www.dotcms.com"); + final Host host = Mockito.mock(Host.class); + Mockito.when(host.getIdentifier()).thenReturn("1"); + Mockito.when(host.getHostname()).thenReturn("www.dotcms.com"); final CollectorContextMap collectorContextMap = new CollectorContextMap() { @Override public Object get(final String key) { @@ -62,9 +59,9 @@ public RequestMatcher getRequestMatcher() { final CollectorPayloadBean collectorPayloadBean = new ConcurrentCollectorPayloadBean(); pagesCollector.collect(collectorContextMap, collectorPayloadBean); - Assert.assertEquals("/test-path", collectorPayloadBean.get("url")); - Assert.assertEquals("www.dotcms.com", collectorPayloadBean.get("host")); - Assert.assertEquals("en", collectorPayloadBean.get("language")); - Assert.assertEquals(EventType.PAGE_REQUEST.getType(), collectorPayloadBean.get("event_type")); + Assert.assertEquals("/test-path", collectorPayloadBean.get(Collector.URL)); + Assert.assertEquals("www.dotcms.com", collectorPayloadBean.get(Collector.SITE_NAME)); + Assert.assertEquals("en", collectorPayloadBean.get(Collector.LANGUAGE)); + Assert.assertEquals(EventType.PAGE_REQUEST.getType(), collectorPayloadBean.get(Collector.EVENT_TYPE)); } } diff --git a/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/AsyncVanitiesCollectorTest.java b/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/AsyncVanitiesCollectorTest.java index 8635612928ef..807448c2d578 100644 --- a/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/AsyncVanitiesCollectorTest.java +++ b/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/AsyncVanitiesCollectorTest.java @@ -84,15 +84,21 @@ public void collectAsyncVanityData() throws DotDataException, IOException, assertTrue("Resolved vanity url must be present", resolvedVanity.isPresent()); final Map expectedDataMap = Map.of( - "event_type", EventType.PAGE_REQUEST.getType(), - "host", testSite.getHostname(), - "comeFromVanityURL", true, - "language", defaultLanguage.getIsoCode(), - "url", TEST_PAGE_URL, - "object", Map.of( - "id", testHTMLPage.getIdentifier(), - "title", TEST_PAGE_NAME, - "url", TEST_PAGE_URL) + Collector.EVENT_TYPE, EventType.PAGE_REQUEST.getType(), + Collector.SITE_NAME, testSite.getHostname(), + Collector.COME_FROM_VANITY_URL, true, + Collector.LANGUAGE, defaultLanguage.getIsoCode(), + Collector.URL, TEST_PAGE_URL, + Collector.OBJECT, Map.of( + Collector.ID, testHTMLPage.getIdentifier(), + Collector.TITLE, TEST_PAGE_NAME, + Collector.URL, TEST_PAGE_URL, + Collector.CONTENT_TYPE_ID, testHTMLPage.getContentType().id(), + Collector.CONTENT_TYPE_NAME, testHTMLPage.getContentType().name(), + Collector.CONTENT_TYPE_VAR_NAME, testHTMLPage.getContentType().variable(), + Collector.BASE_TYPE, testHTMLPage.getContentType().baseType().name(), + Collector.LIVE, testHTMLPage.isLive(), + Collector.WORKING, testHTMLPage.isWorking()) ); final Collector collector = new AsyncVanitiesCollector(); diff --git a/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/BasicProfileCollectorTest.java b/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/BasicProfileCollectorTest.java index 50ba30bfebbf..16b72e4d2d4d 100644 --- a/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/BasicProfileCollectorTest.java +++ b/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/BasicProfileCollectorTest.java @@ -55,15 +55,14 @@ public void collectBasicProfileData() throws DotDataException, UnknownHostExcept final HttpServletRequest request = Util.mockHttpRequestObj(response, "/", requestId, APILocator.getUserAPI().getAnonymousUser()); final Map expectedDataMap = Map.of( - "renderMode", "LIVE", - "cluster", CLUSTER_ID, - "server", SERVER_ID, - "persona", "dot:default", - "utc_time", "2024-10-09T00:00:00.000000Z", - "sessionNew", true, - "userAgent", Util.USER_AGENT, - "sessionId", "DAA3339CD687D9ABD4101CF9EDDD42DB", - "request_id", requestId + Collector.CLUSTER, CLUSTER_ID, + Collector.SERVER, SERVER_ID, + Collector.PERSONA, "dot:default", + Collector.UTC_TIME, "2024-10-09T00:00:00.000000Z", + Collector.SESSION_NEW, true, + Collector.USER_AGENT, Util.USER_AGENT, + Collector.SESSION_ID, "DAA3339CD687D9ABD4101CF9EDDD42DB", + Collector.REQUEST_ID, requestId ); final Collector collector = new BasicProfileCollector(); final CollectorPayloadBean collectedData = Util.getCollectorPayloadBean(request, collector, new PagesAndUrlMapsRequestMatcher(), null); @@ -75,7 +74,7 @@ public void collectBasicProfileData() throws DotDataException, UnknownHostExcept if (collectedData.toMap().containsKey(key)) { final Object expectedValue = expectedDataMap.get(key); final Object collectedValue = collectedData.toMap().get(key); - if (!"utc_time".equalsIgnoreCase(key)) { + if (!Collector.UTC_TIME.equalsIgnoreCase(key)) { assertEquals("Collected value must be equal to expected value for key: " + key, expectedValue, collectedValue); } counter++; diff --git a/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/FilesCollectorTest.java b/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/FilesCollectorTest.java index e8d544f63dc8..d82cd92667e8 100644 --- a/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/FilesCollectorTest.java +++ b/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/FilesCollectorTest.java @@ -14,6 +14,7 @@ import com.dotmarketing.util.PageMode; import com.dotmarketing.util.UUIDUtil; import com.dotmarketing.util.UtilMethods; +import io.vavr.control.Try; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -70,15 +71,22 @@ public void collectFileData() throws DotDataException, IOException, DotSecurityE APILocator.getUserAPI().getAnonymousUser()); final Map expectedDataMap = Map.of( - "host", testSite.getHostname(), - "site", testSite.getIdentifier(), - "language", APILocator.getLanguageAPI().getDefaultLanguage().getIsoCode(), - "event_type", EventType.FILE_REQUEST.getType(), - "url", testFileAsset.getURI(), - "object", Map.of( - "id", testFileAsset.getIdentifier(), - "title", testFileAsset.getTitle(), - "url", testFileAsset.getURI()) + Collector.SITE_NAME, testSite.getHostname(), + Collector.SITE_ID, testSite.getIdentifier(), + Collector.LANGUAGE, APILocator.getLanguageAPI().getDefaultLanguage().getIsoCode(), + Collector.EVENT_TYPE, EventType.FILE_REQUEST.getType(), + Collector.URL, testFileAsset.getURI(), + Collector.OBJECT, Map.of( + Collector.ID, testFileAsset.getIdentifier(), + Collector.TITLE, testFileAsset.getTitle(), + Collector.URL, testFileAsset.getURI(), + Collector.CONTENT_TYPE_ID, testFileAsset.getContentType().id(), + Collector.CONTENT_TYPE_NAME, testFileAsset.getContentType().name(), + Collector.CONTENT_TYPE_VAR_NAME, testFileAsset.getContentType().variable(), + Collector.BASE_TYPE, testFileAsset.getContentType().baseType().name(), + Collector.LIVE, String.valueOf(Try.of(()->testFileAsset.isLive()).getOrElse(false)), + Collector.WORKING, String.valueOf(Try.of(()->testFileAsset.isWorking()).getOrElse(false)) + ) ); final Collector collector = new FilesCollector(); 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 a03992d5450b..e532d5855c27 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 @@ -11,6 +11,7 @@ import com.dotmarketing.beans.Host; import com.dotmarketing.business.APILocator; import com.dotmarketing.exception.DotDataException; +import com.dotmarketing.exception.DotSecurityException; import com.dotmarketing.portlets.contentlet.model.Contentlet; import com.dotmarketing.portlets.contentlet.model.IndexPolicy; import com.dotmarketing.portlets.htmlpageasset.model.HTMLPageAsset; @@ -70,7 +71,7 @@ public static void prepare() throws Exception { * */ @Test - public void testPageDetailCollector() throws DotDataException, UnknownHostException { + public void testPageDetailCollector() throws DotDataException, UnknownHostException, DotSecurityException { final HttpServletResponse response = mock(HttpServletResponse.class); final String requestId = UUIDUtil.uuid(); final HttpServletRequest request = Util.mockHttpRequestObj(response, @@ -100,15 +101,21 @@ public void testPageDetailCollector() throws DotDataException, UnknownHostExcept ContentletDataGen.publish(newsTestContent); final Map expectedDataMap = Map.of( - "event_type", EventType.PAGE_REQUEST.getType(), - "host", testSite.getHostname(), - "language", language.getIsoCode(), - "url", TEST_URL_MAP_DETAIL_PAGE_URL, - "object", Map.of( - "id", testDetailPage.getIdentifier(), - "title", testDetailPage.getTitle(), - "url", TEST_URL_MAP_DETAIL_PAGE_URL, - "detail_page_url", testDetailPage.getURI()) + Collector.EVENT_TYPE, EventType.PAGE_REQUEST.getType(), + Collector.SITE_NAME, testSite.getHostname(), + Collector.LANGUAGE, language.getIsoCode(), + Collector.URL, TEST_URL_MAP_DETAIL_PAGE_URL, + Collector.OBJECT, Map.of( + Collector.ID, testDetailPage.getIdentifier(), + Collector.TITLE, testDetailPage.getTitle(), + Collector.URL, TEST_URL_MAP_DETAIL_PAGE_URL, + Collector.CONTENT_TYPE_ID, newsTestContent.getContentType().id(), + Collector.CONTENT_TYPE_NAME, newsTestContent.getContentType().name(), + Collector.CONTENT_TYPE_VAR_NAME, newsTestContent.getContentType().variable(), + Collector.BASE_TYPE, newsTestContent.getContentType().baseType().name(), + Collector.LIVE, newsTestContent.isLive(), + Collector.WORKING, newsTestContent.isWorking(), + Collector.DETAIL_PAGE_URL, testDetailPage.getURI()) ); final Collector collector = new PageDetailCollector(); diff --git a/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/PagesCollectorTest.java b/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/PagesCollectorTest.java index 934269c23996..5b789e909ea8 100644 --- a/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/PagesCollectorTest.java +++ b/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/PagesCollectorTest.java @@ -73,7 +73,7 @@ public static void prepare() throws Exception { * */ @Test - public void collectPageData() throws DotDataException, UnknownHostException { + public void collectPageData() throws Exception { final HttpServletResponse response = mock(HttpServletResponse.class); final String requestId = UUIDUtil.uuid(); final HttpServletRequest request = Util.mockHttpRequestObj(response, TEST_PAGE_URL, @@ -82,14 +82,20 @@ public void collectPageData() throws DotDataException, UnknownHostException { final HTMLPageAsset testPage = Util.createTestHTMLPage(testSite, TEST_PAGE_NAME); final Map expectedDataMap = Map.of( - "event_type", EventType.PAGE_REQUEST.getType(), - "host", testSite.getHostname(), - "language", APILocator.getLanguageAPI().getDefaultLanguage().getIsoCode(), - "url", TEST_PAGE_URL, - "object", Map.of( - "id", testPage.getIdentifier(), - "title", testPage.getTitle(), - "url", testPage.getURI()) + Collector.EVENT_TYPE, EventType.PAGE_REQUEST.getType(), + Collector.SITE_NAME, testSite.getHostname(), + Collector.LANGUAGE, APILocator.getLanguageAPI().getDefaultLanguage().getIsoCode(), + Collector.URL, TEST_PAGE_URL, + Collector.OBJECT, Map.of( + Collector.ID, testPage.getIdentifier(), + Collector.TITLE, testPage.getTitle(), + Collector.URL, TEST_PAGE_URL, + Collector.CONTENT_TYPE_ID, testPage.getContentType().id(), + Collector.CONTENT_TYPE_NAME, testPage.getContentType().name(), + Collector.CONTENT_TYPE_VAR_NAME, testPage.getContentType().variable(), + Collector.BASE_TYPE, testPage.getContentType().baseType().name(), + Collector.LIVE, testPage.isLive(), + Collector.WORKING, testPage.isWorking()) ); final Collector collector = new PagesCollector(); @@ -116,7 +122,7 @@ public void collectPageData() throws DotDataException, UnknownHostException { * */ @Test - public void collectUrlMapPageData() throws DotDataException, UnknownHostException { + public void collectUrlMapPageData() throws Exception { final HttpServletResponse response = mock(HttpServletResponse.class); final String requestId = UUIDUtil.uuid(); final HttpServletRequest request = Util.mockHttpRequestObj(response, @@ -148,17 +154,21 @@ public void collectUrlMapPageData() throws DotDataException, UnknownHostExceptio ContentletDataGen.publish(newsTestContent); final Map expectedDataMap = Map.of( - "event_type", EventType.URL_MAP.getType(), - "host", testSite.getHostname(), - "language", APILocator.getLanguageAPI().getDefaultLanguage().getIsoCode(), - "url", TEST_URL_MAP_DETAIL_PAGE_URL, - "object", Map.of( - "content_type_var_name", urlMappedContentType.variable(), - "content_type_id", urlMappedContentType.id(), - "id", newsTestContent.getIdentifier(), - "content_type_name", urlMappedContentType.name(), - "title", urlTitle, - "url", TEST_URL_MAP_DETAIL_PAGE_URL) + Collector.EVENT_TYPE, EventType.URL_MAP.getType(), + Collector.SITE_NAME, testSite.getHostname(), + Collector.LANGUAGE, APILocator.getLanguageAPI().getDefaultLanguage().getIsoCode(), + Collector.URL, TEST_URL_MAP_DETAIL_PAGE_URL, + Collector.OBJECT, Map.of( + Collector.ID, newsTestContent.getIdentifier(), + Collector.TITLE, urlTitle, + Collector.URL, TEST_URL_MAP_DETAIL_PAGE_URL, + Collector.CONTENT_TYPE_ID, urlMappedContentType.id(), + Collector.CONTENT_TYPE_NAME, urlMappedContentType.name(), + Collector.CONTENT_TYPE_VAR_NAME, urlMappedContentType.variable(), + Collector.BASE_TYPE, urlMappedContentType.baseType().name(), + Collector.LIVE, newsTestContent.isLive(), + Collector.WORKING, newsTestContent.isWorking() + ) ); final Collector collector = new PagesCollector(); diff --git a/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/SyncVanitiesCollectorTest.java b/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/SyncVanitiesCollectorTest.java index 636e6cbfe1ab..c0bcb1f3c993 100644 --- a/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/SyncVanitiesCollectorTest.java +++ b/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/SyncVanitiesCollectorTest.java @@ -87,17 +87,17 @@ public void collectSyncVanityData() throws DotDataException, IOException, DotSec assertTrue("Resolved vanity url must be present", resolvedVanity.isPresent()); final Map expectedDataMap = Map.of( - "site", testSite.getIdentifier(), - "event_type", EventType.VANITY_REQUEST.getType(), - "language", defaultLanguage.getIsoCode(), - "vanity_url", TEST_PAGE_URL, - "language_id", defaultLanguage.getId(), - "url", URI, - "object", Map.of( - "forward_to", TEST_PAGE_URL, - "response", "200", - "id", resolvedVanity.get().vanityUrlId, - "url", URI) + Collector.SITE_ID, testSite.getIdentifier(), + Collector.EVENT_TYPE, EventType.VANITY_REQUEST.getType(), + Collector.LANGUAGE, defaultLanguage.getIsoCode(), + Collector.VANITY_URL_KEY, TEST_PAGE_URL, + Collector.LANGUAGE_ID, defaultLanguage.getId(), + Collector.URL, URI, + Collector.OBJECT, Map.of( + Collector.FORWARD_TO, TEST_PAGE_URL, + Collector.RESPONSE, "200", + Collector.ID, resolvedVanity.get().vanityUrlId, + Collector.URL, URI) ); final Collector collector = new SyncVanitiesCollector(); 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 82a73bc488bd..ace3b4430674 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 @@ -51,6 +51,7 @@ import java.util.Optional; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -304,8 +305,7 @@ public static void validateExpectedEntries(final Map expectedDat */ public static void validateExpectedEntries(final Map expectedDataMap, final Map collectedData) { - assertEquals("Number of returned expected properties doesn't match", expectedDataMap.size(), - collectedData.size()); + assertTrue("Number of returned expected properties doesn't match", collectedData.size() >= expectedDataMap.size()); for (final String key : expectedDataMap.keySet()) { if (collectedData.containsKey(key)) { final Object expectedValue = expectedDataMap.get(key); @@ -313,17 +313,18 @@ public static void validateExpectedEntries(final Map expectedDat if (expectedValue instanceof Map) { final Map expectedMap = (Map) expectedValue; final Map collectedMap = (Map) collectedValue; - assertEquals("Number of returned expected properties in 'object' entry " + + assertTrue("Number of returned expected properties in 'object' entry " + "doesn't match", - expectedMap.size(), collectedMap.size()); + collectedMap.size() >= expectedMap.size()); for (final String mapKey : expectedMap.keySet()) { assertEquals("Collected value in 'object' entry must be equal to expected" + " value for key: " - + mapKey, expectedMap.get(mapKey), collectedMap.get(mapKey)); + + mapKey, expectedMap.get(mapKey).toString(), collectedMap.get(mapKey).toString()); } + } else { + assertEquals("Collected value must be equal to expected value for key: " + key, + expectedValue, collectedValue); } - assertEquals("Collected value must be equal to expected value for key: " + key, - expectedValue, collectedValue); } } } diff --git a/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/WebEventsCollectorServiceImplTest.java b/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/WebEventsCollectorServiceImplTest.java index e80bf21f71bb..a1e344046cb8 100644 --- a/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/WebEventsCollectorServiceImplTest.java +++ b/dotcms-integration/src/test/java/com/dotcms/analytics/track/collectors/WebEventsCollectorServiceImplTest.java @@ -32,6 +32,7 @@ import com.dotmarketing.portlets.languagesmanager.model.Language; import com.dotmarketing.util.Config; import com.dotmarketing.util.UUIDUtil; +import io.vavr.control.Try; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -175,18 +176,26 @@ public void testBasicProfileCollector() throws DotDataException, IOException { * */ @Test - public void testPagesCollector() throws DotDataException, IOException { + public void testPagesCollector() throws DotDataException, IOException, DotSecurityException { testPage = null != testPage ? testPage : Util.createTestHTMLPage(testSite, TEST_PAGE_NAME); final Map expectedDataMap = Map.of( - "event_type", EventType.PAGE_REQUEST.getType(), - "host", testSite.getHostname(), - "url", TEST_PAGE_URL, - "language", APILocator.getLanguageAPI().getDefaultLanguage().getIsoCode(), - "object", Map.of( - "id", testPage.getIdentifier(), - "title", testPage.getTitle(), - "url", testPage.getURI()) + Collector.EVENT_TYPE, EventType.PAGE_REQUEST.getType(), + Collector.SITE_NAME, testSite.getHostname(), + Collector.URL, TEST_PAGE_URL, + Collector.LANGUAGE, APILocator.getLanguageAPI().getDefaultLanguage().getIsoCode(), + Collector.OBJECT, Map.of( + Collector.ID, testPage.getIdentifier(), + Collector.TITLE, testPage.getTitle(), + Collector.URL, testPage.getURI(), + Collector.CONTENT_TYPE_ID, testPage.getContentType().id(), + Collector.CONTENT_TYPE_NAME, testPage.getContentType().name(), + Collector.CONTENT_TYPE_VAR_NAME, testPage.getContentType().variable(), + Collector.BASE_TYPE, testPage.getContentType().baseType().name(), + Collector.LIVE, testPage.isLive(), + Collector.WORKING, testPage.isWorking() + ) + ); final TestEventLogSubmitter submitter = new TestEventLogSubmitter(); @@ -220,7 +229,7 @@ public void testPagesCollector() throws DotDataException, IOException { * */ @Test - public void testPageDetailCollector() throws DotDataException, IOException { + public void testPageDetailCollector() throws Exception { testDetailPage = null != testDetailPage ? testDetailPage : Util.createTestHTMLPage(testSite, TEST_URL_MAP_PAGE_NAME, PARENT_FOLDER_1_NAME); final String urlTitle = "mynews"; @@ -243,15 +252,24 @@ public void testPageDetailCollector() throws DotDataException, IOException { final Contentlet newsTestContent = contentletDataGen.nextPersisted(); ContentletDataGen.publish(newsTestContent); final Map expectedDataMap = Map.of( - "event_type", EventType.PAGE_REQUEST.getType(), - "host", testSite.getHostname(), - "language", language.getIsoCode(), - "url", TEST_URL_MAP_DETAIL_PAGE_URL, - "object", Map.of( - "id", testDetailPage.getIdentifier(), - "title", testDetailPage.getTitle(), - "url", TEST_URL_MAP_DETAIL_PAGE_URL, - "detail_page_url", testDetailPage.getURI()) + Collector.EVENT_TYPE, EventType.PAGE_REQUEST.getType(), + Collector.SITE_NAME, testSite.getHostname(), + Collector.LANGUAGE, language.getIsoCode(), + Collector.URL, TEST_URL_MAP_DETAIL_PAGE_URL, + Collector.OBJECT, Map.of( + Collector.ID, testDetailPage.getIdentifier(), + Collector.TITLE, testDetailPage.getTitle(), + Collector.URL, TEST_URL_MAP_DETAIL_PAGE_URL, + Collector.CONTENT_TYPE_ID, urlMappedContentType.id(), + Collector.CONTENT_TYPE_NAME, urlMappedContentType.name(), + Collector.CONTENT_TYPE_VAR_NAME, urlMappedContentType.variable(), + Collector.BASE_TYPE, urlMappedContentType.baseType().name(), + Collector.LIVE, testDetailPage.isLive(), + Collector.WORKING, testDetailPage.isWorking(), + Collector.DETAIL_PAGE_URL, testDetailPage.getURI() + + + ) ); final TestEventLogSubmitter submitter = new TestEventLogSubmitter(); @@ -293,17 +311,17 @@ public void testSyncVanitiesCollector() throws DotDataException, IOException, Do assertTrue(resolvedVanity.isPresent(), "Test resolved vanity url must be present"); final Map expectedDataMap = Map.of( - "site", testSite.getIdentifier(), - "event_type", EventType.VANITY_REQUEST.getType(), - "language", defaultLanguage.getIsoCode(), - "vanity_url", TEST_PAGE_URL, - "language_id", (int) defaultLanguage.getId(), - "url", URI, - "object", Map.of( - "forward_to", TEST_PAGE_URL, - "response", "200", - "id", resolvedVanity.get().vanityUrlId, - "url", URI) + Collector.SITE_ID, testSite.getIdentifier(), + Collector.EVENT_TYPE, EventType.VANITY_REQUEST.getType(), + Collector.LANGUAGE, defaultLanguage.getIsoCode(), + Collector.VANITY_URL_KEY, TEST_PAGE_URL, + Collector.LANGUAGE_ID, (int) defaultLanguage.getId(), + Collector.URL, URI, + Collector.OBJECT, Map.of( + Collector.FORWARD_TO, TEST_PAGE_URL, + Collector.RESPONSE, "200", + Collector.ID, resolvedVanity.get().vanityUrlId, + Collector.URL, URI) ); final TestEventLogSubmitter submitter = new TestEventLogSubmitter(); @@ -352,15 +370,21 @@ public void testAsyncVanitiesCollector() throws DotDataException, IOException, D assertTrue(resolvedVanity.isPresent(), "Test resolved vanity url must be present"); final Map expectedDataMap = Map.of( - "event_type", EventType.PAGE_REQUEST.getType(), - "host", testSite.getHostname(), - "comeFromVanityURL", true, - "language", defaultLanguage.getIsoCode(), - "url", TEST_PAGE_URL, - "object", Map.of( - "id", testPage.getIdentifier(), - "title", TEST_PAGE_NAME, - "url", TEST_PAGE_URL) + Collector.EVENT_TYPE, EventType.PAGE_REQUEST.getType(), + Collector.SITE_NAME, testSite.getHostname(), + Collector.COME_FROM_VANITY_URL, true, + Collector.LANGUAGE, defaultLanguage.getIsoCode(), + Collector.URL, TEST_PAGE_URL, + Collector.OBJECT, Map.of( + Collector.ID, testPage.getIdentifier(), + Collector.TITLE, TEST_PAGE_NAME, + Collector.URL, TEST_PAGE_URL, + Collector.CONTENT_TYPE_ID, testPage.getContentType().id(), + Collector.CONTENT_TYPE_NAME, testPage.getContentType().name(), + Collector.CONTENT_TYPE_VAR_NAME, testPage.getContentType().variable(), + Collector.BASE_TYPE, testPage.getContentType().baseType().name(), + Collector.LIVE, testPage.isLive(), + Collector.WORKING, testPage.isWorking()) ); final TestEventLogSubmitter submitter = new TestEventLogSubmitter(); @@ -406,15 +430,23 @@ public void testFilesCollector() throws DotDataException, IOException, DotSecuri ".txt","Sample content for my test file", "parent-folder-for-file", testSite); final Map expectedDataMap = Map.of( - "host", testSite.getHostname(), - "site", testSite.getIdentifier(), - "language", APILocator.getLanguageAPI().getDefaultLanguage().getIsoCode(), - "event_type", EventType.FILE_REQUEST.getType(), - "url", testFileAsset.getURI(), - "object", Map.of( - "id", testFileAsset.getIdentifier(), - "title", testFileAsset.getTitle(), - "url", testFileAsset.getURI()) + Collector.SITE_NAME, testSite.getHostname(), + Collector.SITE_ID, testSite.getIdentifier(), + Collector.LANGUAGE, APILocator.getLanguageAPI().getDefaultLanguage().getIsoCode(), + Collector.EVENT_TYPE, EventType.FILE_REQUEST.getType(), + Collector.URL, testFileAsset.getURI(), + Collector.OBJECT, Map.of( + Collector.ID, testFileAsset.getIdentifier(), + Collector.TITLE, testFileAsset.getTitle(), + Collector.URL, testFileAsset.getURI(), + Collector.CONTENT_TYPE_ID, testFileAsset.getContentType().id(), + Collector.CONTENT_TYPE_NAME, testFileAsset.getContentType().name(), + Collector.CONTENT_TYPE_VAR_NAME, testFileAsset.getContentType().variable(), + Collector.BASE_TYPE, testFileAsset.getContentType().baseType().name(), + Collector.LIVE, String.valueOf(Try.of(()->testFileAsset.isLive()).getOrElse(false)), + Collector.WORKING, String.valueOf(Try.of(()->testFileAsset.isWorking()).getOrElse(false)) + ) + ); final TestEventLogSubmitter submitter = new TestEventLogSubmitter();