From 4a317603fed7a850c91d9f9085d562b21fc85e40 Mon Sep 17 00:00:00 2001 From: Shrikant Sharat Kandula Date: Tue, 28 May 2024 09:50:12 +0530 Subject: [PATCH] chore: Remove unused `eventData` (#33730) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For action creation, client sends this in `eventData` field of the request body: ![shot-2024-05-26-04-50-46](https://github.com/appsmithorg/appsmith/assets/120119/b876b27f-47ec-4a00-8598-33cb92120c49) But the class defined for `eventData` is this: ![shot-2024-05-26-04-51-03](https://github.com/appsmithorg/appsmith/assets/120119/18bf46b7-597a-4b2f-8355-1b8fad30e4ce) Clearly isn't used, or working. /test sanity datasource ⚠️ Note that `eventData` is actually used in the analytics data sent by client, and that's not being removed here. We're only removing the unused server-side support here. > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: 30e8f455a310b3a25cf80cb6fc21da704ac0d411 > Cypress dashboard url: Click here! --- app/client/src/api/ActionAPI.tsx | 2 +- .../external/models/AnalyticsInfo.java | 20 --------- .../external/models/ce/ActionCE_DTO.java | 7 ---- .../services/ce/ActionServiceCE_Test.java | 41 ------------------- 4 files changed, 1 insertion(+), 69 deletions(-) delete mode 100644 app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/AnalyticsInfo.java diff --git a/app/client/src/api/ActionAPI.tsx b/app/client/src/api/ActionAPI.tsx index 32cc3351c4..6d98cf6bef 100644 --- a/app/client/src/api/ActionAPI.tsx +++ b/app/client/src/api/ActionAPI.tsx @@ -132,7 +132,7 @@ class ActionAPI extends API { static async createAction( apiConfig: Partial, ): Promise> { - return API.post(ActionAPI.url, apiConfig); + return API.post(ActionAPI.url, { ...apiConfig, eventData: undefined }); } static async fetchActions( diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/AnalyticsInfo.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/AnalyticsInfo.java deleted file mode 100644 index f942844d93..0000000000 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/AnalyticsInfo.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.appsmith.external.models; - -import com.appsmith.external.views.FromRequest; -import com.appsmith.external.views.Views; -import com.fasterxml.jackson.annotation.JsonView; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.ToString; - -import java.util.Map; - -@Getter -@Setter -@ToString -@NoArgsConstructor -public class AnalyticsInfo { - @JsonView({Views.Public.class, FromRequest.class}) - private Map analyticsData; -} diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ce/ActionCE_DTO.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ce/ActionCE_DTO.java index dd9b6ca66a..a99034a694 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ce/ActionCE_DTO.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ce/ActionCE_DTO.java @@ -6,7 +6,6 @@ import com.appsmith.external.dtos.LayoutExecutableUpdateDTO; import com.appsmith.external.exceptions.ErrorDTO; import com.appsmith.external.helpers.Identifiable; import com.appsmith.external.models.ActionConfiguration; -import com.appsmith.external.models.AnalyticsInfo; import com.appsmith.external.models.CreatorContextType; import com.appsmith.external.models.Datasource; import com.appsmith.external.models.DefaultResources; @@ -156,11 +155,6 @@ public class ActionCE_DTO implements Identifiable, Executable { @JsonView(Views.Internal.class) DefaultResources defaultResources; - // This field will be used to store analytics data related to this specific domain object. It's been introduced in - // order to track success metrics of modules. Learn more on GitHub issue#24734 - @JsonView({Views.Public.class, FromRequest.class}) - AnalyticsInfo eventData; - @JsonView(Views.Internal.class) protected Instant createdAt; @@ -211,7 +205,6 @@ public class ActionCE_DTO implements Identifiable, Executable { public void sanitiseToExportDBObject() { this.resetTransientFields(); - this.setEventData(null); this.setDefaultResources(null); this.setUpdatedAt(null); this.setCacheResponse(null); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ActionServiceCE_Test.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ActionServiceCE_Test.java index 62a60a0d7f..8f9fd552e7 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ActionServiceCE_Test.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ActionServiceCE_Test.java @@ -6,7 +6,6 @@ import com.appsmith.external.helpers.AppsmithEventContext; import com.appsmith.external.helpers.AppsmithEventContextType; import com.appsmith.external.models.ActionConfiguration; import com.appsmith.external.models.ActionDTO; -import com.appsmith.external.models.AnalyticsInfo; import com.appsmith.external.models.Datasource; import com.appsmith.external.models.DatasourceConfiguration; import com.appsmith.external.models.DatasourceStorageDTO; @@ -1567,44 +1566,4 @@ public class ActionServiceCE_Test { assertThat(savedAction.getCreatedAt()).isNotNull(); assertThat(savedAction.getUpdatedAt()).isNotNull(); } - - @Test - @WithUserDetails(value = "api_user") - public void createCopyActionWithAnalyticsData_validateAnalyticsDataPersistsInResponse() { - Mockito.when(pluginExecutorHelper.getPluginExecutor(Mockito.any())) - .thenReturn(Mono.just(new MockPluginExecutor())); - - ActionDTO action = new ActionDTO(); - action.setName("CopyOfQuery1"); - action.setPageId(testPage.getId()); - action.setDatasource(datasource); - ActionConfiguration actionConfiguration = new ActionConfiguration(); - actionConfiguration.setPluginSpecifiedTemplates(List.of(new Property(null, true))); - - AnalyticsInfo analyticsInfo = new AnalyticsInfo(); - Map analyticsData = new HashMap<>(); - String keyOriginalActionId = "originalActionId"; - String valueOriginalActionId = "xyz"; - analyticsData.put(keyOriginalActionId, valueOriginalActionId); - analyticsInfo.setAnalyticsData(analyticsData); - action.setEventData(analyticsInfo); - - action.setActionConfiguration(actionConfiguration); - - Mono actionMono = - Mono.just(action).flatMap(action1 -> layoutActionService.createSingleAction(action1, Boolean.FALSE)); - StepVerifier.create(actionMono) - .assertNext(createdAction -> { - assertThat(createdAction.getId()).isNotEmpty(); - assertThat(createdAction.getName()).isEqualTo(action.getName()); - assertThat(createdAction.getIsValid()).isTrue(); - assertThat(createdAction - .getEventData() - .getAnalyticsData() - .get(keyOriginalActionId) - .toString() - .equalsIgnoreCase(valueOriginalActionId)); - }) - .verifyComplete(); - } }