Skip to content

Commit

Permalink
Merge branch 'main' into issue-31402-urlContentMap-Take2
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinogiardino authored Mar 1, 2025
2 parents 1ac43dc + 155e3b0 commit b8ff27e
Show file tree
Hide file tree
Showing 76 changed files with 1,330 additions and 520 deletions.
2 changes: 1 addition & 1 deletion core-web/libs/sdk/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dotcms/client",
"version": "0.0.1-alpha.38",
"version": "0.0.1-beta.2",
"description": "Official JavaScript library for interacting with DotCMS REST APIs.",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion core-web/libs/sdk/experiments/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dotcms/experiments",
"version": "0.0.1-alpha.38",
"version": "0.0.1-beta.2",
"description": "Official JavaScript library to use Experiments with DotCMS.",
"repository": {
"type": "git",
Expand Down
3 changes: 2 additions & 1 deletion core-web/libs/sdk/experiments/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"allowJs": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true
"strict": true,
"moduleResolution": "bundler"
},
"files": [],
"include": ["src"],
Expand Down
13 changes: 12 additions & 1 deletion core-web/libs/sdk/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dotcms/react",
"version": "0.0.1-alpha.38",
"version": "0.0.1-beta-2",
"peerDependencies": {
"react": ">=18",
"react-dom": ">=18",
Expand All @@ -22,6 +22,17 @@
"React",
"Components"
],
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts",
"./next": "./src/next.ts"
},
"typesVersions": {
"*": {
".": ["./src/index.d.ts"],
"next": ["./src/next.d.ts"]
}
},
"author": "dotcms <[email protected]>",
"license": "MIT",
"bugs": {
Expand Down
6 changes: 4 additions & 2 deletions core-web/libs/sdk/react/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@
"executor": "@nx/rollup:rollup",
"outputs": ["{options.outputPath}"],
"options": {
"main": "libs/sdk/react/src/index.ts",
"additionalEntryPoints": ["libs/sdk/react/src/next.ts"],
"generateExportsField": true,
"outputPath": "dist/libs/sdk/react",
"tsConfig": "libs/sdk/react/tsconfig.lib.json",
"project": "libs/sdk/react/package.json",
"entryFile": "libs/sdk/react/src/index.ts",
"additionalEntryPoints": ["libs/sdk/react/src/next.ts"],
"external": ["react/jsx-runtime"],
"rollupConfig": "@nrwl/react/plugins/bundle-rollup",
"compiler": "babel",
"extractCss": false,
"format": ["esm"],
"extractCss": false,
"assets": [
{
"glob": "libs/sdk/react/README.md",
Expand Down
15 changes: 13 additions & 2 deletions core-web/libs/sdk/uve/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dotcms/uve",
"version": "0.0.1",
"version": "0.0.1-beta.2",
"description": "Official JavaScript library for interacting with Universal Visual Editor (UVE)",
"repository": {
"type": "git",
Expand All @@ -13,10 +13,21 @@
"UVE",
"Universal Visual Editor"
],
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts",
"./types": "./src/types.ts"
},
"typesVersions": {
"*": {
".": ["./src/index.d.ts"],
"types": ["./src/types.d.ts"]
}
},
"author": "dotcms <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/dotCMS/core/issues"
},
"homepage": "https://github.com/dotCMS/core/tree/main/core-web/libs/sdk/client/README.md"
"homepage": "https://github.com/dotCMS/core/tree/main/core-web/libs/sdk/uve/README.md"
}
15 changes: 9 additions & 6 deletions core-web/libs/sdk/uve/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@
"executor": "@nx/rollup:rollup",
"outputs": ["{options.outputPath}"],
"options": {
"format": ["esm", "cjs"],
"compiler": "tsc",
"main": "libs/sdk/uve/src/index.ts",
"additionalEntryPoints": ["libs/sdk/uve/src/types.ts"],
"generateExportsField": true,
"assets": [{ "input": "libs/sdk/uve", "output": ".", "glob": "*.md" }],
"outputPath": "dist/libs/sdk/uve",
"main": "libs/sdk/uve/src/public/index.ts",
"additionalEntryPoints": ["libs/sdk/uve/src/public/types.ts"],
"tsConfig": "libs/sdk/uve/tsconfig.lib.json"
"tsConfig": "libs/sdk/uve/tsconfig.lib.json",
"project": "libs/sdk/uve/package.json",
"entryFile": "libs/sdk/uve/src/index.ts",
"compiler": "babel",
"format": ["esm", "cjs"],
"extractCss": false,
"assets": [{ "input": "libs/sdk/uve", "output": ".", "glob": "*.md" }]
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions core-web/libs/sdk/uve/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { getUVEState } from './lib/utils';

export { getUVEState };
3 changes: 0 additions & 3 deletions core-web/libs/sdk/uve/src/public/index.ts

This file was deleted.

3 changes: 0 additions & 3 deletions core-web/libs/sdk/uve/src/public/types.ts

This file was deleted.

3 changes: 3 additions & 0 deletions core-web/libs/sdk/uve/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { UVE_MODE, UVEState } from './lib/types';

export { UVE_MODE, UVEState };
4 changes: 2 additions & 2 deletions core-web/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
"@dotcms/utils": ["libs/utils/src"],
"@dotcms/utils-testing": ["libs/utils-testing/src/index.ts"],
"@dotcms/utils/*": ["libs/utils/src/*"],
"@dotcms/uve": ["libs/sdk/uve/src/public/index.ts"],
"@dotcms/uve/types": ["libs/sdk/uve/src/public/types.ts"],
"@dotcms/uve": ["libs/sdk/uve/src/index.ts"],
"@dotcms/uve/types": ["libs/sdk/uve/src/types.ts"],
"@models/*": ["apps/dotcms-ui/src/app/shared/models/*"],
"@pipes/*": ["apps/dotcms-ui/src/app/view/pipes/*"],
"@portlets/*": ["apps/dotcms-ui/src/app/portlets/*"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ CREATE TABLE IF NOT EXISTS clickhouse_test_db.events
_timestamp DateTime,
api_key String,
cluster_id String,
customer_name String,
customer_category String,
environment_name String,
environment_version String,
customer_id String,
doc_encoding String,
doc_host String,
Expand Down Expand Up @@ -110,3 +114,9 @@ ALTER TABLE clickhouse_test_db.events DROP COLUMN IF EXISTS object_detail_page_u
ALTER TABLE clickhouse_test_db.events DROP COLUMN IF EXISTS object_url;
ALTER TABLE clickhouse_test_db.events DROP COLUMN IF EXISTS object_forward_to;
ALTER TABLE clickhouse_test_db.events DROP COLUMN IF EXISTS comefromvanityurl;


ALTER TABLE clickhouse_test_db.events ADD COLUMN IF NOT EXISTS customer_name String;
ALTER TABLE clickhouse_test_db.events ADD COLUMN IF NOT EXISTS customer_category String;
ALTER TABLE clickhouse_test_db.events ADD COLUMN IF NOT EXISTS environment_name String;
ALTER TABLE clickhouse_test_db.events ADD COLUMN IF NOT EXISTS environment_version String;
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.dotcms.analytics.track.matchers.VanitiesRequestMatcher;
import com.dotcms.analytics.web.AnalyticsWebAPI;
import com.dotcms.business.SystemTableUpdatedKeyEvent;
import com.dotcms.featureflag.FeatureFlagName;
import com.dotcms.filters.interceptor.Result;
import com.dotcms.filters.interceptor.WebInterceptor;
import com.dotcms.system.event.local.model.EventSubscriber;
Expand Down Expand Up @@ -38,7 +39,7 @@
public class AnalyticsTrackWebInterceptor implements WebInterceptor, EventSubscriber<SystemTableUpdatedKeyEvent> {

private static final String[] DEFAULT_BLACKLISTED_PROPS = new String[]{StringPool.BLANK};
private static final String ANALYTICS_TURNED_ON_KEY = "FEATURE_FLAG_CONTENT_ANALYTICS";
private static final String ANALYTICS_TURNED_ON_KEY = FeatureFlagName.FEATURE_FLAG_CONTENT_ANALYTICS;
private static final Map<String, RequestMatcher> requestMatchersMap = new ConcurrentHashMap<>();
private transient final AnalyticsWebAPI analyticsWebAPI;
private final WhiteBlackList whiteBlackList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
package com.dotcms.analytics.track.collectors;

import com.dotcms.enterprise.cluster.ClusterFactory;
import com.dotcms.exception.ExceptionUtil;
import com.dotcms.telemetry.business.MetricsAPI;
import com.dotcms.util.FunctionUtils;
import com.dotmarketing.business.APILocator;
import com.dotmarketing.business.web.WebAPILocator;
import com.dotmarketing.util.PageMode;
import com.dotmarketing.exception.DotDataException;
import com.dotmarketing.util.Logger;
import com.dotmarketing.util.UtilMethods;
import com.liferay.portal.model.User;
import com.liferay.util.StringPool;

import javax.servlet.http.HttpServletRequest;
import java.time.Instant;
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;

/**
* Collects the basic profile information for a collector payload bean.
* Collects the basic profile information for a collector payload bean. It's worth noting that
* <b>ALL</b>ALL data collectors will include the information added by this one.
*
* @author jsanca
* @since Sep 17th, 2024
*/
public class BasicProfileCollector implements Collector {

Expand Down Expand Up @@ -56,6 +60,8 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa
collectorPayloadBean.put(SESSION_ID, sessionId);
collectorPayloadBean.put(SESSION_NEW, sessionNew);

this.setCustomerTelemetryData(collectorPayloadBean);

if (UtilMethods.isSet(collectorContextMap.get(CollectorContextMap.REFERER))) {
collectorPayloadBean.put(REFERER, collectorContextMap.get(CollectorContextMap.REFERER).toString());
}
Expand Down Expand Up @@ -83,13 +89,34 @@ public CollectorPayloadBean collect(final CollectorContextMap collectorContextMa
return collectorPayloadBean;
}

/**
* Sets the customer Telemetry data as part of the information that will be persisted to the
* Content Analytics database.
*
* @param collectorPayloadBean The {@link CollectorPayloadBean} that will be persisted to the
* Content Analytics database.
*/
private void setCustomerTelemetryData(final CollectorPayloadBean collectorPayloadBean) {
final MetricsAPI metricsAPI = APILocator.getMetricsAPI();
try {
final MetricsAPI.Client client = metricsAPI.getClient();
collectorPayloadBean.put(CUSTOMER_NAME, client.getClientName());
collectorPayloadBean.put(CUSTOMER_CATEGORY, client.getCategory());
collectorPayloadBean.put(ENVIRONMENT_NAME, client.getEnvironment());
collectorPayloadBean.put(ENVIRONMENT_VERSION, client.getVersion());
} catch (final DotDataException e) {
Logger.warnAndDebug(BasicProfileCollector.class, String.format("Failed to retrieve customer Telemetry data: " +
"%s", ExceptionUtil.getErrorMessage(e)), e);
}
}

private void setUserInfo(final HttpServletRequest request, final CollectorPayloadBean collectorPayloadBean) {

final User user = WebAPILocator.getUserWebAPI().getUser(request);
if (Objects.nonNull(user)) {

final HashMap<String, String> userObject = new HashMap<>();
userObject.put(ID, user.getUserId().toString());
userObject.put(ID, user.getUserId());
userObject.put(EMAIL, user.getEmailAddress());
collectorPayloadBean.put(USER_OBJECT, userObject);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,9 @@ public interface Collector {
String USER_AGENT = "userAgent";
String UTC_TIME = "utc_time";


String RESPONSE = "action";
String RESPONSE_CODE = "response_code";


String DETAIL_PAGE_URL = "detail_page_url";
String IS_EXPERIMENT_PAGE = "isexperimentpage";
String IS_TARGET_PAGE = "istargetpage";
Expand All @@ -61,6 +59,12 @@ public interface Collector {

String EMAIL = "email";
String USER_OBJECT = "user";

String CUSTOMER_NAME = "customer_name";
String CUSTOMER_CATEGORY = "customer_category";
String ENVIRONMENT_NAME = "environment_name";
String ENVIRONMENT_VERSION = "environment_version";

/**
* Test if the collector should run
* @param collectorContextMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.dotcms.analytics.app.AnalyticsApp;
import com.dotcms.business.SystemTableUpdatedKeyEvent;
import com.dotcms.experiments.business.ConfigExperimentUtil;
import com.dotcms.featureflag.FeatureFlagName;
import com.dotcms.security.apps.AppsAPI;
import com.dotmarketing.beans.Host;
import com.dotmarketing.business.APILocator;
Expand Down Expand Up @@ -31,7 +32,7 @@
public class AnalyticsWebAPIImpl implements AnalyticsWebAPI {

private static final String ANALYTICS_JS_CODE_CLASS_PATH = "/ca/html/analytics_head.html";
private static final String ANALYTICS_AUTO_INJECT_TURNED_ON_KEY = "FEATURE_FLAG_CONTENT_ANALYTICS_AUTO_INJECT";
private static final String ANALYTICS_AUTO_INJECT_TURNED_ON_KEY = FeatureFlagName.FEATURE_FLAG_CONTENT_ANALYTICS_AUTO_INJECT;
private final AtomicBoolean isAutoInjectTurnedOn;
private final HostWebAPI hostWebAPI;
private final AppsAPI appsAPI;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import com.dotcms.contenttype.transform.contenttype.StructureTransformer;
import com.dotcms.contenttype.transform.field.LegacyFieldTransformer;
import com.dotcms.exception.ExceptionUtil;
import com.dotcms.featureflag.FeatureFlagName;
import com.dotcms.notifications.bean.NotificationLevel;
import com.dotcms.publisher.business.DotPublisherException;
import com.dotcms.publisher.business.PublisherAPI;
Expand Down Expand Up @@ -238,7 +239,7 @@
public class ESContentletAPIImpl implements ContentletAPI {

private static Lazy<Boolean> FEATURE_FLAG_DB_UNIQUE_FIELD_VALIDATION = Lazy.of(() ->
Config.getBooleanProperty("FEATURE_FLAG_DB_UNIQUE_FIELD_VALIDATION", false));
Config.getBooleanProperty(FeatureFlagName.FEATURE_FLAG_DB_UNIQUE_FIELD_VALIDATION, false));
private static final String CAN_T_CHANGE_STATE_OF_CHECKED_OUT_CONTENT = "Can't change state of checked out content or where inode is not set. Use Search or Find then use method";
private static final String CANT_GET_LOCK_ON_CONTENT = "Only the CMS Admin or the user who locked the contentlet can lock/unlock it";
private static final String FAILED_TO_DELETE_UNARCHIVED_CONTENT = "Failed to delete unarchived content. Content must be archived first before it can be deleted.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.dotcms.contenttype.model.field.FieldVariable;
import com.dotcms.contenttype.model.type.ContentType;
import com.dotcms.contenttype.transform.contenttype.ContentTypeInternationalization;
import com.dotcms.featureflag.FeatureFlagName;
import com.dotmarketing.exception.DotDataException;
import com.dotmarketing.exception.DotSecurityException;
import com.liferay.portal.model.User;
Expand Down Expand Up @@ -41,7 +42,7 @@
*
*/
public interface FieldAPI {
String FULLSCREEN_FIELD_FEATURE_FLAG = "content.edit.ui.fullscreen";
String FULLSCREEN_FIELD_FEATURE_FLAG = FeatureFlagName.FULLSCREEN_FIELD_FEATURE_FLAG;

/**
* Retrieves the list of the base Fields Types
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dotcms.contenttype.transform.contenttype;

import com.dotcms.api.web.HttpServletRequestThreadLocal;
import com.dotcms.contenttype.model.type.ContentType;
import com.dotcms.rest.api.v1.contenttype.ContentTypeHelper;
import com.dotmarketing.beans.Host;
Expand All @@ -9,6 +10,7 @@
import com.dotmarketing.exception.DotDataException;
import com.dotmarketing.exception.DotSecurityException;
import com.dotmarketing.util.Logger;
import com.dotmarketing.util.PageMode;
import com.dotmarketing.util.UUIDUtil;
import com.dotmarketing.util.UtilMethods;
import com.liferay.portal.model.User;
Expand Down Expand Up @@ -42,8 +44,11 @@ public Optional<String> uriToId()
final var detailPageURI = new URI(detailPage);
var path = detailPageURI.getRawPath();

final boolean respectRoles = null != HttpServletRequestThreadLocal.INSTANCE.getRequest() ?
PageMode.get(HttpServletRequestThreadLocal.INSTANCE.getRequest()).respectAnonPerms : false;

final Host site = APILocator.getHostAPI()
.findByName(detailPageURI.getRawAuthority(), user, false);
.findByName(detailPageURI.getRawAuthority(), user, respectRoles);
if (null == site) {
throw new IllegalArgumentException(
String.format("Site [%s] in detail page URL [%s] not found.",
Expand Down Expand Up @@ -83,8 +88,11 @@ public Optional<String> idToUri() throws DotDataException, DotSecurityException
var detailPageIdentifier = APILocator.getIdentifierAPI().find(detailPage);
if (null != detailPageIdentifier && detailPageIdentifier.exists()) {

final boolean respectRoles = null != HttpServletRequestThreadLocal.INSTANCE.getRequest() ?
PageMode.get(HttpServletRequestThreadLocal.INSTANCE.getRequest()).respectAnonPerms : false;

final Host detailPageSite = APILocator.getHostAPI().find(
detailPageIdentifier.getHostId(), user, false);
detailPageIdentifier.getHostId(), user, respectRoles);

// Building the detail page URI
var detailPageURL = String.format(
Expand Down
Loading

0 comments on commit b8ff27e

Please sign in to comment.