diff --git a/docker/docker-compose-examples/analytics/setup/config/dev/cube/schema/Events.js b/docker/docker-compose-examples/analytics/setup/config/dev/cube/schema/Events.js index f6aada775d43..07466ea3b791 100644 --- a/docker/docker-compose-examples/analytics/setup/config/dev/cube/schema/Events.js +++ b/docker/docker-compose-examples/analytics/setup/config/dev/cube/schema/Events.js @@ -157,7 +157,10 @@ cube('request', { MIN(utc_time) as createdAt, MAX(source_ip) as source_ip, MAX(language) as language, - MAX(user_agent) as user_agent, + MAX(useragent) as user_agent, + MAX(persona) as persona, + MAX(rendermode) as rendermode, + MAX(referer) as referer, MAX(host) as host, MAX(CASE WHEN event_type = 'PAGE_REQUEST' THEN object_id ELSE NULL END) as page_id, MAX(CASE WHEN event_type = 'PAGE_REQUEST' THEN object_title ELSE NULL END) as page_title, @@ -174,7 +177,7 @@ cube('request', { MAX(CASE WHEN event_type = 'URL_MAP' THEN object_content_type_id ELSE NULL END) as url_map_content_type_id, MAX(CASE WHEN event_type = 'URL_MAP' THEN object_content_type_name ELSE NULL END) as url_map_content_type_name, MAX(CASE WHEN event_type = 'URL_MAP' THEN object_content_type_var_name ELSE NULL END) as url_map_content_type_var_name, - MAX(CASE WHEN event_type = 'URL_MAP' THEN object_detail_page_url ELSE NULL END) as url_map_detail_page_url, + MAX(object_detail_page_url) as url_map_detail_page_url, MAX(url) AS url, CASE WHEN MAX(CASE WHEN event_type = 'FILE_REQUEST' THEN 1 ELSE 0 END) = 1 THEN 'FILE' @@ -192,6 +195,9 @@ cube('request', { sourceIp: { sql: 'source_ip', type: `string` }, language: { sql: 'language', type: `string` }, userAgent: { sql: 'user_agent', type: `string` }, + referer: { sql: 'referer', type: `string` }, + renderMode: { sql: 'rendermode', type: `string` }, + persona: { sql: 'persona', type: `string` }, host: { sql: 'host', type: `string` }, url: { sql: 'url', type: `string` }, pageId: { sql: 'page_id', type: `string` }, @@ -209,11 +215,52 @@ cube('request', { urlMapContentDetailTitle: { sql: 'url_map_content_detail_title', type: `string` }, urlMapContentId: { sql: 'url_map_content_type_id', type: `string` }, urlMapContentTypeName: { sql: 'url_map_content_type_name', type: `string` }, - urlMapContentTypeVarName: { sql: 'url_map_content_type_var_name', type: `string` }, + urlMapContentTypeVarName: { sql: 'url_map_content_type_var_name', type: `string` } }, measures: { count: { type: "count" + }, + totalSessions: { + sql: 'sessionid', + type: 'countDistinct', + title: 'Total Sessions' + }, + totalRequest: { + sql: 'request_id', + type: 'countDistinct', + title: 'Total Requests' + }, + pageRequest: { + sql: 'page_id', + type: 'count', + title: 'Count of Page request' + }, + uniquePageRequest: { + sql: 'page_id', + type: 'countDistinct', + title: 'Unique Page Ids by Session' + }, + pageRequestAverage: { + sql: `${fileRequest} / NULLIF(${totalRequest}, 0)`, + type: 'number', + title: 'FileRequest Average' + }, + fileRequest: { + sql: 'file_id', + type: 'count', + title: 'Count of File Request' + }, + uniqueFileRequest: { + sql: 'file_id', + type: 'countDistinct', + title: 'Unique Count of File Request' + }, + fileRequestAverage: { + sql: `${fileRequest} / NULLIF(${totalRequest}, 0)`, + type: 'number', + title: 'FileRequest Average' } } }); + 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 3ab4a74277e7..39f0f3f8f8b5 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 @@ -3,7 +3,11 @@ import com.dotcms.enterprise.cluster.ClusterFactory; import com.dotcms.util.FunctionUtils; import com.dotmarketing.business.APILocator; +import com.dotmarketing.business.web.WebAPILocator; +import com.dotmarketing.util.PageMode; +import com.dotmarketing.util.UtilMethods; +import javax.servlet.http.HttpServletRequest; import java.time.Instant; import java.time.ZoneId; import java.time.ZonedDateTime; @@ -41,6 +45,21 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa FunctionUtils.getOrDefault(Objects.nonNull(serverId), ()->serverId,()->APILocator.getServerAPI().readServerId())); collectorPayloadBean.put("sessionId", sessionId); collectorPayloadBean.put("sessionNew", sessionNew); + + if (UtilMethods.isSet(collectorContextMap.get("referer"))) { + collectorPayloadBean.put("referer", collectorContextMap.get("referer").toString()); + } + + if (UtilMethods.isSet(collectorContextMap.get("user-agent"))) { + collectorPayloadBean.put("userAgent", collectorContextMap.get("user-agent").toString()); + } + + final HttpServletRequest request = (HttpServletRequest)collectorContextMap.get("request"); + + collectorPayloadBean.put("persona", + WebAPILocator.getPersonalizationWebAPI().getContainerPersonalization(request)); + + collectorPayloadBean.put("renderMode", PageMode.get(request).toString().replace("_MODE", "")); return collectorPayloadBean; }