Skip to content

chore: analytic events added for reactive behaviour change#40917

Merged
sneha122 merged 9 commits intoreleasefrom
chore/reactive-actions-analytic-backend-events
Jun 17, 2025
Merged

chore: analytic events added for reactive behaviour change#40917
sneha122 merged 9 commits intoreleasefrom
chore/reactive-actions-analytic-backend-events

Conversation

@sneha122
Copy link
Contributor

@sneha122 sneha122 commented Jun 11, 2025

Description

This PR adds / updates following analytic events for reactivity run behaviour changes either by system or by user:

Metric Event Name Type
Run behavior change tracking action_RUN_BEHAVIOUR_CHANGED New Event
Run behavior context on action execution execute_ACTION_TRIGGERED -> runBehavior (property) New Property in existing events

Fixes #Issue Number
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

/ok-to-test tags="@tag.Sanity, @tag.Widget"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/15700973404
Commit: b347ce2
Cypress dashboard.
Tags: @tag.Sanity, @tag.Widget
Spec:


Tue, 17 Jun 2025 07:46:20 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features
    • Added analytics tracking for changes in the run behavior of actions and executables, capturing detailed information about each change.
  • Enhancements
    • Analytics events now include the run behavior configuration when actions are executed.
  • Chores
    • Updated internal constants to support new analytics event types and fields.
    • Integrated new dependencies to support analytics reporting for run behavior changes.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 11, 2025

Walkthrough

This update introduces analytics tracking for changes in the "run behaviour" of actions and executables. New constants and event types are added, analytics events are sent when run behaviour changes both on user action and system updates, and relevant data is included in analytics payloads. Constructor dependencies are updated to support the analytics service.

Changes

File(s) Summary
.../AnalyticsEvents.java Added new enum constant ACTION_RUN_BEHAVIOUR_CHANGED for analytics event tracking.
.../FieldNameCE.java Added constant ACTION_CONFIGURATION_RUN_BEHAVIOUR.
.../OnLoadExecutablesUtilCEImpl.java Added analytics reporting for run behaviour changes in executables during system updates; added sendRunBehaviourChangedAnalytics method and related dependencies.
.../OnLoadExecutablesUtilImpl.java Updated constructor to include AnalyticsService, ApplicationService, and RunBehaviourAnalyticsUtils dependencies.
.../LayoutActionServiceCEImpl.java Enhanced setRunBehaviour to send analytics event after user-initiated run behaviour change with detailed metadata; added isRegularAction method and new dependencies.
.../ActionExecutionSolutionCEImpl.java Included run behaviour property in analytics event data.
.../OnLoadExecutablesUtilCEImplTest.java Added mocks for AnalyticsService, ApplicationService, and RunBehaviourAnalyticsUtils; stubbed analytics calls in tests.
.../LayoutActionServiceImpl.java Updated constructor to include ApplicationService and RunBehaviourAnalyticsUtils dependencies and pass them to superclass.
.../RunBehaviourAnalyticsMetadata.java Added new data class encapsulating run behaviour analytics metadata.
.../RunBehaviourUpdateSource.java Added new enum defining run behaviour update sources: SYSTEM and USER.
.../RunBehaviourAnalyticsUtils.java Added utility class to send detailed run behaviour changed analytics events asynchronously.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant LayoutActionService
    participant AnalyticsService

    User->>LayoutActionService: setRunBehaviour(actionId, newRunBehaviour)
    LayoutActionService->>LayoutActionService: Save oldRunBehaviour
    LayoutActionService->>LayoutActionService: Update action with newRunBehaviour
    LayoutActionService->>AnalyticsService: sendRunBehaviourChangedAnalytics(action, oldRunBehaviour, userInitiated=true)
    AnalyticsService-->>LayoutActionService: Event sent
    LayoutActionService-->>User: Return updated action
Loading
sequenceDiagram
    participant System
    participant OnLoadExecutablesUtil
    participant AnalyticsService

    System->>OnLoadExecutablesUtil: updateExecutablesRunBehaviour(list)
    OnLoadExecutablesUtil->>OnLoadExecutablesUtil: Store oldRunBehaviour for each executable
    OnLoadExecutablesUtil->>OnLoadExecutablesUtil: Update runBehaviour
    OnLoadExecutablesUtil->>AnalyticsService: sendRunBehaviourChangedAnalytics(executable, oldRunBehaviour, userInitiated=false)
    AnalyticsService-->>OnLoadExecutablesUtil: Event sent
    OnLoadExecutablesUtil-->>System: Return updated executables
Loading

Possibly related PRs

Suggested labels

Enhancement, Core Query Execution, Integrations Product, Integrations Pod

Suggested reviewers

  • subrata71

Poem

When actions change the way they run,
Analytics now tracks each one.
With enums, constants, and a map or two,
We log the old, we log the new.
Events dispatched, the data flows—
Observing run behaviour as it grows! 🚦

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@sneha122 sneha122 requested a review from subrata71 June 11, 2025 08:35
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Jun 11, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (2)
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutActionServiceCEImpl.java (1)

346-363: Raw Map type – add generics

Map data = new HashMap<>(); loses type safety and triggers unchecked warnings.
Use Map<String, Object>.

- Map<String, Object> data = new HashMap<>();
+ Map<String, Object> data = new HashMap<>();
app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java (1)

313-314: Minor: oldRunBehaviourMap can be avoided

Since executable is mutable, capturing executable.getRunBehaviour() into a local variable right before the update (and passing it downstream via Tuple2 or a POJO) removes the need for an external map and avoids key-mismatch bugs.

Not blocking—just food for thought.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between befe9ff and 3c16c33.

📒 Files selected for processing (6)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/AnalyticsEvents.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/constants/ce/FieldNameCE.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java (6 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilImpl.java (2 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutActionServiceCEImpl.java (3 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: server-spotless / spotless-check
  • GitHub Check: server-unit-tests / server-unit-tests
🔇 Additional comments (3)
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/AnalyticsEvents.java (1)

27-28: Event name spelling & placement look okay

The new constant is consistent with the existing "*_RUN_*" naming pattern and passes a string value, so the enum won’t default-lower-case it inadvertently.
No action needed.

app/server/appsmith-server/src/main/java/com/appsmith/server/constants/ce/FieldNameCE.java (1)

212-214: Constant added correctly

The new key fits the existing constant style.
No further remarks.

app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilImpl.java (1)

24-34: Constructor update LGTM

AnalyticsService is threaded through correctly and forwarded to the superclass.
No issues spotted.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
app/server/appsmith-server/src/test/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImplTest.java (2)

63-76: Avoid per-test boilerplate – centralise AnalyticsService stubbing in setUp()

Every test repeats the same doAnswer(...).when(onLoadExecutablesUtilCE).sendRunBehaviourChangedAnalytics(...) block.
Moving this stub to the common setUp() method (or a private helper) keeps individual test bodies focused on their intent and reduces maintenance overhead.

@BeforeEach
public void setUp() {
     onLoadExecutablesUtilCE = spy(new OnLoadExecutablesUtilCEImpl(
         astService,
         objectMapper,
         executableOnLoadService,
         observationRegistry,
         observationHelper,
         featureFlagService,
         analyticsService));

+    // Stub once for all tests
+    doAnswer(inv -> Mono.just(inv.getArgument(0)))
+        .when(onLoadExecutablesUtilCE)
+        .sendRunBehaviourChangedAnalytics(any(Executable.class), any(RunBehaviourEnum.class));

     ObservationRegistry.ObservationConfig mockObservationConfig =
         Mockito.mock(ObservationRegistry.ObservationConfig.class);
     Mockito.when(observationRegistry.observationConfig()).thenReturn(mockObservationConfig);
}

108-111: Duplicate stubbing blocks now redundant

Once the common stub is moved to setUp(), these duplicated doAnswer blocks can be deleted, trimming ~30 lines and making the individual tests clearer.

Also applies to: 152-155, 199-202, 273-276, 313-316, 409-412, 468-471

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8e6cfec and b4fdd20.

📒 Files selected for processing (2)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java (6 hunks)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImplTest.java (11 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: server-unit-tests / server-unit-tests
  • GitHub Check: server-spotless / spotless-check

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/services/LayoutActionServiceImpl.java (1)

20-44: Constructor now takes 12 services – consider refactor for readability.

The ballooning parameter list signals high coupling and hurts testability. A parameter object, builder, or Spring’s @RequiredArgsConstructor with dedicated “context” holder would simplify this signature.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b4fdd20 and 35fd080.

📒 Files selected for processing (4)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java (6 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilImpl.java (2 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/LayoutActionServiceImpl.java (3 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutActionServiceCEImpl.java (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutActionServiceCEImpl.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilImpl.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: server-unit-tests / server-unit-tests
  • GitHub Check: server-spotless / spotless-check
🔇 Additional comments (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/services/LayoutActionServiceImpl.java (1)

20-32:

Details

✅ Verification successful

Verify for new circular‐dependency risks after adding ApplicationService.

Injecting ApplicationService here may introduce a Spring circular-reference if ApplicationService (directly or indirectly) depends on LayoutActionServiceImpl. Please confirm start-up still succeeds and there are no proxy-bean fall-backs.

Run this quick scan:


🏁 Script executed:

#!/bin/bash
# Looks for any constructor/field injection of LayoutActionServiceImpl (or its interface) inside ApplicationService impls.
rg -n --context 2 -e 'LayoutActionServiceImpl' -e 'LayoutActionService' $(fd --type f --extension java | grep -i 'applicationservice')

Length of output: 2341


No circular‐dependency risk detected after adding ApplicationService
A quick scan confirmed that no ApplicationService implementation (CE or CE-compatible) injects LayoutActionService/LayoutActionServiceImpl. Spring startup will not hit a circular reference.

@sneha122 sneha122 added the ok-to-test Required label for CI label Jun 17, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/RunBehaviourAnalyticsUtils.java (2)

49-60: Duplicate/ambiguous timestamp fields

You’re sending both createdAt (raw Instant/Date object) and the string-formatted actionCreated.
Downstream analytics pipelines usually expect a single canonical field, otherwise they’ll coerce or drop one.

Consider removing the unformatted createdAt or renaming one of them for clarity.


70-95: Extract datasource mapping for readability

The verbose put block is repeated in several classes. Extracting it into a small helper (within this util or DatasourceMapper) makes the main flow more readable and less error-prone.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between db8f509 and b347ce2.

📒 Files selected for processing (8)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/domains/RunBehaviourAnalyticsMetadata.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/enums/RunBehaviourUpdateSource.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/RunBehaviourAnalyticsUtils.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java (6 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilImpl.java (2 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/LayoutActionServiceImpl.java (3 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutActionServiceCEImpl.java (4 hunks)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImplTest.java (11 hunks)
✅ Files skipped from review due to trivial changes (2)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/enums/RunBehaviourUpdateSource.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/domains/RunBehaviourAnalyticsMetadata.java
🚧 Files skipped from review as they are similar to previous changes (5)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/LayoutActionServiceImpl.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilImpl.java
  • app/server/appsmith-server/src/test/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImplTest.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutActionServiceCEImpl.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: server-unit-tests / server-unit-tests

@sneha122
Copy link
Contributor Author

Tested the events with reactivity:

  1. When query bound to widget with .data property -> we get following properties in event in addition to all properties similar to execute event:
{
  "newRunBehaviour": "AUTOMATIC",
  "oldRunBehaviour": "MANUAL",
  "creatorContextType": "PAGE",
  "wasChangedBy": "SYSTEM",
  "isActionPartOfModuleInstance": false,
}
  1. When query binding is removed from widget by removing .data property -> we get following properties in event in addition to all properties similar to execute event:
{
  "newRunBehaviour": "MANUAL",
  "oldRunBehaviour": "AUTOMATIC",
  "creatorContextType": "PAGE",
  "wasChangedBy": "SYSTEM",
  "isActionPartOfModuleInstance": false,
}
  1. When run behaviour is manually changed from query settings to automatic -> we get following properties in event in addition to all properties similar to execute event:
{
  "newRunBehaviour": "AUTOMATIC",
  "oldRunBehaviour": "MANUAL",
  "creatorContextType": "PAGE",
  "wasChangedBy": "USER",
  "isActionPartOfModuleInstance": false,
}
  1. When run behaviour is manually changed from query settings to manual from automatic -> we get following properties in event in addition to all properties similar to execute event:
{
  "newRunBehaviour": "MANUAL",
  "oldRunBehaviour": "AUTOMATIC",
  "creatorContextType": "PAGE",
  "wasChangedBy": "USER",
  "isActionPartOfModuleInstance": false,
}

This is verified locally by setting up segment.

CC: @subrata71 @pedro-santos-rodrigues @infinitetrooper

@sneha122
Copy link
Contributor Author

Not merging till all things in EE pass as well https://github.com/appsmithorg/appsmith-ee/pull/7804

@sneha122 sneha122 merged commit 685e955 into release Jun 17, 2025
51 of 52 checks passed
@sneha122 sneha122 deleted the chore/reactive-actions-analytic-backend-events branch June 17, 2025 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants