From 7e1ea558ade4929b9cde190988beb1b2c1025174 Mon Sep 17 00:00:00 2001 From: jdotcms Date: Tue, 26 Nov 2024 15:49:43 -0600 Subject: [PATCH] #30411 first shot with some addition and name refactoring --- .../collectors/AsyncVanitiesCollector.java | 2 +- .../analytics/track/collectors/Collector.java | 48 ++++++++++++------- .../track/collectors/CollectorContextMap.java | 1 + .../collectors/CustomerEventCollector.java | 4 +- .../track/collectors/FilesCollector.java | 8 +++- .../track/collectors/PageDetailCollector.java | 6 ++- .../track/collectors/PagesCollector.java | 5 +- .../collectors/SyncVanitiesCollector.java | 8 ++-- 8 files changed, 51 insertions(+), 31 deletions(-) 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..813f5ce78f11 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(URL, cachedVanityUrl.forwardTo)); match.get(whoIAM).collect(innerCollectorContextMap, collectorPayloadBean); } 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..cf481099d078 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"; /** * 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..49ecd2ff92f5 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 @@ -57,14 +57,18 @@ 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()); }); } 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..4acfede47cbd 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,10 @@ 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(DETAIL_PAGE_URL, Try.of(detailPageContent::getURI).getOrElse(StringPool.BLANK)); collectorPayloadBean.put(OBJECT, pageObject); } @@ -87,7 +91,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 90c4c6e55b01..6fef01620651 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,7 @@ 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()); collectorPayloadBean.put(EVENT_TYPE, EventType.URL_MAP.getType()); } } else { @@ -83,8 +84,6 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa pageObject.put(ID, page.getIdentifier()); pageObject.put(TITLE, page.getTitle()); collectorPayloadBean.put(EVENT_TYPE, EventType.PAGE_REQUEST.getType()); - pageObject.put("id", page.getIdentifier()); - pageObject.put("title", page.getTitle()); } pageObject.put(URL, uri); } @@ -94,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/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;