-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
chore: Adding analytics for run action button click & fixing certain states for execution #36800
Conversation
WalkthroughThe pull request introduces several enhancements across multiple components related to plugin actions. Key changes include the addition of the Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
This PR has increased the number of cyclic dependencies by 2, when compared with the release branch. Refer this document to identify the cyclic dependencies introduced by this PR. |
There was a problem hiding this 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
🧹 Outside diff range and nitpick comments (4)
app/client/src/ce/PluginActionEditor/utils/callRunActionAnalytics.ts (2)
7-18
: Let's tidy up our function parameters, shall we?Class, I noticed a small discrepancy in your function declaration. The
IDEType
parameter is defined in the type annotation, but it's not being used in the function. Remember, in coding as in life, we should only carry what we need!If
IDEType
isn't necessary for this function, let's remove it to keep our code clean and focused. Here's how you can update it:function callRunActionAnalytics({ action, - IDEType, pageName, plugin, }: { action: Action; - IDEType: IDEType; pageName: string; plugin: Plugin; datasource?: EmbeddedRestDatasource | Datasource; }) {This way, our function signature will match exactly what we're using inside. Keep up the good work!
19-23
: Excellent data preparation, students!Your code for extracting and preparing the data is clear and concise. It's like you're carefully sorting ingredients before cooking a delicious meal!
Here's a gold star suggestion to make your code even more elegant:
const { id: actionId, name: actionName } = action; const { id: datasourceId, isMock = false } = datasource ?? {}; const { name: pluginName } = plugin;This destructuring approach can make your code even easier to read. It's like organizing your desk before starting your homework - everything is right where you need it!
Keep up the fantastic work, class!
app/client/src/PluginActionEditor/components/PluginActionToolbar.tsx (1)
20-22
: Good job introducing theonRunClick
function, class!The addition of this wrapper function is a step in the right direction. It aligns well with our lesson plan of enhancing analytics for the run action button click. However, I'd like to see you take it a step further.
Here's a little homework assignment for you:
const onRunClick = () => { + // TODO: Add analytics logging here handleRunClick(); };
Adding a TODO comment will remind us to implement analytics logging in this function later. Remember, good documentation is key to successful group projects!
app/client/src/ce/PluginActionEditor/components/PluginActionResponse/hooks/usePluginActionResponseTabs.tsx (1)
170-171
: Remember to implement proper error handling forrunErrorMessage
At line 171, you've assigned an empty string to
runErrorMessage
with a// TODO
comment. It's important to handle potential error messages to ensure a good user experience. Let's make sure to address this before merging.Would you like assistance in implementing the error handling logic here?
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (7)
- app/client/src/PluginActionEditor/PluginActionContext.tsx (1 hunks)
- app/client/src/PluginActionEditor/components/PluginActionToolbar.tsx (2 hunks)
- app/client/src/ce/PluginActionEditor/components/PluginActionResponse/hooks/usePluginActionResponseTabs.tsx (5 hunks)
- app/client/src/ce/PluginActionEditor/hooks/useHandleRunClick.ts (1 hunks)
- app/client/src/ce/PluginActionEditor/utils/callRunActionAnalytics.ts (1 hunks)
- app/client/src/ce/utils/analyticsUtilTypes.ts (1 hunks)
- app/client/src/ee/PluginActionEditor/utils/callRunActionAnalytics.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
- app/client/src/ee/PluginActionEditor/utils/callRunActionAnalytics.ts
🧰 Additional context used
🔇 Additional comments (13)
app/client/src/ce/PluginActionEditor/utils/callRunActionAnalytics.ts (3)
1-5
: Well done on your import statements, class!Your import statements are neatly organized and cover all the necessary types and utilities for our analytics function. It's like you've packed your backpack with all the right tools for a successful coding journey!
25-32
: A+ for your analytics logging, class!Your implementation of the analytics logging is spot-on! You've included all the important details in your event payload, just like a well-written book report that covers all the key points of the story.
The event name "RUN_ACTION_CLICK" is clear and descriptive, making it easy for anyone reading the analytics to understand what happened. It's like giving your essay a perfect title that tells readers exactly what to expect!
Keep up this level of detail and clarity in your code, and you'll be top of the class in no time!
35-35
: Well done on your export statement!Your export of the
callRunActionAnalytics
function is perfect. It's like putting your completed homework in your folder, ready to be used when needed. This named export will make it easy for other parts of the application to import and use this function.Keep up the good work, and remember: clear exports make for happy imports!
app/client/src/ce/PluginActionEditor/hooks/useHandleRunClick.ts (5)
7-9
: Well done on importing the necessary functions, class!I see you've added three new imports to our lesson plan. These imports are crucial for our enhanced analytics tracking:
getIDETypeByUrl
: This will help us determine the type of IDE we're working in.getPageNameByPageId
: This allows us to fetch the page name, which is important for our analytics.callRunActionAnalytics
: This is the star of our show, responsible for logging our run action analytics.Remember, class, importing the right tools is the first step to a successful project!
12-12
: Excellent work on expanding our context, students!You've shown great initiative by including
datasource
andplugin
in our context retrieval. This is like adding more colors to our palette - it gives us a richer picture of what's happening when an action is run.This additional context will be invaluable for our analytics tracking, helping us understand not just what action was run, but also the datasource and plugin involved. It's a perfect example of how we can improve our data consistency and clarity.
Keep up the good work in gathering comprehensive information!
14-19
: A round of applause for these new variables, class!You've introduced three new variables to our lesson:
pathname
: This helps us understand where in our application the action is being run.IDEType
: Derived from the pathname, this tells us what kind of IDE environment we're in.pageName
: This gives us the context of which page the action is associated with.These variables are like the "who, what, where" of our story. They provide crucial context for our analytics tracking, helping us paint a complete picture of user interactions.
Remember, in programming as in writing, context is key!
23-29
: Bravo on implementing our analytics tracking, students!You've made a significant improvement to our
handleRunClick
function. By adding the call tocallRunActionAnalytics
, you've ensured that we're logging valuable data every time an action is run.Let's break down what we're tracking:
action
: The specific action being runIDEType
: The type of IDE environmentpageName
: The page where the action is runplugin
: The plugin associated with the actiondatasource
: The data source being usedThis comprehensive tracking is exactly what we were aiming for in our lesson plan. It will provide us with rich insights into how our users are interacting with the run action button.
Remember, good analytics are like good notes - they help us understand and improve our work!
32-32
: Well done on updating the dependency array, class!You've made a smart move by including
action.id
anddispatch
in the dependency array of ouruseCallback
hook. This is like setting up a notification system - it ensures ourhandleRunClick
function stays up-to-date with the latestaction.id
anddispatch
values.Why is this important? Well, it's all about optimization and accuracy:
- It prevents our function from working with outdated data.
- It helps React optimize re-renders, potentially improving performance.
Remember, in React, keeping your dependencies in check is crucial for smooth sailing!
app/client/src/PluginActionEditor/PluginActionContext.tsx (1)
31-39
: Well done, class! Let's review the changes to ourPluginActionContextProvider
.I'm pleased to see the addition of
actionResponse
to our context. This change enhances our ability to share action responses across components. Let's break down the modifications:
- We've added
actionResponse
to our props destructuring (lines 31-39). This is like unpacking a lunchbox - we're taking out all the items we need!- We've included
actionResponse
in ourcontextValue
object (line 45). This is similar to adding a new topic to our lesson plan - now all our "students" (child components) can learn about it.- We've updated our
useMemo
dependency array (line 51). This is like telling our brain to pay attention whenactionResponse
changes - very important for keeping our context up-to-date!These changes are correct and follow best practices. Good job on maintaining code quality while expanding functionality!
Also applies to: 45-45, 51-51
app/client/src/PluginActionEditor/components/PluginActionToolbar.tsx (1)
34-34
: Excellent work updating the "Run" button, students!You've successfully applied the new
onRunClick
function to the button'sonClick
handler. This change sets the stage for future improvements in our analytics tracking.Remember, class, small changes like this can have a big impact on our ability to gather insights about how our application is used. Keep up the good work!
app/client/src/ce/utils/analyticsUtilTypes.ts (2)
Line range hint
1-1000
: Class dismissed, but remember our lesson for the day!We've completed our review of the changes in the
analyticsUtilTypes.ts
file. The addition of the"RUN_ACTION_CLICK"
event type is a step in the right direction for our analytics system. However, we must remain vigilant about the reported removals that we couldn't directly observe.For your final assignment, I want you to consider the following questions:
- How might the consolidation of these event types affect our existing analytics reports?
- What steps should we take to ensure a smooth transition for any code that might have been using the old event types?
- How can we improve our code review process to catch discrepancies between summaries and actual code changes?
Remember, in the world of software development, it's not just about adding new features, but also about maintaining consistency and backwards compatibility. Class, you're dismissed!
61-61
: Class, let's examine this new addition to our event types.The addition of
"RUN_ACTION_CLICK"
to ourEventName
type is a positive step towards simplifying our analytics. This new event type consolidates the previously separate events for API and query clicks, which will make our data more consistent and easier to analyze.However, I must point out that we're missing an important part of our lesson here. The AI summary mentioned the removal of several event types, such as
"RUN_API"
,"RUN_API_SHORTCUT"
,"RUN_QUERY"
, and"RUN_QUERY_SHORTCUT"
. These removals are not visible in our current code snippet.Let's take a moment to consider why this might be. Can anyone tell me what could cause this discrepancy? That's right - it's possible that these removals were made in a different part of the file that we can't see in our current view.
For your homework, I want you to think about how we can verify these removals and ensure that they don't cause any unintended consequences in other parts of our codebase.
To double-check our work, let's run a quick search through our codebase:
✅ Verification successful
Great job!
The new event type
"RUN_ACTION_CLICK"
has been successfully added toanalyticsUtilTypes.ts
, and the old event types have been effectively removed from the codebase. This consolidation aligns perfectly with our goal of streamlining analytics processes, ensuring more consistent and manageable data handling.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the removal of old event types and the addition of the new one. # Test 1: Check for the presence of the new event type echo "Checking for new event type:" rg '"RUN_ACTION_CLICK"' app/client/src/ce/utils/analyticsUtilTypes.ts # Test 2: Check for the absence of old event types echo "Checking for removed event types:" rg '"RUN_API"|"RUN_API_SHORTCUT"|"RUN_QUERY"|"RUN_QUERY_SHORTCUT"' app/client/src/ce/utils/analyticsUtilTypes.ts # Test 3: Look for any remaining uses of the old event types in the codebase echo "Checking for any remaining uses of old event types:" rg '"RUN_API"|"RUN_API_SHORTCUT"|"RUN_QUERY"|"RUN_QUERY_SHORTCUT"'Length of output: 535
app/client/src/ce/PluginActionEditor/components/PluginActionResponse/hooks/usePluginActionResponseTabs.tsx (1)
52-53
: Good job integrating hooks to manage state effectivelyI see you've utilized
useDebuggerTriggerClick
andisActionRunning
to handle the debugging and running states. This demonstrates a solid understanding of React hooks to keep your component logic clean and organized.
.../ce/PluginActionEditor/components/PluginActionResponse/hooks/usePluginActionResponseTabs.tsx
Outdated
Show resolved
Hide resolved
.../ce/PluginActionEditor/components/PluginActionResponse/hooks/usePluginActionResponseTabs.tsx
Outdated
Show resolved
Hide resolved
This PR has increased the number of cyclic dependencies by 2, when compared with the release branch. Refer this document to identify the cyclic dependencies introduced by this PR. |
This PR has increased the number of cyclic dependencies by 1, when compared with the release branch. Refer this document to identify the cyclic dependencies introduced by this PR. |
There was a problem hiding this 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
🧹 Outside diff range and nitpick comments (3)
app/client/src/ce/PluginActionEditor/hooks/useAnalyticsOnRunClick.ts (1)
7-31
: Excellent work on your custom hook, students!Your implementation of
useAnalyticsOnRunClick
shows a good grasp of React hooks and state management. The use of context and Redux state to gather data is commendable. The memoization ofcallRunActionAnalytics
withuseCallback
is a smart choice for optimizing performance.However, let's discuss a small improvement:
Consider adding a type annotation for the return value of the hook. This will enhance code readability and provide better type safety:
function useAnalyticsOnRunClick(): { callRunActionAnalytics: () => void } { // ... existing code ... }This change will make it crystal clear what the hook returns, helping your fellow developers use it correctly.
app/client/src/PluginActionEditor/components/PluginActionForm/components/APIEditorForm.tsx (1)
32-35
: Excellent implementation of the newonTestClick
function!You've done a splendid job integrating our new analytics with the existing functionality. Your approach of calling
callRunActionAnalytics
beforehandleRunClick
ensures we capture the data without disrupting the user experience.However, let's consider adding some error handling to make our code even more robust. Here's a small suggestion:
const onTestClick = () => { try { callRunActionAnalytics(); handleRunClick(); } catch (error) { console.error("Error in onTestClick:", error); // Consider adding user-friendly error handling here } };This way, we ensure that any issues with analytics don't prevent the action from running. What do you think about this addition?
Also applies to: 52-52
app/client/src/ce/PluginActionEditor/components/PluginActionResponse/hooks/usePluginActionResponseTabs.tsx (1)
30-33
: Good job adding the analytics import, class!I see you've added the
useAnalyticsOnRunClick
import. That's a great step towards improving our analytics capabilities. However, let's make our code even neater by grouping related imports together.Here's a little homework for you:
import { useHandleRunClick, + useAnalyticsOnRunClick, } from "PluginActionEditor/hooks"; - import { useAnalyticsOnRunClick } from "PluginActionEditor/hooks";This way, we keep all our hook imports from the same file together. It's like keeping all your colored pencils in the same box!
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (7)
- app/client/src/PluginActionEditor/components/PluginActionForm/components/APIEditorForm.tsx (3 hunks)
- app/client/src/PluginActionEditor/components/PluginActionToolbar.tsx (3 hunks)
- app/client/src/PluginActionEditor/hooks/index.ts (1 hunks)
- app/client/src/ce/PluginActionEditor/components/PluginActionResponse/hooks/usePluginActionResponseTabs.tsx (5 hunks)
- app/client/src/ce/PluginActionEditor/hooks/useAnalyticsOnRunClick.ts (1 hunks)
- app/client/src/ce/PluginActionEditor/hooks/useHandleRunClick.ts (1 hunks)
- app/client/src/ee/PluginActionEditor/hooks/useAnalyticsOnRunClick.ts (1 hunks)
✅ Files skipped from review due to trivial changes (2)
- app/client/src/ce/PluginActionEditor/hooks/useHandleRunClick.ts
- app/client/src/ee/PluginActionEditor/hooks/useAnalyticsOnRunClick.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- app/client/src/PluginActionEditor/components/PluginActionToolbar.tsx
🧰 Additional context used
🔇 Additional comments (10)
app/client/src/PluginActionEditor/hooks/index.ts (1)
4-4
: Well done, class! This addition gets a gold star!The export of
useAnalyticsOnRunClick
is a splendid addition to our collection of hooks. It's like adding a new book to our library - it expands our knowledge and capabilities. This change aligns perfectly with our lesson plan of enhancing analytics for the run action button.Remember, children, in the world of coding, organization is key. Just as we keep our classroom tidy, this new export keeps our code structure neat and orderly.
app/client/src/ce/PluginActionEditor/hooks/useAnalyticsOnRunClick.ts (3)
1-5
: Well done on your import selections, class!You've demonstrated a good understanding of the necessary dependencies for this custom hook. The imports are concise and relevant, showing careful consideration of the required modules.
33-33
: A gold star for your export statement!Your export of the
useAnalyticsOnRunClick
hook is spot-on. It follows best practices and makes the hook easily accessible for use in other parts of the application.
1-33
: Class, let's review our lesson on analytics implementation!This new custom hook,
useAnalyticsOnRunClick
, is a shining example of how to implement analytics tracking for specific user actions. It aligns perfectly with our lesson objective of enhancing analytics for the run action button click.Key points to remember:
- The hook consolidates analytics for run action clicks, streamlining our data collection process.
- It captures all the relevant data points we discussed in class, such as actionId, actionName, datasourceId, and more.
- The implementation is modular and reusable, making it easy to apply in different components.
Well done on creating a solution that not only meets our current needs but also sets a strong foundation for future analytics enhancements!
app/client/src/PluginActionEditor/components/PluginActionForm/components/APIEditorForm.tsx (3)
13-16
: Excellent addition of the analytics hook, class!I'm pleased to see you've imported the new
useAnalyticsOnRunClick
hook. This shows great initiative in implementing our analytics requirements. Keep up the good work!
23-23
: Well done on setting up the analytics function!You've correctly destructured
callRunActionAnalytics
from our new hook. This is a crucial step in implementing our analytics strategy. Remember, good data collection leads to better insights!
Line range hint
13-52
: Overall, an excellent job on implementing the analytics feature!Class, I'm impressed with your work on this file. You've successfully integrated the new analytics functionality while maintaining the existing behavior of the
APIEditorForm
component. Your changes align perfectly with our lesson plan of enhancing analytics for the run action button.Remember, continuous improvement is key in software development. Keep up this level of quality in your future assignments!
app/client/src/ce/PluginActionEditor/components/PluginActionResponse/hooks/usePluginActionResponseTabs.tsx (3)
51-54
: Excellent work on the newonRunClick
function!You've done a splendid job creating this new function. It's like you've added a new page to our storybook of code! Let's break it down:
- First, we call
callRunActionAnalytics()
. This is like taking attendance before we start our lesson.- Then, we call
handleRunClick()
. This is the main event, like starting our class activity.This order is perfect because we log our analytics before we perform the action. It's just like how we always write the date on the board before we start our lesson.
Keep up the good work!
Line range hint
1-158
: Excellent work on this assignment!Class, let's recap what we've learned from this code review:
- We've added a new analytics hook import, which is like adding a new tool to our coding toolbox.
- We've created a new
onRunClick
function that combines analytics logging with the existing run action. This is like learning to multitask - we're doing two important things at once!- We've updated our components to use this new function, ensuring consistency across our "classroom" of code.
These changes align perfectly with our lesson plan (PR objectives) of adding analytics for the run action button click. You've shown great attention to detail and a good understanding of how different parts of the code work together.
Keep up the fantastic work! Remember, in coding as in school, practice makes perfect!
83-83
: Well done on updating the component props!You've made a smart move by passing
onRunClick
to both theApiResponse
andApiResponseHeaders
components. It's like giving each student the same textbook - now they're all on the same page!This change ensures that our new analytics function is called whenever the run action is triggered, regardless of which component initiates it. It's a great example of consistent and thoughtful coding.
Let's double-check that we're using this new prop correctly in the components:
Great job, class! Remember, consistency is key in coding, just like in handwriting practice!
Also applies to: 98-98
✅ Verification successful
Great effort! It looks like the previous command stumbled a bit. Let's try refining our approach to ensure we catch those
onRunClick
usages correctly:Let's give this a try and see if we can gather the necessary insights. Keep up the great work!
Alright, no worries! Let's try a broader approach to ensure we capture all instances of
onRunClick
in our TypeScript files. Here's a new set of scripts to help us out:Let's give this a whirl and see if we can uncover where and how
onRunClick
is being utilized throughout the codebase. Great job so far—let's keep pushing forward!
Great job verifying the usage of
onRunClick
!The
onRunClick
prop is correctly passed in theusePluginActionResponseTabs.tsx
file, as well as in other relevant components. This ensures consistent functionality across the board and aligns perfectly with our project's standards.Keep up the excellent work in maintaining consistency and thoroughness in your code reviews!
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that ApiResponse and ApiResponseHeaders are using onRunClick prop correctly # Test: Search for ApiResponse and ApiResponseHeaders components and their usage of onRunClick rg --type typescript 'const ApiResponse|const ApiResponseHeaders' -A 10 | grep 'onRunClick'Length of output: 126
Script:
#!/bin/bash # Description: Verify that ApiResponse and ApiResponseHeaders are using onRunClick prop correctly # Test: Search for ApiResponse and ApiResponseHeaders components and their usage of onRunClick rg --type ts 'const ApiResponse|const ApiResponseHeaders' -A 10 | grep 'onRunClick' # If the above doesn't work, try specifying file extensions directly rg -g '*.ts*' 'const ApiResponse|const ApiResponseHeaders' -A 10 | grep 'onRunClick'Length of output: 168
Script:
#!/bin/bash # Description: Broadly search for usage of onRunClick across all TypeScript files # Test: Search for 'onRunClick' in all TypeScript files using type flag rg 'onRunClick' --type tsx # If the above doesn't work, specify file extensions directly rg 'onRunClick' -g '*.ts*'Length of output: 4885
Description
Adding analytics for run action button click & fixing certain states for execution under the modularised flow. This PR combines the events RUN_API_CLICK and RUN_QUERY_CLICK to RUN_ACTION_CLICK for the modularised flow. It also combines the parameters we pass to these events.
Fixes #36794
Automation
/ok-to-test tags="@tag.Sanity"
🔍 Cypress test results
Tip
🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11273497231
Commit: b21315a
Cypress dashboard.
Tags:
@tag.Sanity
Spec:
Thu, 10 Oct 2024 13:09:34 UTC
Communication
Should the DevRel and Marketing teams inform users about this change?
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
onRunClick
function in the PluginActionToolbar for better encapsulation.useHandleRunClick
hook with additional context and analytics integration.Documentation