chore: Server Side Event for running action (#23379)

## Description
Server Side Event to capture run action. Determines if action is user
initiated or not.

Fixes #23127

#### Type of change
- Chore (housekeeping or task changes that don't impact user perception)

## Testing
#### How Has This Been Tested?
> Please describe the tests that you ran to verify your changes. Also
list any relevant details for your test configuration.
> Delete anything that is not relevant
- [ ] Manual
- [ ] Jest
- [ ] Cypress


## Checklist:
#### Dev activity
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag

---------

Co-authored-by: “sneha122” <“sneha@appsmith.com”>
This commit is contained in:
Sanveer Singh Osahan 2023-05-16 18:40:52 +05:30 committed by GitHub
parent fdb1f3d489
commit 504436c998
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 1 deletions

View File

@ -56,6 +56,7 @@ export interface ExecuteActionRequest extends APIRequest {
| Record<string, string>
| Record<string, Record<string, Array<string>>>
>;
analyticsProperties?: Record<string, boolean>;
}
export type ExecuteActionResponse = ApiResponse & {

View File

@ -716,6 +716,8 @@ function* runActionSaga(
executePluginActionSaga,
id,
paginationField,
{},
true,
);
payload = executePluginActionResponse.payload;
isError = executePluginActionResponse.isError;
@ -1100,6 +1102,7 @@ function* executePluginActionSaga(
actionOrActionId: PageAction | string,
paginationField?: PaginationField,
params?: Record<string, unknown>,
isUserInitiated?: boolean,
) {
let pluginAction;
let actionId;
@ -1151,6 +1154,9 @@ function* executePluginActionSaga(
actionId: actionId,
viewMode: appMode === APP_MODE.PUBLISHED,
paramProperties: {},
analyticsProperties: {
isUserInitiated: !!isUserInitiated,
},
};
if (paginationField) {

View File

@ -41,6 +41,8 @@ public class ExecuteActionDTO {
Map<String, String> invertParameterMap; // e.g. {"k1":"Text1.text","k2":"Table1.data", "k3": "Api1.data"}
Map<String, Object> analyticsProperties;
@JsonIgnore
long totalReadableByteCount;

View File

@ -308,6 +308,7 @@ public class ActionExecutionSolutionCEImpl implements ActionExecutionSolutionCE
dto.setViewMode(executeActionDTO.getViewMode());
dto.setParamProperties(executeActionDTO.getParamProperties());
dto.setPaginationField(executeActionDTO.getPaginationField());
dto.setAnalyticsProperties(executeActionDTO.getAnalyticsProperties());
return Mono.empty();
});
}
@ -1043,6 +1044,10 @@ public class ActionExecutionSolutionCEImpl implements ActionExecutionSolutionCE
paramsList = new ArrayList<>();
}
List<String> executionParams = paramsList.stream().map(param -> param.getValue()).collect(Collectors.toList());
Map<String, Object> analyticsProperties = executeActionDto.getAnalyticsProperties();
if (analyticsProperties == null) {
analyticsProperties = new HashMap<>();
}
data.putAll(Map.of(
"request", request,
@ -1052,7 +1057,8 @@ public class ActionExecutionSolutionCEImpl implements ActionExecutionSolutionCE
"statusCode", ObjectUtils.defaultIfNull(actionExecutionResult.getStatusCode(), ""),
"timeElapsed", timeElapsed,
"actionCreated", DateUtils.ISO_FORMATTER.format(action.getCreatedAt()),
"actionId", ObjectUtils.defaultIfNull(action.getId(), "")
"actionId", ObjectUtils.defaultIfNull(action.getId(), ""),
"isUserInitiated", ObjectUtils.defaultIfNull(analyticsProperties.get("isUserInitiated"), false)
));
data.putAll(Map.of(
FieldName.ACTION_EXECUTION_REQUEST_PARAMS_SIZE, executeActionDto.getTotalReadableByteCount(),