Skip to content

Commit

Permalink
feat(Content Analytics) fixes #31414 : Record Content Type of Detail …
Browse files Browse the repository at this point in the history
…Pages Correctly in Events (#31446)

### Proposed Changes
* Changing some parameters of the CA Event to include the appropriate
Content Type ID, Name, and Velocity Variable Name.
  • Loading branch information
jcastro-dotcms authored Feb 24, 2025
1 parent f70861e commit 2d0b56b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.dotmarketing.cms.urlmap.UrlMapContext;
import com.dotmarketing.portlets.contentlet.model.Contentlet;
import com.dotmarketing.portlets.htmlpageasset.business.HTMLPageAssetAPI;
import com.dotmarketing.portlets.htmlpageasset.model.HTMLPageAsset;
import com.dotmarketing.portlets.htmlpageasset.model.IHTMLPage;
import com.dotmarketing.util.Logger;
import com.dotmarketing.util.PageMode;
Expand Down Expand Up @@ -73,17 +74,17 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa
.onFailure(e -> Logger.error(this, String.format("Error finding detail page " +
"'%s': %s", urlMapContentType.detailPage(), getErrorMessage(e)), e))
.getOrNull();

final HTMLPageAsset detailPageAsset = (HTMLPageAsset) detailPageContent;
final HashMap<String, String> pageObject = new HashMap<>();
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(CONTENT_TYPE_ID, detailPageAsset.getContentTypeId());
pageObject.put(CONTENT_TYPE_NAME, detailPageAsset.getContentType().name());
pageObject.put(CONTENT_TYPE_VAR_NAME, detailPageAsset.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(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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ public void testPageDetailCollector() throws DotDataException, UnknownHostExcept
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.CONTENT_TYPE_ID, testDetailPage.getContentTypeId(),
Collector.CONTENT_TYPE_NAME, testDetailPage.getContentType().name(),
Collector.CONTENT_TYPE_VAR_NAME, testDetailPage.getContentType().variable(),
Collector.BASE_TYPE, newsTestContent.getContentType().baseType().name(),
Collector.LIVE, newsTestContent.isLive(),
Collector.WORKING, newsTestContent.isWorking(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ public void testPageDetailCollector() throws Exception {
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.CONTENT_TYPE_ID, testDetailPage.getContentTypeId(),
Collector.CONTENT_TYPE_NAME, testDetailPage.getContentType().name(),
Collector.CONTENT_TYPE_VAR_NAME, testDetailPage.getContentType().variable(),
Collector.BASE_TYPE, urlMappedContentType.baseType().name(),
Collector.LIVE, testDetailPage.isLive(),
Collector.WORKING, testDetailPage.isWorking(),
Expand Down

0 comments on commit 2d0b56b

Please sign in to comment.