-
Notifications
You must be signed in to change notification settings - Fork 4.7k
chore: analytic events added for reactive behaviour change #40917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sneha122
merged 9 commits into
release
from
chore/reactive-actions-analytic-backend-events
Jun 17, 2025
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3c16c33
chore: analytic events added for reactive behaviour change
8e6cfec
code review changes
b4fdd20
fixed failing test cases
35fd080
fix: added more properties to the event
595d130
fix: test failure issue fixes
6dfc47f
Merge branch 'release' into chore/reactive-actions-analytic-backend-e…
db8f509
updated events with more properties
5863bec
fix: migrated changes from EE to CE for events and code split
b347ce2
Merge branch 'release' into chore/reactive-actions-analytic-backend-e…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...smith-server/src/main/java/com/appsmith/server/domains/RunBehaviourAnalyticsMetadata.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package com.appsmith.server.domains; | ||
|
|
||
| import com.appsmith.external.models.ActionDTO; | ||
| import com.appsmith.external.models.CreatorContextType; | ||
| import com.appsmith.external.models.RunBehaviourEnum; | ||
| import com.appsmith.server.enums.RunBehaviourUpdateSource; | ||
| import lombok.Builder; | ||
| import lombok.Data; | ||
|
|
||
| @Data | ||
| @Builder | ||
| public class RunBehaviourAnalyticsMetadata { | ||
| private ActionDTO actionDTO; | ||
| private RunBehaviourEnum oldRunBehaviour; | ||
| private CreatorContextType creatorContextType; | ||
| private RunBehaviourUpdateSource wasChangedBy; | ||
| private boolean isActionPartOfModuleInstance; | ||
| } |
6 changes: 6 additions & 0 deletions
6
...ver/appsmith-server/src/main/java/com/appsmith/server/enums/RunBehaviourUpdateSource.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package com.appsmith.server.enums; | ||
|
|
||
| public enum RunBehaviourUpdateSource { | ||
| SYSTEM, | ||
| USER | ||
| } |
106 changes: 106 additions & 0 deletions
106
...appsmith-server/src/main/java/com/appsmith/server/helpers/RunBehaviourAnalyticsUtils.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| package com.appsmith.server.helpers; | ||
|
|
||
| import com.appsmith.external.constants.AnalyticsEvents; | ||
| import com.appsmith.external.models.ActionDTO; | ||
| import com.appsmith.external.models.CreatorContextType; | ||
| import com.appsmith.external.models.RunBehaviourEnum; | ||
| import com.appsmith.server.applications.base.ApplicationService; | ||
| import com.appsmith.server.constants.FieldName; | ||
| import com.appsmith.server.domains.Application; | ||
| import com.appsmith.server.domains.ApplicationMode; | ||
| import com.appsmith.server.domains.RunBehaviourAnalyticsMetadata; | ||
| import com.appsmith.server.enums.RunBehaviourUpdateSource; | ||
| import com.appsmith.server.services.AnalyticsService; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.apache.commons.lang3.ObjectUtils; | ||
| import org.springframework.stereotype.Component; | ||
| import reactor.core.publisher.Mono; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| import static java.lang.Boolean.TRUE; | ||
|
|
||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class RunBehaviourAnalyticsUtils { | ||
|
|
||
| private final AnalyticsService analyticsService; | ||
| private final ApplicationService applicationService; | ||
|
|
||
| public Mono<Void> sendRunBehaviourChangedAnalytics(RunBehaviourAnalyticsMetadata params) { | ||
| ActionDTO actionDTO = params.getActionDTO(); | ||
| RunBehaviourEnum oldRunBehaviour = params.getOldRunBehaviour(); | ||
| CreatorContextType creatorType = params.getCreatorContextType(); | ||
| RunBehaviourUpdateSource wasChangedBy = params.getWasChangedBy(); | ||
| boolean isActionPartOfModuleInstance = params.isActionPartOfModuleInstance(); | ||
|
|
||
| return Mono.justOrEmpty(actionDTO.getApplicationId()) | ||
| .flatMap(applicationService::findById) | ||
| .defaultIfEmpty(new Application()) | ||
| .flatMap(application -> { | ||
| Map<String, Object> data = new HashMap<>(); | ||
| data.put("actionId", ObjectUtils.defaultIfNull(actionDTO.getId(), "")); | ||
| data.put("name", ObjectUtils.defaultIfNull(actionDTO.getName(), "")); | ||
| data.put("pageId", ObjectUtils.defaultIfNull(actionDTO.getPageId(), "")); | ||
| data.put("applicationId", ObjectUtils.defaultIfNull(actionDTO.getApplicationId(), "")); | ||
| data.put("pluginId", ObjectUtils.defaultIfNull(actionDTO.getPluginId(), "")); | ||
| data.put("pluginName", ObjectUtils.defaultIfNull(actionDTO.getPluginName(), "")); | ||
| data.put("createdAt", ObjectUtils.defaultIfNull(actionDTO.getCreatedAt(), "")); | ||
| data.put("oldRunBehaviour", ObjectUtils.defaultIfNull(oldRunBehaviour, "")); | ||
| data.put("newRunBehaviour", ObjectUtils.defaultIfNull(actionDTO.getRunBehaviour(), "")); | ||
| data.put("pluginType", ObjectUtils.defaultIfNull(actionDTO.getPluginType(), "")); | ||
| data.put("actionConfiguration", ObjectUtils.defaultIfNull(actionDTO.getActionConfiguration(), "")); | ||
|
|
||
| // Handle potential null createdAt for formatting | ||
| String actionCreated = actionDTO.getCreatedAt() != null | ||
| ? DateUtils.ISO_FORMATTER.format(actionDTO.getCreatedAt()) | ||
| : ""; | ||
|
sneha122 marked this conversation as resolved.
|
||
| data.put("actionCreated", actionCreated); | ||
|
|
||
| final String appMode = TRUE.equals(application.getViewMode()) | ||
| ? ApplicationMode.PUBLISHED.toString() | ||
| : ApplicationMode.EDIT.toString(); | ||
|
|
||
| data.put("workspaceId", ObjectUtils.defaultIfNull(application.getWorkspaceId(), "")); | ||
| data.put(FieldName.APP_MODE, appMode); | ||
| data.put("appName", ObjectUtils.defaultIfNull(application.getName(), "")); | ||
| data.put("isExampleApp", ObjectUtils.defaultIfNull(application.isAppIsExample(), false)); | ||
|
|
||
| // Handle datasource info with null checks | ||
| Map<String, Object> datasourceInfo = new HashMap<>(); | ||
| if (actionDTO.getDatasource() != null) { | ||
| datasourceInfo.put( | ||
| "name", | ||
| ObjectUtils.defaultIfNull( | ||
| actionDTO.getDatasource().getName(), "")); | ||
| datasourceInfo.put( | ||
| "dsIsMock", | ||
| ObjectUtils.defaultIfNull( | ||
| actionDTO.getDatasource().getIsMock(), false)); | ||
| datasourceInfo.put( | ||
| "dsIsTemplate", | ||
| ObjectUtils.defaultIfNull( | ||
| actionDTO.getDatasource().getIsTemplate(), false)); | ||
| datasourceInfo.put( | ||
| "dsId", | ||
| ObjectUtils.defaultIfNull( | ||
| actionDTO.getDatasource().getId(), "")); | ||
| } else { | ||
| datasourceInfo.put("name", ""); | ||
| datasourceInfo.put("dsIsMock", false); | ||
| datasourceInfo.put("dsIsTemplate", false); | ||
| datasourceInfo.put("dsId", ""); | ||
| } | ||
| data.put("datasource", datasourceInfo); | ||
|
|
||
| data.put("wasChangedBy", ObjectUtils.defaultIfNull(wasChangedBy, "")); | ||
| data.put("creatorContextType", ObjectUtils.defaultIfNull(creatorType, CreatorContextType.PAGE)); | ||
| data.put("isActionPartOfModuleInstance", isActionPartOfModuleInstance); | ||
|
|
||
| return analyticsService | ||
| .sendObjectEvent(AnalyticsEvents.ACTION_RUN_BEHAVIOUR_CHANGED, actionDTO, data) | ||
| .then(); // Return Mono<Void> for fire-and-forget | ||
| }); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.