Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public Mono<Void> sendEvent(String event, String userId, Map<String, ?> 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<String, Object> entry : analyticsProperties.entrySet()) {
if (userId.equals(entry.getValue())) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -38,7 +39,8 @@ public ActionExecutionSolutionImpl(
DatasourceStorageService datasourceStorageService,
EnvironmentPermission environmentPermission,
ConfigService configService,
TenantService tenantService) {
TenantService tenantService,
CommonConfig commonConfig) {
super(
newActionService,
actionPermission,
Expand All @@ -57,6 +59,7 @@ public ActionExecutionSolutionImpl(
datasourceStorageService,
environmentPermission,
configService,
tenantService);
tenantService,
commonConfig);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 =
Expand All @@ -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;
Expand All @@ -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));
Expand Down Expand Up @@ -789,6 +795,14 @@ protected Mono<ActionExecutionResult> 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 : {}",
Expand All @@ -807,6 +821,7 @@ protected Mono<ActionExecutionResult> getActionExecutionResult(
executeActionDTO, actionDTO, datasourceStorage, plugin, pluginExecutor)
.timeout(Duration.ofMillis(timeoutDuration)));

ActionConfiguration finalRawActionConfiguration = rawActionConfiguration;
return actionExecutionResultMono
.onErrorMap(executionExceptionMapper(actionDTO, timeoutDuration))
.onErrorResume(executionExceptionHandler(actionDTO))
Expand All @@ -824,7 +839,12 @@ protected Mono<ActionExecutionResult> getActionExecutionResult(
timeElapsed);

return sendExecuteAnalyticsEvent(
actionDTO, datasourceStorage, executeActionDTO, result, timeElapsed)
actionDTO,
datasourceStorage,
executeActionDTO,
result,
timeElapsed,
finalRawActionConfiguration)
.thenReturn(result);
});
});
Expand Down Expand Up @@ -925,7 +945,8 @@ private Mono<ActionExecutionRequest> sendExecuteAnalyticsEvent(
DatasourceStorage datasourceStorage,
ExecuteActionDTO executeActionDto,
ActionExecutionResult actionExecutionResult,
Long timeElapsed) {
Long timeElapsed,
ActionConfiguration rawActionConfiguration) {

if (!isSendExecuteAnalyticsEvent()) {
return Mono.empty();
Expand Down Expand Up @@ -1113,8 +1134,17 @@ private Mono<ActionExecutionRequest> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -128,6 +129,9 @@ class ActionExecutionSolutionCEImplTest {
@SpyBean
TenantService tenantService;

@SpyBean
CommonConfig commonConfig;

@Autowired
EnvironmentPermission environmentPermission;

Expand Down Expand Up @@ -157,7 +161,8 @@ public void beforeEach() {
datasourceStorageService,
environmentPermission,
configService,
tenantService);
tenantService,
commonConfig);

ObservationRegistry.ObservationConfig mockObservationConfig =
Mockito.mock(ObservationRegistry.ObservationConfig.class);
Expand Down