diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/constants/ce/FieldNameCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/constants/ce/FieldNameCE.java index ced4d5619e23..4f091e9cb59c 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/constants/ce/FieldNameCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/constants/ce/FieldNameCE.java @@ -151,6 +151,9 @@ public class FieldNameCE { public static final String ACTION_EXECUTION_REQUEST_PARAMS_COUNT = "actionExecutionRequestParamsCount"; public static final String ACTION_EXECUTION_RESULT = "actionExecutionResult"; public static final String ACTION_EXECUTION_TIME = "actionExecutionTime"; + public static final String ACTION_EXECUTION_REQUEST_PARAMS_VALUE_MAP = "actionExecutionRequestParamsValueMap"; + public static final String ACTION_EXECUTION_INVERT_PARAMETER_MAP = "actionExecutionInvertParameterMap"; + public static final String ACTION_CONFIGURATION = "actionConfiguration"; public static final String WEBSITE = "website"; public static final String TEMPLATE_APPLICATION_NAME = "templateAppName"; public static final String SOURCE = "source"; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/AnalyticsServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/AnalyticsServiceCEImpl.java index 4eb0807948e7..8c41a2fc8514 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/AnalyticsServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/AnalyticsServiceCEImpl.java @@ -206,6 +206,7 @@ public Mono sendEvent(String event, String userId, Map properti // Hash usernames at all places for self-hosted instance if (shouldHashUserId(event, userId, hashUserId, commonConfig.isCloudHosting())) { final String hashedUserId = hash(userId); + // Remove request key, if it's self-hosted as it contains user's evaluated params analyticsProperties.remove("request"); for (final Map.Entry entry : analyticsProperties.entrySet()) { if (userId.equals(entry.getValue())) { diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ActionExecutionSolutionImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ActionExecutionSolutionImpl.java index 821e6717d81d..de3ae719512c 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ActionExecutionSolutionImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ActionExecutionSolutionImpl.java @@ -1,6 +1,7 @@ package com.appsmith.server.solutions; import com.appsmith.server.applications.base.ApplicationService; +import com.appsmith.server.configurations.CommonConfig; import com.appsmith.server.datasources.base.DatasourceService; import com.appsmith.server.datasourcestorages.base.DatasourceStorageService; import com.appsmith.server.helpers.PluginExecutorHelper; @@ -38,7 +39,8 @@ public ActionExecutionSolutionImpl( DatasourceStorageService datasourceStorageService, EnvironmentPermission environmentPermission, ConfigService configService, - TenantService tenantService) { + TenantService tenantService, + CommonConfig commonConfig) { super( newActionService, actionPermission, @@ -57,6 +59,7 @@ public ActionExecutionSolutionImpl( datasourceStorageService, environmentPermission, configService, - tenantService); + tenantService, + commonConfig); } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java index 6b31319f3423..5f62d3371745 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java @@ -8,6 +8,7 @@ import com.appsmith.external.exceptions.pluginExceptions.AppsmithPluginException; import com.appsmith.external.exceptions.pluginExceptions.StaleConnectionException; import com.appsmith.external.helpers.MustacheHelper; +import com.appsmith.external.models.ActionConfiguration; import com.appsmith.external.models.ActionDTO; import com.appsmith.external.models.ActionExecutionRequest; import com.appsmith.external.models.ActionExecutionResult; @@ -19,6 +20,7 @@ import com.appsmith.external.plugins.PluginExecutor; import com.appsmith.server.acl.AclPermission; import com.appsmith.server.applications.base.ApplicationService; +import com.appsmith.server.configurations.CommonConfig; import com.appsmith.server.constants.Constraint; import com.appsmith.server.constants.FieldName; import com.appsmith.server.datasources.base.DatasourceService; @@ -51,6 +53,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.Gson; import io.micrometer.observation.ObservationRegistry; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.ArrayUtils; @@ -117,6 +120,7 @@ public class ActionExecutionSolutionCEImpl implements ActionExecutionSolutionCE private final EnvironmentPermission environmentPermission; private final ConfigService configService; private final TenantService tenantService; + private final CommonConfig commonConfig; static final String PARAM_KEY_REGEX = "^k\\d+$"; static final String BLOB_KEY_REGEX = @@ -143,7 +147,8 @@ public ActionExecutionSolutionCEImpl( DatasourceStorageService datasourceStorageService, EnvironmentPermission environmentPermission, ConfigService configService, - TenantService tenantService) { + TenantService tenantService, + CommonConfig commonConfig) { this.newActionService = newActionService; this.actionPermission = actionPermission; this.observationRegistry = observationRegistry; @@ -162,6 +167,7 @@ public ActionExecutionSolutionCEImpl( this.environmentPermission = environmentPermission; this.configService = configService; this.tenantService = tenantService; + this.commonConfig = commonConfig; this.patternList.add(Pattern.compile(PARAM_KEY_REGEX)); this.patternList.add(Pattern.compile(BLOB_KEY_REGEX)); @@ -789,6 +795,14 @@ protected Mono getActionExecutionResult( final DatasourceStorage datasourceStorage = tuple.getT2(); final PluginExecutor pluginExecutor = tuple.getT3(); final Plugin plugin = tuple.getT4(); + // This is to return the raw user query including bindings + ActionConfiguration rawActionConfiguration = null; + if (actionDTO != null && actionDTO.getActionConfiguration() != null) { + // deep copying the actionConfiguration to avoid any changes in the original object + Gson gson = commonConfig.gsonInstance(); + rawActionConfiguration = gson.fromJson( + gson.toJson(actionDTO.getActionConfiguration()), ActionConfiguration.class); + } log.debug( "[{}]Execute Action called in Page {}, for action id : {} action name : {}", @@ -807,6 +821,7 @@ protected Mono getActionExecutionResult( executeActionDTO, actionDTO, datasourceStorage, plugin, pluginExecutor) .timeout(Duration.ofMillis(timeoutDuration))); + ActionConfiguration finalRawActionConfiguration = rawActionConfiguration; return actionExecutionResultMono .onErrorMap(executionExceptionMapper(actionDTO, timeoutDuration)) .onErrorResume(executionExceptionHandler(actionDTO)) @@ -824,7 +839,12 @@ protected Mono getActionExecutionResult( timeElapsed); return sendExecuteAnalyticsEvent( - actionDTO, datasourceStorage, executeActionDTO, result, timeElapsed) + actionDTO, + datasourceStorage, + executeActionDTO, + result, + timeElapsed, + finalRawActionConfiguration) .thenReturn(result); }); }); @@ -925,7 +945,8 @@ private Mono sendExecuteAnalyticsEvent( DatasourceStorage datasourceStorage, ExecuteActionDTO executeActionDto, ActionExecutionResult actionExecutionResult, - Long timeElapsed) { + Long timeElapsed, + ActionConfiguration rawActionConfiguration) { if (!isSendExecuteAnalyticsEvent()) { return Mono.empty(); @@ -1113,8 +1134,17 @@ private Mono sendExecuteAnalyticsEvent( } else { eventData.put(FieldName.ACTION_EXECUTION_REQUEST_PARAMS, REDACTED_DATA); } + if (executeActionDto != null) { + if (commonConfig.isCloudHosting()) { + // Only send this parameter if cloud hosting is true as it contains user's evaluated params + data.put(FieldName.ACTION_EXECUTION_REQUEST_PARAMS_VALUE_MAP, executeActionDto.getParams()); + } + data.put( + FieldName.ACTION_EXECUTION_INVERT_PARAMETER_MAP, + executeActionDto.getInvertParameterMap()); + } + data.put(FieldName.ACTION_CONFIGURATION, rawActionConfiguration); data.put(FieldName.EVENT_DATA, eventData); - return analyticsService .sendObjectEvent(AnalyticsEvents.EXECUTE_ACTION, actionDTO, data) .thenReturn(request); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImplTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImplTest.java index 4f0a20df1a41..9aac576ae4bd 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImplTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImplTest.java @@ -8,6 +8,7 @@ import com.appsmith.external.models.Datasource; import com.appsmith.external.models.Param; import com.appsmith.server.applications.base.ApplicationService; +import com.appsmith.server.configurations.CommonConfig; import com.appsmith.server.constants.FieldName; import com.appsmith.server.datasources.base.DatasourceService; import com.appsmith.server.datasourcestorages.base.DatasourceStorageService; @@ -128,6 +129,9 @@ class ActionExecutionSolutionCEImplTest { @SpyBean TenantService tenantService; + @SpyBean + CommonConfig commonConfig; + @Autowired EnvironmentPermission environmentPermission; @@ -157,7 +161,8 @@ public void beforeEach() { datasourceStorageService, environmentPermission, configService, - tenantService); + tenantService, + commonConfig); ObservationRegistry.ObservationConfig mockObservationConfig = Mockito.mock(ObservationRegistry.ObservationConfig.class);